threads / discuss / 13859

Unfathomable merge conflict

Subject: Unfathomable merge conflict

## tl;dr

2 messages between Jun 8, 2008 and Jun 8, 2008.

replies: 1people: 2as markdown or json

Vegard Nossum· Jun 8, 2008, 07:57 UTC · lore
Hi,

I want to do a kind of manual rebase where I check out an older version of a branch and simply re-apply a selection of the commits following this point in history.

So in this specific case, I want to check out v2.6.25 of linux-2.6.git and re-apply all the changes that were made to the file net/mac80211/rc80211_pid_algo.c between v2.6.25 and v2.6.26-rc4.

In order to determine which commits I need, I used the following command:
$ git log --follow v2.6.25..v2.6.26-rc4 net/mac80211/rc80211_pid_algo.c
The last entry on the screen is this:
commit 8318d78a44d49ac1edf2bdec7299de3617c4232e
Author: Johannes Berg <johannes@sipsolutions.net>
Date:   Thu Jan 24 19:38:38 2008 +0100
    cfg80211 API for channels/bitrates, mac80211 and driver conversion
so I checkout v2.6.25 and try to cherry-pick it. But it fails with a conflict:
CONFLICT (content): Merge conflict in net/mac80211/rc80211_pid_algo.c

So I wonder: How can this happen? This should be the first change since v2.6.25 that touches the file, yet it fails with a conflict in the very same file. Where does the conflict come from?

I have tried both --date-order and --topo-order for git-log, and also used the symmetric difference (...) in addition to the range format (..), but still this is displayed the first commit (in chronological order) that should be applied.

Thanks in advance for any explanations or tips.
Vegard
-- 
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
	-- E. W. Dijkstra, EWD1036
Junio C Hamano· Jun 8, 2008, 09:48 UTC · re: Vegard Nossum · lore

Re: Unfathomable merge conflict

"Vegard Nossum" <vegard.nossum@gmail.com> writes:
Show 7 quoted lines
> So in this specific case, I want to check out v2.6.25 of linux-2.6.git
> and re-apply all the changes that were made to the file
> net/mac80211/rc80211_pid_algo.c between v2.6.25 and v2.6.26-rc4.
>
> In order to determine which commits I need, I used the following command:
>
> $ git log --follow v2.6.25..v2.6.26-rc4 net/mac80211/rc80211_pid_algo.c

The commits given by that will contain ones that are based on the file from a version way older than v2.6.25, which were merged to the history after v2.6.25.

    $ git log -m --pretty=oneline --abbrev-commit v2.6.25..v2.6.26-rc4 -- \
      net/mac80211/rc80211_pid_algo.c
    2c8dccc... mac80211: rename files
    d0709a6... mac80211: RCU-ify STA info structure access
    902acc7... mac80211: clean up mesh code
    ee38585... mac80211: mesh data structures and first mesh changes
    6f48422... mac80211: remove STA infos last_ack stuff
    b7c50de... rc80211-pid: fix rate adjustment
    8318d78... cfg80211 API for channels/bitrates, mac80211 and driver conversion

8318d78 has diverged from the mainline way before v2.6.25, and there even is another patch before v2.6.25 that was applied to the mainline:

    $ git log --pretty=oneline --abbrev-commit --left-right \
      8318d78...v2.6.25 -- net/mac80211/rc80211_pid_algo.c
    >1d60ab0... rc80211-pid: fix rate adjustment
    <8318d78... cfg80211 API for channels/bitrates, mac80211 and driver conversion

So it is _very_ natural that application of 8318d78 to v2.6.25 _will_ have conflicts that you would need to resolve.

All of the above was first merged into the mainline with 334d0945, which is a merge of d1643d2 into d1a4be6.

An interesting experiment is to start from 334d0945 and revert the above commits (only for the path you are interested in) in the reverse order:

    $ git checkout 334d0945
    $ for c in 2c8dccc d0709a6 902acc7 ee38585 6f48422 b7c50de 8318d78
      do git show --pretty=email -R $c -- net/mac80211/rc80211_pid_algo.c
      done | git am

Then, the difference between the result and v2.6.25 would show the fixup you would need to squash into when you apply 8318d78, _if_ you trust what Linus did when 334d0945 was made:

    $ git diff v2.6.25 -- net/mac80211/rc80211_pid_algo.c >P.diff

This looks as if 1d60ab0 is being reverted. But the moral equivalent of that patch is included as b7c50de in the history post v2.6.25, and that is why the result is Ok.

If you apply P.diff on top of v2.6.25, then apply 8318d78 (only for the path), and b7c50de (because it is redoing what you are reverting with P.diff), that would be the forwarded-ported 8318d78 for v2.6.25.

    $ git checkout v2.6.25
    $ git show --pretty=email 8318d78 -- net/mac80211/rc80211_pid_algo.c |
      git am
    $ git reset --hard
    $ git apply --index P.diff
    $ git apply --index .dotest/patch
    $ git show b7c50de -- net/mac80211/rc80211_pid_algo.c |
      git apply --index
    $ git am --resolved
After that, remainder can be picked as before, but in the forward order:
    $ for c in 6f48422 ee38585 902acc7 d0709a6 2c8dccc
      do git show --pretty=email $c -- net/mac80211/rc80211_pid_algo.c
      done | git am

and the resulting net/mac80211/rc80211_pid_algo.c will match the one from v2.6.26-rc4 exactly.

← back to recent threads