{"thread":{"id":"13666","subject":"git and appending merge commits","startedAt":"2008-05-26T03:35:42Z","lastAt":"2008-05-26T06:39:30Z","messageCount":4,"participants":["Adam Majer","Shawn O. Pearce","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"77738","messageId":"483A300E.6090104@zombino.com","threadId":"13666","inReplyTo":null,"subject":"git and appending merge commits","fromName":"Adam Majer","fromEmail":"adamm@zombino.com","sentAt":"2008-05-26T03:35:42Z","receivedAt":"2008-05-26T03:35:42Z","isPatch":false,"sender":{"key":"adamm@zombino.com","avatar":"https://avatars.githubusercontent.com/u/1211498?v=4"},"body":"Hi all,\n\nI've recently started using Git and it is a very nice tool. During some\nmerging, I've come upon one type of issue that seems to be a bug\nsomewhere. To reproduce,\n\n\n  1. branch master\n  2. branch upstream\n  3. add new version to upstream\n  4. merge it to master\n  5. append master merge changeset\n\n#5 results in \"messsed up\" diffs\n\nFor an example of such a mess up please see,\n\nhttp://git.debian.org/?p=collab-maint/mrtg.git;a=commitdiff;h=a8bc78ffd6d51ab09a791fa97e25f57b60eecd06\n\nIt appears that the tool generates a patch to a patch and displays that\ninstead of the appended merge diff which is what I would have expected..\n\nIs current output by design?\n\n- Adam\n\nPS. I should have probably used a new commit to do that changelog\naddition instead of appending the merge!\n"},{"id":"77741","messageId":"20080526045136.GC30245@spearce.org","threadId":"13666","inReplyTo":"483A300E.6090104@zombino.com","subject":"Re: git and appending merge commits","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-05-26T04:51:36Z","receivedAt":"2008-05-26T04:51:36Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Adam Majer <adamm@zombino.com> wrote:\n...\n>   5. append master merge changeset\n> \n> #5 results in \"messsed up\" diffs\n> \n> For an example of such a mess up please see,\n> \n> http://git.debian.org/?p=collab-maint/mrtg.git;a=commitdiff;h=a8bc78ffd6d51ab09a791fa97e25f57b60eecd06\n> \n> It appears that the tool generates a patch to a patch and displays that\n> instead of the appended merge diff which is what I would have expected..\n> \n> Is current output by design?\n\nYes, it is by design.  This is a feature of Git that very few\n(if any) other systems have.\n\nWhat you are seeing here is a combined diff.  It is a diff of the\nfinal output of the merge against its two parents (the two branches\nthat were merged together).  Places where both a \"++\" or \"--\" prefix\na line indicate a place where the merge commit adds something that\nis not in either parent.  This is stuff that the merge author edited\nhimself/herself during the merge.\n\nIf you had not amended the merge, you would have seen a less\ninteresting diff here, as the combined diff output tries to\navoid showing trivial changes.\n\n-- \nShawn.\n"},{"id":"77742","messageId":"7vej7pek3z.fsf@gitster.siamese.dyndns.org","threadId":"13666","inReplyTo":"483A300E.6090104@zombino.com","subject":"Re: git and appending merge commits","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-05-26T04:59:28Z","receivedAt":"2008-05-26T04:59:28Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Adam Majer <adamm@zombino.com> writes:\n\n> Is current output by design?\n\nYes, it is _very much_ by design and it not \"messed up\" at all.  Look at\nthe output of URL you quoted and notice that you are asking for condensed\ncombined diff (\"diff --cc\").\n\nFor a merge commit with N parents, you can define \"a diff for the\nresulting merge commit\" in various ways:\n\n * You could have a set of diffs between each parent to the merge result.\n   You can get this with \"git diff-tree -p -m $commit\".\n\n * You could say the first parent is special, and define it as the diff\n   between its first parent and the merge result.  You can get this by\n   asking \"git diff $commit^1 $commit\".\n\n * You can say what non-trivial changes the merge itself did.  This is the\n   combined merge and what \"git show $commit\" (and \"git log -p\") gives.\n\nDepending on what you want, you can ask these various forms of diffs.\n\nWhen you are reviewing the changes series of commits introduced to the\nhistory (iow, \"git log -p\"), a single diff between parent and the merge\nresult is not so interesting, primarily because each individual change\nfrom commits on each side branch is (or should be) much easier to read and\nunderstand, but if a merge needed to do something non-trivial to resolve\nconficts, you would want to know about it, and that is the reason why --cc\nformat is the default.\n\nIn a combined diff, unlike the single column to show \"+/-/ \" at the\nbeginning for one-parent diff, each parent gets one column.  And in a\ncondensed combined diff, a hunk whose result is inherited solely from one\nparent (iow, a trivial conflict resolution) is removed from the output, so\nthat only a non-trivial conflict resolution that leaves result that is\ndifferent from all parents are shown.\n"},{"id":"77747","messageId":"483A5B22.3070809@zombino.com","threadId":"13666","inReplyTo":"7vej7pek3z.fsf@gitster.siamese.dyndns.org","subject":"Re: git and appending merge commits","fromName":"Adam Majer","fromEmail":"adamm@zombino.com","sentAt":"2008-05-26T06:39:30Z","receivedAt":"2008-05-26T06:39:30Z","isPatch":false,"sender":{"key":"adamm@zombino.com","avatar":"https://avatars.githubusercontent.com/u/1211498?v=4"},"body":"Junio C Hamano wrote:\n> In a combined diff, unlike the single column to show \"+/-/ \" at the\n> beginning for one-parent diff, each parent gets one column.  And in a\n> condensed combined diff, a hunk whose result is inherited solely from one\n> parent (iow, a trivial conflict resolution) is removed from the output, so\n> that only a non-trivial conflict resolution that leaves result that is\n> different from all parents are shown.\n\nThank you Junio and Shawn for the very clear explanation! Now it makes\nvery good sense why the patch looks so \"weird\" :) For cases where both\nbranches touch the same file and there is a conflict, this would be very\nuseful indeed.\n\nCheers,\nAdam\n"}]}