threads / bug / 37854

Bug in log for path in case of identical commit

Subject: Bug in log for path in case of identical commit

## tl;dr

4 messages between Oct 31, 2014 and Nov 5, 2014.

replies: 3people: 3as markdown or json

Alexandre Garnier· Oct 31, 2014, 08:40 UTC · lore

When merging 2 branches with the same modifications on the both sides, depending the merge side, one branch disappear from the file history.

To be more clear, there is a script in attachment to reproduce, but
here is the result :
$ git log --graph --oneline --all --decorate --name-status
*   63c807f (HEAD, master) Merge branch 'branch' into 'master'
|\
| * 5dc8785 (branch) Change line 15 on branch
| | M   file
| * d9cd3ce Change line 25 on branch
| | M   file
* | 7220d52 Change line 15 on master
|/
|   M   file
* 7566672 Initial commit
  A     file
$ git log --graph --oneline --all --decorate --name-status -- file
* 5dc8785 (branch) Change line 15 on branch
| M     file
* d9cd3ce Change line 25 on branch
| M     file
* 7566672 Initial commit
  A     file
=> The commit 7220d52 modified the file but is not shown in file
history anymore.
The expected result would be:
* 5dc8785 (branch) Change line 15 on branch
| M     file
* d9cd3ce Change line 25 on branch
| M     file
| * 7220d52 Change line 15 on master
|/
|   M   file
* 7566672 Initial commit
  A     file

The order between the 2 commits on the branch is not important. If you do a 'cherry-pick 7220d52' or a 'merge --squash master' instead of applying the same modification for commit 5dc8785, you get the same result (cherry-picking was my initial use-case). If you do not create the commit d9cd3ce, then the file history show all commits. If you merge 'master' into 'branch', then the file history show all commits.

Am I missing something or is it really a bug? Thanks.

-- 
Alex
Junio C Hamano· Nov 3, 2014, 20:02 UTC · re: Alexandre Garnier · lore

Re: Bug in log for path in case of identical commit

Alexandre Garnier <zigarn+git@gmail.com> writes:
> When merging 2 branches with the same modifications on the both sides,
> depending the merge side, one branch disappear from the file history.

Isn't this a basic and fundamental of feature of Git called merge simplification, i.e. if two or more branches did the same thing and did not contribute to the end result, drop all but the one of them to show one simplest explanation of the history?

An option to get messier and fuller history is --full-history, if the above matches what you are seeing.

Show 46 quoted lines
>
> To be more clear, there is a script in attachment to reproduce, but
> here is the result :
> $ git log --graph --oneline --all --decorate --name-status
> *   63c807f (HEAD, master) Merge branch 'branch' into 'master'
> |\
> | * 5dc8785 (branch) Change line 15 on branch
> | | M   file
> | * d9cd3ce Change line 25 on branch
> | | M   file
> * | 7220d52 Change line 15 on master
> |/
> |   M   file
> * 7566672 Initial commit
>   A     file
>
> $ git log --graph --oneline --all --decorate --name-status -- file
> * 5dc8785 (branch) Change line 15 on branch
> | M     file
> * d9cd3ce Change line 25 on branch
> | M     file
> * 7566672 Initial commit
>   A     file
>
> => The commit 7220d52 modified the file but is not shown in file
> history anymore.
> The expected result would be:
> * 5dc8785 (branch) Change line 15 on branch
> | M     file
> * d9cd3ce Change line 25 on branch
> | M     file
> | * 7220d52 Change line 15 on master
> |/
> |   M   file
> * 7566672 Initial commit
>   A     file
>
> The order between the 2 commits on the branch is not important.
> If you do a 'cherry-pick 7220d52' or a 'merge --squash master' instead
> of applying the same modification for commit 5dc8785, you get the same
> result (cherry-picking was my initial use-case).
> If you do not create the commit d9cd3ce, then the file history show all commits.
> If you merge 'master' into 'branch', then the file history show all commits.
>
> Am I missing something or is it really a bug?
> Thanks.
Phil Hord· Nov 4, 2014, 16:21 UTC · re: Alexandre Garnier · lore

Re: Bug in log for path in case of identical commit

