# Bad git log behavior with multiple glob path arguments

3 messages from 2014-03-05 to 2014-03-05. Participants: Jeremy Nickurak, Duy Nguyen.
Thread: https://gitlist.dev/t/36062

## Jeremy Nickurak, 2014-03-05 05:56

Subject: Bad git log behavior with multiple glob path arguments
Message-ID: <CA+eQo_21j=GzsvWAjxzr+aFYcPcnnyozySOo0m9bO-xJq_6a9A@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BeQo_21j%3DGzsvWAjxzr%2BaFYcPcnnyozySOo0m9bO-xJq_6a9A%40mail.gmail.com

```
git log seems to understand globs in the last path argument, and the
last path argument only. I didn't see anything in the git log man page
expressly saying this was to be expected, but it does seem like it
ought to work for all the arguments or none of them.

Here's a little shell script I ended up using to convince myself I
wasn't going crazy. I'd expect the same output for all of the git log
test, since they all specify (either with globs or not) all the files
added to the repository. Alternatively, if globs aren't expected to
work, I'd at least expect all the glob tests to return nothing.

Note that glob matching doesn't seem to occur unless '--' is included.
I'm not exactly clear on why that is.

#!/bin/sh

TESTREPO="$(pwd)/bad-glob-test-repo"

rm  -rf "$TESTREPO"

echo "Running tests in $TESTREPO"
mkdir "$TESTREPO"
cd "$TESTREPO"
mkdir subdira
mkdir subdirb
mkdir subdirc

git init
echo a > subdira/file.txt
echo b > subdirb/file.txt
echo c > subdirc/file.txt

git add subdira/file.txt
git commit -m 'a'

git add subdirb/file.txt
git commit -m 'b'

git add subdirc/file.txt
git commit -m 'c'

echo Glob Test 1: git log --oneline -- 'subdira/*.txt' 'subdirb/*.txt'
'subdirc/*.txt'
git log --oneline -- 'subdira/*.txt' 'subdirb/*.txt' 'subdirc/*.txt'

echo Glob Test 2: git log --oneline -- 'subdira/*.txt' 'subdirc/*.txt'
'subdirb/*.txt'
git log --oneline -- 'subdira/*.txt' 'subdirc/*.txt' 'subdirb/*.txt'

echo Glob Test 3: git log --oneline -- 'subdirb/*.txt' 'subdira/*.txt'
'subdirc/*.txt'
git log --oneline -- 'subdirb/*.txt' 'subdira/*.txt' 'subdirc/*.txt'

echo Glob Test 4: git log --oneline -- 'subdirb/*.txt' 'subdirc/*.txt'
'subdira/*.txt'
git log --oneline -- 'subdirb/*.txt' 'subdirc/*.txt' 'subdira/*.txt'

echo Glob Test 5: git log --oneline -- 'subdirc/*.txt' 'subdira/*.txt'
'subdirb/*.txt'
git log --oneline -- 'subdirc/*.txt' 'subdira/*.txt' 'subdirb/*.txt'

echo Glob Test 6: git log --oneline -- 'subdirc/*.txt' 'subdirb/*.txt'
'subdira/*.txt'
git log --oneline -- 'subdirc/*.txt' 'subdirb/*.txt' 'subdira/*.txt'

echo Explicit Test 1: git log --oneline -- 'subdira/file.txt'
'subdirb/file.txt' 'subdirc/file.txt'
git log --oneline -- 'subdira/file.txt' 'subdirb/file.txt' 'subdirc/file.txt'

echo Explicit Test 2: git log --oneline -- 'subdira/file.txt'
'subdirc/file.txt' 'subdirb/file.txt'
git log --oneline -- 'subdira/file.txt' 'subdirc/file.txt' 'subdirb/file.txt'

echo Explicit Test 3: git log --oneline -- 'subdirb/file.txt'
'subdira/file.txt' 'subdirc/file.txt'
git log --oneline -- 'subdirb/file.txt' 'subdira/file.txt' 'subdirc/file.txt'

echo Explicit Test 4: git log --oneline -- 'subdirb/file.txt'
'subdirc/file.txt' 'subdira/file.txt'
git log --oneline -- 'subdirb/file.txt' 'subdirc/file.txt' 'subdira/file.txt'

echo Explicit Test 5: git log --oneline -- 'subdirc/file.txt'
'subdira/file.txt' 'subdirb/file.txt'
git log --oneline -- 'subdirc/file.txt' 'subdira/file.txt' 'subdirb/file.txt'

echo Explicit Test 6: git log --oneline -- 'subdirc/file.txt'
'subdirb/file.txt' 'subdira/file.txt'
git log --oneline -- 'subdirc/file.txt' 'subdirb/file.txt' 'subdira/file.txt'

-- 
Jeremy Nickurak -= Email/XMPP: -= jeremy@nickurak.ca =-

```

