Bug 577227 - Result of git log -- <path> is wrong
Summary: Result of git log -- <path> is wrong
Status: RESOLVED FIXED
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 5.13.1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-12 02:15 EST by Kyle Zhao CLA
Modified: 2021-12-19 21:09 EST (History)
1 user (show)

See Also:


Attachments
the test repo (31.40 KB, application/zip)
2021-11-12 02:15 EST, Kyle Zhao CLA
no flags Details
test repo (31.36 KB, application/zip)
2021-11-12 02:24 EST, Kyle Zhao CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle Zhao CLA 2021-11-12 02:15:28 EST
Created attachment 287497 [details]
the test repo

```
mkdir test-path-filter-repo
cd test-path-filter-repo
git init
mkdir -p src/d1
touch src/d1/file1
git add *
git commit -m "file1"
git branch b1
touch src/d1/file2
git add *
git commit -m "file2"
git checkout b1
touch src/d1/file3
git add *
git commit -m "file3"
git checkout master
git merge b1
```

I used the above commands to create the test repository.
In this test repository, the jgit result of git log - <path> is wrong.

$ jgit log -- src/d1
commit 88c7262d9ea93b4f23b6970580908f99c09f10da
Author: kylezhao <kylezhao@tencent.com>
Date:   Fri Nov 12 14:56:54 2021 +0800

    Merge branch 'b1'

commit 8af1b91e261dcb5b01f4c6efcd1435b661dc0e2e
Author: kylezhao <kylezhao@tencent.com>
Date:   Fri Nov 12 14:56:54 2021 +0800

    file2

commit 9a83592dd073777b7e813b5dbe89831df6c1ee45
Author: kylezhao <kylezhao@tencent.com>
Date:   Fri Nov 12 14:56:54 2021 +0800

    file3