On Fri, Oct 31, 2014 at 4:40 AM, Alexandre Garnier <zigarn+git@gmail.com> wrote:
Show 45 quoted lines
> When merging 2 branches with the same modifications on the both sides,
> depending the merge side, one branch disappear from the file history.
>
> To be more clear, there is a script in attachment to reproduce, but
> here is the result :
> $ git log --graph --oneline --all --decorate --name-status
> *   63c807f (HEAD, master) Merge branch 'branch' into 'master'
> |\
> | * 5dc8785 (branch) Change line 15 on branch
> | | M   file
> | * d9cd3ce Change line 25 on branch
> | | M   file
> * | 7220d52 Change line 15 on master
> |/
> |   M   file
> * 7566672 Initial commit
>   A     file
>
> $ git log --graph --oneline --all --decorate --name-status -- file
> * 5dc8785 (branch) Change line 15 on branch
> | M     file
> * d9cd3ce Change line 25 on branch
> | M     file
> * 7566672 Initial commit
>   A     file
>
> => The commit 7220d52 modified the file but is not shown in file
> history anymore.
> The expected result would be:
> * 5dc8785 (branch) Change line 15 on branch
> | M     file
> * d9cd3ce Change line 25 on branch
> | M     file
> | * 7220d52 Change line 15 on master
> |/
> |   M   file
> * 7566672 Initial commit
>   A     file
>
> The order between the 2 commits on the branch is not important.
> If you do a 'cherry-pick 7220d52' or a 'merge --squash master' instead
> of applying the same modification for commit 5dc8785, you get the same
> result (cherry-picking was my initial use-case).
> If you do not create the commit d9cd3ce, then the file history show all commits.
> If you merge 'master' into 'branch', then the file history show all commits.

This last line was confusing to me. But I think you've misinterpreted the results a bit. There is no difference between "merge master into branch" and "merge branch into master" in this case. The real reason the "extra" commit is shown in the former case is that you used '--all' (include all refs as commandline arguments) and the commit which was being omitted was directly referenced by a ref, 'master'.

When I remove the "--all" from your test script, I get consistent logs for the two merges.

Maybe this has misled your other tests as well. Read the "History Simplification" section of "git help log".

Alexandre Garnier· Nov 5, 2014, 19:49 UTC · re: Phil Hord · lore

Re: Bug in log for path in case of identical commit

2014-11-04 17:21 GMT+01:00 Phil Hord <phil.hord@gmail.com>:
Show 59 quoted lines
> On Fri, Oct 31, 2014 at 4:40 AM, Alexandre Garnier <zigarn+git@gmail.com> wrote:
>> When merging 2 branches with the same modifications on the both sides,
>> depending the merge side, one branch disappear from the file history.
>>
>> To be more clear, there is a script in attachment to reproduce, but
>> here is the result :
>> $ git log --graph --oneline --all --decorate --name-status
>> *   63c807f (HEAD, master) Merge branch 'branch' into 'master'
>> |\
>> | * 5dc8785 (branch) Change line 15 on branch
>> | | M   file
>> | * d9cd3ce Change line 25 on branch
>> | | M   file
>> * | 7220d52 Change line 15 on master
>> |/
>> |   M   file
>> * 7566672 Initial commit
>>   A     file
>>
>> $ git log --graph --oneline --all --decorate --name-status -- file
>> * 5dc8785 (branch) Change line 15 on branch
>> | M     file
>> * d9cd3ce Change line 25 on branch
>> | M     file
>> * 7566672 Initial commit
>>   A     file
>>
>> => The commit 7220d52 modified the file but is not shown in file
>> history anymore.
>> The expected result would be:
>> * 5dc8785 (branch) Change line 15 on branch
>> | M     file
>> * d9cd3ce Change line 25 on branch
>> | M     file
>> | * 7220d52 Change line 15 on master
>> |/
>> |   M   file
>> * 7566672 Initial commit
>>   A     file
>>
>> The order between the 2 commits on the branch is not important.
>> If you do a 'cherry-pick 7220d52' or a 'merge --squash master' instead
>> of applying the same modification for commit 5dc8785, you get the same
>> result (cherry-picking was my initial use-case).
>> If you do not create the commit d9cd3ce, then the file history show all commits.
>> If you merge 'master' into 'branch', then the file history show all commits.
>
> This last line was confusing to me.  But I think you've misinterpreted
> the results a bit.  There is no difference between "merge master into
> branch" and "merge branch into master" in this case.  The real reason
> the "extra" commit is shown in the former case is that you used
> '--all' (include all refs as commandline arguments) and the commit
> which was being omitted was directly referenced by a ref, 'master'.
>
> When I remove the "--all" from your test script, I get consistent logs
> for the two merges.
>
> Maybe this has misled your other tests as well.  Read the "History
> Simplification" section of "git help log".

Thanks for pointing me out the 'history simplification' [1]. Didn't know about this and missed it in the large help of 'git log'. I will now use the '--full-history' option more often as it has more sense to me (but it's not available in EGit: bug #341028) [2])

[1] http://git-scm.com/docs/git-log#_history_simplification [2] https://bugs.eclipse.org/bugs/show_bug.cgi?id=341028

-- 
Alex

← back to recent threads