## Duy Nguyen, 2014-03-05 10:01

Subject: Re: Bad git log behavior with multiple glob path arguments
Message-ID: <CACsJy8A28x5m1SLV-R=QrFniPXUbV+x9N27GA-j+Ut_oe_6oGQ@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8A28x5m1SLV-R%3DQrFniPXUbV%2Bx9N27GA-j%2BUt_oe_6oGQ%40mail.gmail.com
In-Reply-To: <CA+eQo_21j=GzsvWAjxzr+aFYcPcnnyozySOo0m9bO-xJq_6a9A@mail.gmail.com>

```
On Wed, Mar 5, 2014 at 12:56 PM, Jeremy Nickurak <jeremy@nickurak.ca> wrote:
> git log seems to understand globs in the last path argument, and the
> last path argument only. I didn't see anything in the git log man page
> expressly saying this was to be expected, but it does seem like it
> ought to work for all the arguments or none of them.

What version did you use? We have a fix in the same area,
e4ddb05 (tree_entry_interesting: match against all pathspecs -
2014-01-25), and it's in v1.8.5.5 and v1.9.0

> Here's a little shell script I ended up using to convince myself I
> wasn't going crazy. I'd expect the same output for all of the git log
> test, since they all specify (either with globs or not) all the files
> added to the repository. Alternatively, if globs aren't expected to
> work, I'd at least expect all the glob tests to return nothing.
>
> Note that glob matching doesn't seem to occur unless '--' is included.

do you mean "git log" does not run at all and complains about
disambiguation, or it runs but nothing is filtered?

> I'm not exactly clear on why that is.
>
> #!/bin/sh
>
> TESTREPO="$(pwd)/bad-glob-test-repo"
>
> rm  -rf "$TESTREPO"
>
> echo "Running tests in $TESTREPO"
> mkdir "$TESTREPO"
> cd "$TESTREPO"
> mkdir subdira
> mkdir subdirb
> mkdir subdirc
>
> git init
> echo a > subdira/file.txt
> echo b > subdirb/file.txt
> echo c > subdirc/file.txt
>
> git add subdira/file.txt
> git commit -m 'a'
>
> git add subdirb/file.txt
> git commit -m 'b'
>
> git add subdirc/file.txt
> git commit -m 'c'
>
> echo Glob Test 1: git log --oneline -- 'subdira/*.txt' 'subdirb/*.txt'
> 'subdirc/*.txt'
> git log --oneline -- 'subdira/*.txt' 'subdirb/*.txt' 'subdirc/*.txt'
>
> echo Glob Test 2: git log --oneline -- 'subdira/*.txt' 'subdirc/*.txt'
> 'subdirb/*.txt'
> git log --oneline -- 'subdira/*.txt' 'subdirc/*.txt' 'subdirb/*.txt'
>
> echo Glob Test 3: git log --oneline -- 'subdirb/*.txt' 'subdira/*.txt'
> 'subdirc/*.txt'
> git log --oneline -- 'subdirb/*.txt' 'subdira/*.txt' 'subdirc/*.txt'
>
> echo Glob Test 4: git log --oneline -- 'subdirb/*.txt' 'subdirc/*.txt'
> 'subdira/*.txt'
> git log --oneline -- 'subdirb/*.txt' 'subdirc/*.txt' 'subdira/*.txt'
>
> echo Glob Test 5: git log --oneline -- 'subdirc/*.txt' 'subdira/*.txt'
> 'subdirb/*.txt'
> git log --oneline -- 'subdirc/*.txt' 'subdira/*.txt' 'subdirb/*.txt'
>
> echo Glob Test 6: git log --oneline -- 'subdirc/*.txt' 'subdirb/*.txt'
> 'subdira/*.txt'
> git log --oneline -- 'subdirc/*.txt' 'subdirb/*.txt' 'subdira/*.txt'
>
> echo Explicit Test 1: git log --oneline -- 'subdira/file.txt'
> 'subdirb/file.txt' 'subdirc/file.txt'
> git log --oneline -- 'subdira/file.txt' 'subdirb/file.txt' 'subdirc/file.txt'
>
> echo Explicit Test 2: git log --oneline -- 'subdira/file.txt'
> 'subdirc/file.txt' 'subdirb/file.txt'
> git log --oneline -- 'subdira/file.txt' 'subdirc/file.txt' 'subdirb/file.txt'
>
> echo Explicit Test 3: git log --oneline -- 'subdirb/file.txt'
> 'subdira/file.txt' 'subdirc/file.txt'
> git log --oneline -- 'subdirb/file.txt' 'subdira/file.txt' 'subdirc/file.txt'
>
> echo Explicit Test 4: git log --oneline -- 'subdirb/file.txt'
> 'subdirc/file.txt' 'subdira/file.txt'
> git log --oneline -- 'subdirb/file.txt' 'subdirc/file.txt' 'subdira/file.txt'
>
> echo Explicit Test 5: git log --oneline -- 'subdirc/file.txt'
> 'subdira/file.txt' 'subdirb/file.txt'
> git log --oneline -- 'subdirc/file.txt' 'subdira/file.txt' 'subdirb/file.txt'
>
> echo Explicit Test 6: git log --oneline -- 'subdirc/file.txt'
> 'subdirb/file.txt' 'subdira/file.txt'
> git log --oneline -- 'subdirc/file.txt' 'subdirb/file.txt' 'subdira/file.txt'
>
> --
> Jeremy Nickurak -= Email/XMPP: -= jeremy@nickurak.ca =-
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Duy

```