As we can see, The commit which commit message is "file1" is missing!
I then tested with cgit and found that the cgit result was correct.
Comment 1 Kyle Zhao CLA 2021-11-12 02:24:37 EST
Created attachment 287498 [details]
test repo
Comment 2 Eclipse Genie CLA 2021-11-12 02:32:28 EST
New Gerrit change created: https://git.eclipse.org/r/c/jgit/jgit/+/187660
Comment 3 Matthias Sohn CLA 2021-12-12 17:50:04 EST
(In reply to Kyle Zhao from comment #0)
> Created attachment 287497 [details]
> the test repo
> 
> ```
> mkdir test-path-filter-repo
> cd test-path-filter-repo
> git init
> mkdir -p src/d1
> touch src/d1/file1
> git add *
> git commit -m "file1"
> git branch b1
> touch src/d1/file2
> git add *
> git commit -m "file2"
> git checkout b1
> touch src/d1/file3
> git add *
> git commit -m "file3"
> git checkout master
> git merge b1
> ```
> 
> I used the above commands to create the test repository.
> In this test repository, the jgit result of git log - <path> is wrong.
> 
> $ jgit log -- src/d1
> commit 88c7262d9ea93b4f23b6970580908f99c09f10da
> Author: kylezhao <kylezhao@tencent.com>
> Date:   Fri Nov 12 14:56:54 2021 +0800
> 
>     Merge branch 'b1'
> 
> commit 8af1b91e261dcb5b01f4c6efcd1435b661dc0e2e
> Author: kylezhao <kylezhao@tencent.com>
> Date:   Fri Nov 12 14:56:54 2021 +0800
> 
>     file2
> 
> commit 9a83592dd073777b7e813b5dbe89831df6c1ee45
> Author: kylezhao <kylezhao@tencent.com>
> Date:   Fri Nov 12 14:56:54 2021 +0800
> 
>     file3
> 
> 
> As we can see, The commit which commit message is "file1" is missing!
> I then tested with cgit and found that the cgit result was correct.

I can't reproduce this using jgit stable-5.13 (35713588f):

$ jgit log
commit 88c7262d9ea93b4f23b6970580908f99c09f10da
Author: kylezhao <kylezhao@tencent.com>
Date:   Fri Nov 12 14:56:54 2021 +0800

    Merge branch 'b1'

commit 8af1b91e261dcb5b01f4c6efcd1435b661dc0e2e
Author: kylezhao <kylezhao@tencent.com>
Date:   Fri Nov 12 14:56:54 2021 +0800

    file2

commit 9a83592dd073777b7e813b5dbe89831df6c1ee45
Author: kylezhao <kylezhao@tencent.com>
Date:   Fri Nov 12 14:56:54 2021 +0800

    file3

commit 5bf044d5d96704475474a5e5c20898a636837c51
Author: kylezhao <kylezhao@tencent.com>
Date:   Fri Nov 12 14:56:54 2021 +0800

    file1
Comment 4 Kyle Zhao CLA 2021-12-15 02:24:01 EST
(In reply to Matthias Sohn from comment #3)
> (In reply to Kyle Zhao from comment #0)
> > Created attachment 287497 [details]
> > the test repo
> > 
> > ```
> > mkdir test-path-filter-repo
> > cd test-path-filter-repo
> > git init
> > mkdir -p src/d1
> > touch src/d1/file1
> > git add *
> > git commit -m "file1"
> > git branch b1
> > touch src/d1/file2
> > git add *
> > git commit -m "file2"
> > git checkout b1
> > touch src/d1/file3
> > git add *
> > git commit -m "file3"
> > git checkout master
> > git merge b1
> > ```
> > 
> > I used the above commands to create the test repository.
> > In this test repository, the jgit result of git log - <path> is wrong.
> > 
> > $ jgit log -- src/d1
> > commit 88c7262d9ea93b4f23b6970580908f99c09f10da
> > Author: kylezhao <kylezhao@tencent.com>
> > Date:   Fri Nov 12 14:56:54 2021 +0800
> > 
> >     Merge branch 'b1'
> > 
> > commit 8af1b91e261dcb5b01f4c6efcd1435b661dc0e2e
> > Author: kylezhao <kylezhao@tencent.com>
> > Date:   Fri Nov 12 14:56:54 2021 +0800
> > 
> >     file2
> > 
> > commit 9a83592dd073777b7e813b5dbe89831df6c1ee45
> > Author: kylezhao <kylezhao@tencent.com>
> > Date:   Fri Nov 12 14:56:54 2021 +0800
> > 
> >     file3
> > 
> > 
> > As we can see, The commit which commit message is "file1" is missing!
> > I then tested with cgit and found that the cgit result was correct.
> 
> I can't reproduce this using jgit stable-5.13 (35713588f):
> 
> $ jgit log

May be you miss the following parameters ("-- src/d1")?
$ jgit log -- src/d1

> commit 88c7262d9ea93b4f23b6970580908f99c09f10da
> Author: kylezhao <kylezhao@tencent.com>
> Date:   Fri Nov 12 14:56:54 2021 +0800
> 
>     Merge branch 'b1'
> 
> commit 8af1b91e261dcb5b01f4c6efcd1435b661dc0e2e
> Author: kylezhao <kylezhao@tencent.com>
> Date:   Fri Nov 12 14:56:54 2021 +0800
> 
>     file2
> 
> commit 9a83592dd073777b7e813b5dbe89831df6c1ee45
> Author: kylezhao <kylezhao@tencent.com>
> Date:   Fri Nov 12 14:56:54 2021 +0800
> 
>     file3
> 
> commit 5bf044d5d96704475474a5e5c20898a636837c51
> Author: kylezhao <kylezhao@tencent.com>
> Date:   Fri Nov 12 14:56:54 2021 +0800
> 
>     file1
Comment 5 Kyle Zhao CLA 2021-12-15 02:31:39 EST
I just downloaded the latest version of jgit self-contained command line[1], then reproduced the problem.

$ ./org.eclipse.jgit.pgm-6.0.0.202111291000-r.sh log -- src/d1
commit 88c7262d9ea93b4f23b6970580908f99c09f10da
Author: kylezhao <kylezhao@tencent.com>
Date:   Fri Nov 12 14:56:54 2021 +0800

    Merge branch 'b1'

commit 8af1b91e261dcb5b01f4c6efcd1435b661dc0e2e
Author: kylezhao <kylezhao@tencent.com>
Date:   Fri Nov 12 14:56:54 2021 +0800

    file2

commit 9a83592dd073777b7e813b5dbe89831df6c1ee45
Author: kylezhao <kylezhao@tencent.com>
Date:   Fri Nov 12 14:56:54 2021 +0800

    file3

===============================================================
And here were the results of cgit:

$ git log -- src/d1
commit 88c7262d9ea93b4f23b6970580908f99c09f10da (HEAD -> master)
Merge: 8af1b91 9a83592
Author: kylezhao <kylezhao@tencent.com>
Date:   Fri Nov 12 14:56:54 2021 +0800

    Merge branch 'b1'

commit 8af1b91e261dcb5b01f4c6efcd1435b661dc0e2e
Author: kylezhao <kylezhao@tencent.com>
Date:   Fri Nov 12 14:56:54 2021 +0800

    file2

commit 9a83592dd073777b7e813b5dbe89831df6c1ee45 (b1)
Author: kylezhao <kylezhao@tencent.com>
Date:   Fri Nov 12 14:56:54 2021 +0800

    file3

commit 5bf044d5d96704475474a5e5c20898a636837c51
Author: kylezhao <kylezhao@tencent.com>
Date:   Fri Nov 12 14:56:54 2021 +0800

    file1

[1] https://download.eclipse.org/jgit/site/6.0.0.202111291000-r/

Regards,
Kyle
Comment 6 Eclipse Genie CLA 2021-12-16 18:29:19 EST
New Gerrit change created: https://git.eclipse.org/r/c/jgit/jgit/+/188938
Comment 7 Matthias Sohn CLA 2021-12-16 18:33:35 EST
(In reply to Kyle Zhao from comment #4)
> (In reply to Matthias Sohn from comment #3)
> > (In reply to Kyle Zhao from comment #0)
> > > Created attachment 287497 [details]
> > > the test repo
> > > 
> > > ```
> > > mkdir test-path-filter-repo
> > > cd test-path-filter-repo
> > > git init
> > > mkdir -p src/d1
> > > touch src/d1/file1
> > > git add *
> > > git commit -m "file1"
> > > git branch b1
> > > touch src/d1/file2
> > > git add *
> > > git commit -m "file2"
> > > git checkout b1
> > > touch src/d1/file3
> > > git add *
> > > git commit -m "file3"
> > > git checkout master
> > > git merge b1
> > > ```
> > > 
> > > I used the above commands to create the test repository.
> > > In this test repository, the jgit result of git log - <path> is wrong.
> > > 
> > > $ jgit log -- src/d1
> > > commit 88c7262d9ea93b4f23b6970580908f99c09f10da
> > > Author: kylezhao <kylezhao@tencent.com>
> > > Date:   Fri Nov 12 14:56:54 2021 +0800
> > > 
> > >     Merge branch 'b1'
> > > 
> > > commit 8af1b91e261dcb5b01f4c6efcd1435b661dc0e2e
> > > Author: kylezhao <kylezhao@tencent.com>
> > > Date:   Fri Nov 12 14:56:54 2021 +0800
> > > 
> > >     file2
> > > 
> > > commit 9a83592dd073777b7e813b5dbe89831df6c1ee45
> > > Author: kylezhao <kylezhao@tencent.com>
> > > Date:   Fri Nov 12 14:56:54 2021 +0800
> > > 
> > >     file3
> > > 
> > > 
> > > As we can see, The commit which commit message is "file1" is missing!
> > > I then tested with cgit and found that the cgit result was correct.
> > 
> > I can't reproduce this using jgit stable-5.13 (35713588f):
> > 
> > $ jgit log
> 
> May be you miss the following parameters ("-- src/d1")?
> $ jgit log -- src/d1

yes, I missed this

thanks for the fix, moved it to stable-5.13
Comment 9 Kyle Zhao CLA 2021-12-19 21:09:51 EST
> yes, I missed this
> 
> thanks for the fix, moved it to stable-5.13

Got it. Thanks for your review.