Issue with merge commit

117 views
Skip to first unread message

mani chandel

unread,
Jul 7, 2014, 11:44:34 AM7/7/14
to repo-d...@googlegroups.com
Hi,

I am facing an issue with the merge commit.
I merged one commit into another using below commands:

$ git checkout <commit1>
$ git merge <commit2>
Now when I push this to gerrit, I see that there 2 files are modified.
Out of which 1 file has lot of duplicate code added to it.
So if I look at the diff view between base and Patchset 1 for that file, I see something like as shown below:
 
                 Base                                               Patch Set 1
-----------------------------------------------------------|--------------------------------
<<<<<<< HEAD   (350f13 commit1)       |
                                                           |  <over here there is lot of duplicate
=======                                             |   code added > (in green)
>>>>>>> BRANCH (378f8f commit2)     |
 (in red)                                                |

Here, I expect gerrit should have given a merge conflict.
But there was no merge conflict message.

Later the duplicate code was needed to be removed manually and then change was merged.
Here, I am trying to understand why gerrit did not give a merge conflict message when there was
a duplicate code.
This is actually quite important to since if merge does not
work as expected then how can we know what has been merged to the branch.

Can anyone please suggest how can I debug this situation or any pointer on how to find out what
could have caused this issue?

Thanks.
 

David Pursehouse

unread,
Jul 7, 2014, 8:19:53 PM7/7/14
to mani chandel, repo-d...@googlegroups.com
This is because the conflicts were not resolved before committing the
merge and pushing to Gerrit.

The "merge conflict" in Gerrit's UI is not related to the content of the
diff. It is shown when the commit cannot be merged into the repository
because of conflicts between the change and what is already in the
repository.
> --
> --
> To unsubscribe, email repo-discuss...@googlegroups.com
> More info at http://groups.google.com/group/repo-discuss?hl=en
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Repo and Gerrit Discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to repo-discuss...@googlegroups.com
> <mailto:repo-discuss...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

mani chandel

unread,
Jul 8, 2014, 3:35:11 AM7/8/14
to repo-d...@googlegroups.com


On Tuesday, 8 July 2014 03:19:53 UTC+3, David Pursehouse wrote:
This is because the conflicts were not resolved before committing the
merge and pushing to Gerrit.

The "merge conflict" in Gerrit's UI is not related to the content of the
diff.  It is shown when the commit cannot be merged into the repository
because of conflicts between the change and what is already in the
repository.

 Ok, I understand. So is there any way I can know before pushing if there was a conflict?
Coz when I executed git merge <commit2> I did not get any message which says that there are conflicts.



Saša Živkov

unread,
Jul 16, 2014, 11:06:53 AM7/16/14
to mani chandel, repo-d...@googlegroups.com
On Tue, Jul 8, 2014 at 9:35 AM, mani chandel <mani.c...@gmail.com> wrote:


On Tuesday, 8 July 2014 03:19:53 UTC+3, David Pursehouse wrote:
This is because the conflicts were not resolved before committing the
merge and pushing to Gerrit.

The "merge conflict" in Gerrit's UI is not related to the content of the
diff.  It is shown when the commit cannot be merged into the repository
because of conflicts between the change and what is already in the
repository.

 Ok, I understand. So is there any way I can know before pushing if there was a conflict?
If there *was* a conflict during the merge of commit1 and commit2 Git would tell you and you would
know that before pushing.
 
Coz when I executed git merge <commit2> I did not get any message which says that there are conflicts.
This is what David already explained. What you see in Gerrit's UI is NOT a conflict
between the commit1 and commit2 but between the merge(commit1, commit2) and the tip
of the target branch.
 



--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.

Saša Živkov

unread,
Jul 16, 2014, 1:30:15 PM7/16/14
to mani chandel, repo-d...@googlegroups.com
On Wed, Jul 16, 2014 at 5:06 PM, Saša Živkov <ziv...@gmail.com> wrote:



On Tue, Jul 8, 2014 at 9:35 AM, mani chandel <mani.c...@gmail.com> wrote:


On Tuesday, 8 July 2014 03:19:53 UTC+3, David Pursehouse wrote:
This is because the conflicts were not resolved before committing the
merge and pushing to Gerrit.

The "merge conflict" in Gerrit's UI is not related to the content of the
diff.  It is shown when the commit cannot be merged into the repository
because of conflicts between the change and what is already in the
repository.

 Ok, I understand. So is there any way I can know before pushing if there was a conflict?
If there *was* a conflict during the merge of commit1 and commit2 Git would tell you and you would
know that before pushing.
 
Coz when I executed git merge <commit2> I did not get any message which says that there are conflicts.
 
This is what David already explained. What you see in Gerrit's UI is NOT a conflict
between the commit1 and commit2 but between the merge(commit1, commit2) and the tip
of the target branch.