## Jeremy Nickurak, 2014-03-05 16:21

Subject: Re: Bad git log behavior with multiple glob path arguments
Message-ID: <CA+eQo_2Gcipe7VA7WMY+etULjmSC=TqGmpZmGSGeWv03c93FDA@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BeQo_2Gcipe7VA7WMY%2BetULjmSC%3DTqGmpZmGSGeWv03c93FDA%40mail.gmail.com
In-Reply-To: <CACsJy8A28x5m1SLV-R=QrFniPXUbV+x9N27GA-j+Ut_oe_6oGQ@mail.gmail.com>

```
On Wed, Mar 5, 2014 at 3:01 AM, Duy Nguyen <pclouds@gmail.com> wrote:
> On Wed, Mar 5, 2014 at 12:56 PM, Jeremy Nickurak <jeremy@nickurak.ca> wrote:
>> git log seems to understand globs in the last path argument, and the
>> last path argument only. I didn't see anything in the git log man page
>> expressly saying this was to be expected, but it does seem like it
>> ought to work for all the arguments or none of them.
>
> What version did you use? We have a fix in the same area,
> e4ddb05 (tree_entry_interesting: match against all pathspecs -
> 2014-01-25), and it's in v1.8.5.5 and v1.9.0

So close! :) 1.8.5.3

>> Note that glob matching doesn't seem to occur unless '--' is included.
>
> do you mean "git log" does not run at all and complains about
> disambiguation, or it runs but nothing is filtered?

It complains about disambiguation:

$ mkdir -p ~/tmp; cd ~/tmp; git init; echo hello > hello.txt; git add
hello.txt; git commit -m hello; echo "Without --:"; git log --oneline
'*.txt'; echo "With --:"; git log --oneline -- '*.txt';
Reinitialized existing Git repository in /home/nickuj/tmp/.git/
On branch master
nothing to commit, working directory clean
Without --:
fatal: ambiguous argument '*.txt': unknown revision or path not in the
working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
With --:
78ff378 hello

```
