{"thread":{"id":"13859","subject":"Unfathomable merge conflict","startedAt":"2008-06-08T07:57:16Z","lastAt":"2008-06-08T09:48:43Z","messageCount":2,"participants":["Vegard Nossum","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"79098","messageId":"19f34abd0806080057i7ddaff3exbf410879c5b7d031@mail.gmail.com","threadId":"13859","inReplyTo":null,"subject":"Unfathomable merge conflict","fromName":"Vegard Nossum","fromEmail":"vegard.nossum@gmail.com","sentAt":"2008-06-08T07:57:16Z","receivedAt":"2008-06-08T07:57:16Z","isPatch":false,"sender":{"key":"vegard.nossum@gmail.com","avatar":null},"body":"Hi,\n\nI want to do a kind of manual rebase where I check out an older\nversion of a branch and simply re-apply a selection of the commits\nfollowing this point in history.\n\nSo in this specific case, I want to check out v2.6.25 of linux-2.6.git\nand re-apply all the changes that were made to the file\nnet/mac80211/rc80211_pid_algo.c between v2.6.25 and v2.6.26-rc4.\n\nIn order to determine which commits I need, I used the following command:\n\n$ git log --follow v2.6.25..v2.6.26-rc4 net/mac80211/rc80211_pid_algo.c\n\nThe last entry on the screen is this:\n\ncommit 8318d78a44d49ac1edf2bdec7299de3617c4232e\nAuthor: Johannes Berg <johannes@sipsolutions.net>\nDate:   Thu Jan 24 19:38:38 2008 +0100\n\n    cfg80211 API for channels/bitrates, mac80211 and driver conversion\n\nso I checkout v2.6.25 and try to cherry-pick it. But it fails with a conflict:\n\nCONFLICT (content): Merge conflict in net/mac80211/rc80211_pid_algo.c\n\nSo I wonder: How can this happen? This should be the first change\nsince v2.6.25 that touches the file, yet it fails with a conflict in\nthe very same file. Where does the conflict come from?\n\nI have tried both --date-order and --topo-order for git-log, and also\nused the symmetric difference (...) in addition to the range format\n(..), but still this is displayed the first commit (in chronological\norder) that should be applied.\n\nThanks in advance for any explanations or tips.\n\n\nVegard\n\n-- \n\"The animistic metaphor of the bug that maliciously sneaked in while\nthe programmer was not looking is intellectually dishonest as it\ndisguises that the error is the programmer's own creation.\"\n\t-- E. W. Dijkstra, EWD1036\n"},{"id":"79101","messageId":"7v63skl0jo.fsf@gitster.siamese.dyndns.org","threadId":"13859","inReplyTo":"19f34abd0806080057i7ddaff3exbf410879c5b7d031@mail.gmail.com","subject":"Re: Unfathomable merge conflict","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-06-08T09:48:43Z","receivedAt":"2008-06-08T09:48:43Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Vegard Nossum\" <vegard.nossum@gmail.com> writes:\n\n> So in this specific case, I want to check out v2.6.25 of linux-2.6.git\n> and re-apply all the changes that were made to the file\n> net/mac80211/rc80211_pid_algo.c between v2.6.25 and v2.6.26-rc4.\n>\n> In order to determine which commits I need, I used the following command:\n>\n> $ git log --follow v2.6.25..v2.6.26-rc4 net/mac80211/rc80211_pid_algo.c\n\nThe commits given by that will contain ones that are based on the file\nfrom a version way older than v2.6.25, which were merged to the history\nafter v2.6.25.\n\n    $ git log -m --pretty=oneline --abbrev-commit v2.6.25..v2.6.26-rc4 -- \\\n      net/mac80211/rc80211_pid_algo.c\n    2c8dccc... mac80211: rename files\n    d0709a6... mac80211: RCU-ify STA info structure access\n    902acc7... mac80211: clean up mesh code\n    ee38585... mac80211: mesh data structures and first mesh changes\n    6f48422... mac80211: remove STA infos last_ack stuff\n    b7c50de... rc80211-pid: fix rate adjustment\n    8318d78... cfg80211 API for channels/bitrates, mac80211 and driver conversion\n\n8318d78 has diverged from the mainline way before v2.6.25, and there even\nis another patch before v2.6.25 that was applied to the mainline:\n\n    $ git log --pretty=oneline --abbrev-commit --left-right \\\n      8318d78...v2.6.25 -- net/mac80211/rc80211_pid_algo.c\n    >1d60ab0... rc80211-pid: fix rate adjustment\n    <8318d78... cfg80211 API for channels/bitrates, mac80211 and driver conversion\n\nSo it is _very_ natural that application of 8318d78 to v2.6.25 _will_\nhave conflicts that you would need to resolve.\n\nAll of the above was first merged into the mainline with 334d0945, which\nis a merge of d1643d2 into d1a4be6.\n\nAn interesting experiment is to start from 334d0945 and revert the above\ncommits (only for the path you are interested in) in the reverse order:\n\n    $ git checkout 334d0945\n    $ for c in 2c8dccc d0709a6 902acc7 ee38585 6f48422 b7c50de 8318d78\n      do git show --pretty=email -R $c -- net/mac80211/rc80211_pid_algo.c\n      done | git am\n\nThen, the difference between the result and v2.6.25 would show the fixup\nyou would need to squash into when you apply 8318d78, _if_ you trust what\nLinus did when 334d0945 was made:\n\n    $ git diff v2.6.25 -- net/mac80211/rc80211_pid_algo.c >P.diff\n\nThis looks as if 1d60ab0 is being reverted.  But the moral equivalent of\nthat patch is included as b7c50de in the history post v2.6.25, and that is\nwhy the result is Ok.\n\nIf you apply P.diff on top of v2.6.25, then apply 8318d78 (only for the\npath), and b7c50de (because it is redoing what you are reverting with\nP.diff), that would be the forwarded-ported 8318d78 for v2.6.25.\n\n    $ git checkout v2.6.25\n    $ git show --pretty=email 8318d78 -- net/mac80211/rc80211_pid_algo.c |\n      git am\n    $ git reset --hard\n    $ git apply --index P.diff\n    $ git apply --index .dotest/patch\n    $ git show b7c50de -- net/mac80211/rc80211_pid_algo.c |\n      git apply --index\n    $ git am --resolved\n\nAfter that, remainder can be picked as before, but in the forward order:\n\n    $ for c in 6f48422 ee38585 902acc7 d0709a6 2c8dccc\n      do git show --pretty=email $c -- net/mac80211/rc80211_pid_algo.c\n      done | git am\n\nand the resulting net/mac80211/rc80211_pid_algo.c will match the one from\nv2.6.26-rc4 exactly.\n"}]}