What I wrote above is nonsense :-(

So, you probably didn't resolve the conflicts before committing the merge... and the conflict markers
became part of the commit.
If this is not true and you really didn't have any conflicts on merge then I can only imagine that
in your local repository native Git auto resolved all the conflicts but then Gerrit couldn't auto-resolve
all of them and then shows the conflicts in the auto-merge version in the UI.

Edwin Kempin

unread,
Jul 16, 2014, 1:58:31 PM7/16/14
to Saša Živkov, mani chandel, repo-d...@googlegroups.com
2014-07-16 19:30 GMT+02:00 Saša Živkov <ziv...@gmail.com>:



On Wed, Jul 16, 2014 at 5:06 PM, Saša Živkov <ziv...@gmail.com> wrote:



On Tue, Jul 8, 2014 at 9:35 AM, mani chandel <mani.c...@gmail.com> wrote:


On Tuesday, 8 July 2014 03:19:53 UTC+3, David Pursehouse wrote:
This is because the conflicts were not resolved before committing the
merge and pushing to Gerrit.

The "merge conflict" in Gerrit's UI is not related to the content of the
diff.  It is shown when the commit cannot be merged into the repository
because of conflicts between the change and what is already in the
repository.

 Ok, I understand. So is there any way I can know before pushing if there was a conflict?
If there *was* a conflict during the merge of commit1 and commit2 Git would tell you and you would
know that before pushing.
 
Coz when I executed git merge <commit2> I did not get any message which says that there are conflicts.
 
This is what David already explained. What you see in Gerrit's UI is NOT a conflict
between the commit1 and commit2 but between the merge(commit1, commit2) and the tip
of the target branch.

What I wrote above is nonsense :-(

So, you probably didn't resolve the conflicts before committing the merge... and the conflict markers
became part of the commit.
If this is not true and you really didn't have any conflicts on merge then I can only imagine that
in your local repository native Git auto resolved all the conflicts but then Gerrit couldn't auto-resolve
all of them and then shows the conflicts in the auto-merge version in the UI.
Pay attention that for merge commits Gerrit shows you the version with the conflict markers as base so that you are able to review the conflict resolution (on the left side you see the conflicts and on the right side how they have been resolved).

Saša Živkov

unread,
Jul 16, 2014, 2:03:30 PM7/16/14
to Edwin Kempin, mani chandel, repo-d...@googlegroups.com
This is correct. However,  Mani claims that no conflicts were reported on the merge in the local repository.
If this is true and the auto-merge version does show conflicts then I can only assume that the native
Git was able to resolve all the conflicts automatically and Gerrit (when creating the auto-merge) version
couldn't.

mani chandel

unread,
Jul 17, 2014, 5:08:29 AM7/17/14
to repo-d...@googlegroups.com, edwin....@gmail.com
Hi Sasa,

I replicated this issue to test merge of these 2 particular commits many times
and every time I got the same result.
When I merged commit1 and commit2 
I did not get any error and got message that merge was successful (Here, I haven't pushed it to gerrit yet)
I checked the file where it was showing duplicate in gerrit diff view.
And I saw that file got all those duplicates in this step.
But there were no >>> >> <<< kind of marks showing conflicts in that file
nor were was there any conflict message when I executed git merge.
And then when I pushed to gerrit I got the result that I pasted in first post with >>><<< marks on left.
so then developer had to remove the duplicate manually from this file and upload a new patchset.
Every time I conducted this test of merging these 2 commits I got same result.

But this is weird and can cause problem if we do not get an indication of duplicates inserted
at any step :(

Thanks.

Saša Živkov

unread,
Jul 17, 2014, 5:27:11 AM7/17/14
to mani chandel, repo-d...@googlegroups.com, Edwin Kempin
If this all was done without any mistakes on your side then it looks like a bug in the native Git.
Which Git version do you use locally?
 
But there were no >>> >> <<< kind of marks showing conflicts in that file
nor were was there any conflict message when I executed git merge.
And then when I pushed to gerrit I got the result that I pasted in first post with >>><<< marks on left.
so then developer had to remove the duplicate manually from this file and upload a new patchset.
Every time I conducted this test of merging these 2 commits I got same result.

The only way we could help would be to get access to these 2 commits and then reproduce the issue.
Could you provide it to us?

mani chandel

unread,
Jul 25, 2014, 5:59:15 AM7/25/14
to repo-d...@googlegroups.com, edwin....@gmail.com, Saša Živkov
Hi Sasa,

I did some more testing with this issue.
Case 1:
1- Installed gerrit-2.8.5.
2- Pushed this merge commit to gerrit
Result: No merge conflict error on UI

Case 2:
1- Installed gerrit-2.9.
2- Pushed same merge commit to gerrit
Result: Merge Conflict error on gerrit UI (Cannot merge)

This is actually what is expected as there were duplicates introduced while creating merge commit.
Although at the time of merge git did not show any error.
But when upload to gerrit it is showing 'Cannot merge' so user can know that he needs to take an action here.
This is good. So I wanted to know if there is any change introduced in gerrit-2.9 which shows 'Cannot merge'
on UI for such changes.

Thanks.
Reply all
Reply to author
Forward
0 new messages