Why does git merge have so much trouble with Fedora package branches?

Kevin Kofler kevin.kofler at chello.at
Fri Nov 11 03:06:28 UTC 2011

Adam Williamson wrote:
> Take the current state of gnome-power-manager. Master is at:
> commit dfd0f074a7d41d355da28180eae1bda5dc2bba66
> Author: Richard Hughes <richard at hughsie.com>
> Date:   Mon Sep 26 16:58:28 2011 +0100
> New upstream version.
> f16 is at:
> commit b0b31219d2cfdffa815659a8aad78509b65c412a
> Author: Richard Hughes <richard at hughsie.com>
> Date:   Mon Oct 17 11:34:50 2011 +0100
> New upstream version.
> which is just a single commit ahead of the master branch.

What you need to do in this case is:
1. Identify the commit in f16 which made it contain the same contents as 
master. (This is the magic ingredient in my recipe. If that state does not 
exist, it can sometimes be produced by judicious use of cherry-pick or 
revert.) In this case, this would have been commit 
2. Switch the current branch to master.
3. git merge d13e25653fec0bb1e09c99badbecc84688b28cd8 (git will recognize 
that the contents are identical and produce a trivial merge. No conflicts.)
4. git merge f16 (Now git will see from the history that only commit 
b0b31219d2cfdffa815659a8aad78509b65c412a remains to be merged and merge 
that. Again, no conflicts to deal with.)
5. Push your changes.

I use this trick very frequently and I'm surprised that so many people here 
seem not to have figured it out yet (judging from the many complicated 
suggestions of how to do this). I discovered it more or less by accident, 
seeing how merges just worked if the trees were containing identical 
contents with different history, but not when they were containing different 
contents with different history. So I tried using the hash with identical 
contents as the "branch" to merge and, hey, it worked! And now it sounds 
obvious and straightforward to me.

Of course, I blame maintainers (or scripts! Rel-eng's release bumping script 
is a big offender there) for committing the same thing to different branches 
as different commit hashes instead of using merge in the first placeā€¦

        Kevin Kofler

More information about the devel mailing list