git check-ignore --verbose fails oddly when invoked via an alias

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all,

I have some bizarre behavior I cannot explain. Worse, I've had a hard
time coming up with a minimal test-case for it.

I have the following two aliases:

    ig = check-ignore
    igv = !git ig --verbose

I use them to verify git-ignore rules occasionally. Today, I was
working on a project where git igv * kept failing (exit code 1,
indicating none of the provided files are ignored). However, when I do
git check-ignore --verbose *, I get the expected output.

You'll even see in the GIT_TRACE outputs above that one behaves very
differently from the other for unknown reasons

Debugging information:

$ pwd
/Users/Knoble/write/junk-drawer/code
$ g rev-parse --show-toplevel
/Users/Knoble/write/junk-drawer
$ tree -a sml-binary
sml-binary/
├── .cm
│   ├── GUID
│   │   └── myprog.sml
│   ├── SKEL
│   │   └── myprog.sml
│   └── amd64-unix
│       └── myprog.sml
├── .gitignore
├── Makefile
├── myprog
├── myprog.amd64-darwin
├── myprog.cm
├── myprog.sml
└── tmp
    ├── bin
    │   └── myprog
    └── lib
        └── myprog.amd64-darwin

7 directories, 11 files
$ cat sml-binary/.gitignore
myprog
myprog.amd64-darwin
$ g check-ignore sml-binary/*
sml-binary/myprog
sml-binary/myprog.amd64-darwin
$ g check-ignore --verbose sml-binary/*
code/sml-binary/.gitignore:1:myprog sml-binary/myprog
code/sml-binary/.gitignore:2:myprog.amd64-darwin sml-binary/myprog.amd64-darwin
$ g ig sml-binary/*
sml-binary/myprog
sml-binary/myprog.amd64-darwin
$ g igv sml-binary/*
$ echo $?
1
$ pushd sml-binary/
~/write/junk-drawer/code/sml-binary ~/write/junk-drawer/code
~/write/junk-drawer/code/sml-binary
$ g ig *
myprog
myprog.amd64-darwin
$ g ig --verbose *
code/sml-binary/.gitignore:1:myprog myprog
code/sml-binary/.gitignore:2:myprog.amd64-darwin myprog.amd64-darwin
$ g igv *
$ echo $?
1
$ GIT_TRACE2=2 g igv *
15:48:21.773549 common-main.c:48                  version 2.26.2
15:48:21.773904 common-main.c:49                  start git igv
Makefile myprog myprog.amd64-darwin myprog.cm myprog.sml tmp
15:48:21.774443 git.c:697                         cmd_name
_run_dashed_ (_run_dashed_)
15:48:21.774473 run-command.c:735                 child_start[0]
git-igv Makefile myprog myprog.amd64-darwin myprog.cm myprog.sml tmp
15:48:21.774735 run-command.c:950                 child_exit[0] pid:-1
code:-1 elapsed:0.000249
15:48:21.775368 repository.c:130                  worktree
/Users/Knoble/write/junk-drawer
15:48:21.775427 git.c:352                         alias igv -> 'git ig
--verbose' Makefile myprog myprog.amd64-darwin myprog.cm myprog.sml
tmp
15:48:21.775439 git.c:354                         cmd_name
_run_shell_alias_ (_run_dashed_/_run_shell_alias_)
15:48:21.775445 run-command.c:735                 child_start[1] 'git
ig --verbose' Makefile myprog myprog.amd64-darwin myprog.cm myprog.sml
tmp
15:48:21.786123 common-main.c:48                  version 2.26.2
15:48:21.786579 common-main.c:49                  start git ig
--verbose Makefile myprog myprog.amd64-darwin myprog.cm myprog.sml tmp
15:48:21.787201 git.c:697                         cmd_name
_run_dashed_ (_run_dashed_/_run_shell_alias_/_run_dashed_)
15:48:21.787243 run-command.c:735                 child_start[0]
git-ig --verbose Makefile myprog myprog.amd64-darwin myprog.cm
myprog.sml tmp
15:48:21.787464 run-command.c:950                 child_exit[0] pid:-1
code:-1 elapsed:0.000216
15:48:21.787781 git.c:389                         alias ig ->
check-ignore --verbose Makefile myprog myprog.amd64-darwin myprog.cm
myprog.sml tmp
15:48:21.787794 git.c:753                         cmd_name
_run_git_alias_
(_run_dashed_/_run_shell_alias_/_run_dashed_/_run_git_alias_)
15:48:21.787801 run-command.c:735                 child_start[1] git
check-ignore --verbose Makefile myprog myprog.amd64-darwin myprog.cm
myprog.sml tmp
15:48:21.793959 common-main.c:48                  version 2.26.2
15:48:21.794206 common-main.c:49                  start
/usr/local/Cellar/git/2.26.2/libexec/git-core/git check-ignore
--verbose Makefile myprog myprog.amd64-darwin myprog.cm myprog.sml tmp
15:48:21.794427 repository.c:130                  worktree
/Users/Knoble/write/junk-drawer
15:48:21.794671 git.c:440                         cmd_name
check-ignore (_run_dashed_/_run_shell_alias_/_run_dashed_/_run_git_alias_/check-ignore)
15:48:21.795513 git.c:674                         exit elapsed:0.003100 code:1
15:48:21.795529 trace2/tr2_tgt_normal.c:123       atexit elapsed:0.003121 code:1
15:48:21.795935 run-command.c:990                 child_exit[1]
pid:98684 code:1 elapsed:0.008108
15:48:21.795971 git.c:773                         exit elapsed:0.012124 code:1
15:48:21.795995 trace2/tr2_tgt_normal.c:123       atexit elapsed:0.012139 code:1
15:48:21.796351 run-command.c:990                 child_exit[1]
pid:98683 code:1 elapsed:0.020896
15:48:21.796391 git.c:358                         exit elapsed:0.024746 code:1
15:48:21.796416 trace2/tr2_tgt_normal.c:123       atexit elapsed:0.024761 code:1
$ GIT_TRACE2=2 g ig --verbose *
15:57:42.274337 common-main.c:48                  version 2.26.2
15:57:42.274640 common-main.c:49                  start git ig
--verbose Makefile myprog myprog.amd64-darwin myprog.cm myprog.sml tmp
15:57:42.275146 git.c:697                         cmd_name
_run_dashed_ (_run_dashed_)
15:57:42.275167 run-command.c:735                 child_start[0]
git-ig --verbose Makefile myprog myprog.amd64-darwin myprog.cm
myprog.sml tmp
15:57:42.275422 run-command.c:950                 child_exit[0] pid:-1
code:-1 elapsed:0.000246
15:57:42.275763 git.c:389                         alias ig ->
check-ignore --verbose Makefile myprog myprog.amd64-darwin myprog.cm
myprog.sml tmp
15:57:42.275781 git.c:753                         cmd_name
_run_git_alias_ (_run_dashed_/_run_git_alias_)
15:57:42.275794 run-command.c:735                 child_start[1] git
check-ignore --verbose Makefile myprog myprog.amd64-darwin myprog.cm
myprog.sml tmp
15:57:42.282613 common-main.c:48                  version 2.26.2
15:57:42.282876 common-main.c:49                  start
/usr/local/Cellar/git/2.26.2/libexec/git-core/git check-ignore
--verbose Makefile myprog myprog.amd64-darwin myprog.cm myprog.sml tmp
15:57:42.283146 repository.c:130                  worktree
/Users/Knoble/write/junk-drawer
15:57:42.283520 git.c:440                         cmd_name
check-ignore (_run_dashed_/_run_git_alias_/check-ignore)
code/sml-binary/.gitignore:1:myprog     myprog
code/sml-binary/.gitignore:2:myprog.amd64-darwin        myprog.amd64-darwin
15:57:42.284561 git.c:674                         exit elapsed:0.003839 code:0
15:57:42.284588 trace2/tr2_tgt_normal.c:123       atexit elapsed:0.003876 code:0
15:57:42.285171 run-command.c:990                 child_exit[1]
pid:99078 code:0 elapsed:0.009354
15:57:42.285212 git.c:773                         exit elapsed:0.012930 code:0
15:57:42.285246 trace2/tr2_tgt_normal.c:123       atexit elapsed:0.012950 code:0

Failed attempt to produce a minimal example:

$ g init
Dépôt Git vide initialisé dans /private/tmp/git-test/.git/
$ mkdir subdir
$ touch subdir/{a..c}
$ ls
subdir/
$ tree
.
└── subdir
    ├── a
    ├── b
    └── c

1 directory, 3 files
$ echo a >> subdir/.gitignore
$ g status -s
?? subdir/
$ g add --intend-to-add .
$ g status -s
 A subdir/.gitignore
 A subdir/b
 A subdir/c
$ g commit --all -m 'init'
[master (commit racine) 832876e] init
 3 files changed, 1 insertion(+)
 create mode 100644 subdir/.gitignore
 create mode 100644 subdir/b
 create mode 100644 subdir/c
$ g igv *
$ echo $?
1
# ^^^ expected, nothing ignored
$ g igv subdir/*
subdir/.gitignore:1:a   subdir/a
# ^^^ also expected???

D. Ben Knoble




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux