{"thread":{"id":"41840","subject":"git show -m with a parent number","startedAt":"2016-03-27T20:46:02Z","lastAt":"2016-03-30T16:55:21Z","messageCount":5,"participants":["Anatoly Borodin","Jeff King","Junio C Hamano","Andreas Schwab"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"281945","messageId":"nd9gq6$412$1@ger.gmane.org","threadId":"41840","inReplyTo":null,"subject":"git show -m with a parent number","fromName":"Anatoly Borodin","fromEmail":"anatoly.borodin@gmail.com","sentAt":"2016-03-27T20:46:02Z","receivedAt":"2016-03-27T20:46:02Z","isPatch":false,"sender":{"key":"anatoly.borodin@gmail.com","avatar":"https://gravatar.com/avatar/59f11f1f45cf5ebb7bcca8da94b43cfe5f596d91c0a3e27ad0d2a861cc2bbce7?d=mp&s=160"},"body":"Hi All,\n\n\nis there a good reason for `git show -m` to not accept the number of a\nparent of a merge commit? I can run `git show --first-parent COMMIT`,\nbut need to write `git diff COMMIT^2 COMMIT` every time I want to diff\nwith the second parent!\n\n`git cherry-pick -m 2 COMMIT` works, so why can't `git log` work like\nthat?\n\n\n-- \nMit freundlichen Grüßen,\nAnatoly Borodin\n"},{"id":"281981","messageId":"20160328191608.GA22602@sigill.intra.peff.net","threadId":"41840","inReplyTo":"nd9gq6$412$1@ger.gmane.org","subject":"Re: git show -m with a parent number","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-03-28T19:16:08Z","receivedAt":"2016-03-28T19:16:08Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Mar 27, 2016 at 08:46:02PM +0000, Anatoly Borodin wrote:\n\n> is there a good reason for `git show -m` to not accept the number of a\n> parent of a merge commit? I can run `git show --first-parent COMMIT`,\n> but need to write `git diff COMMIT^2 COMMIT` every time I want to diff\n> with the second parent!\n\nI think it could, but nobody has yet found it useful enough to\nimplement.\n\nI am not sure of the workflow it would help. Personally, I use \"-m\" in\ntwo situations:\n\n  1. To puzzle out issues where \"-c\" or \"--cc\" do not show what I\n     expected.\n\n  2. With \"--first-parent\", to follow the linear history of a mainline\n     branch, showing merged topic branches as a single diff.\n\nFor the first one, showing all diffs is what I want. For the second, it\nonly makes sense to for the first parent case, as following other\nparents would zig-zag through history.\n\nBut perhaps you have some other use case in mind. In cases like these, I\nthink it is a good idea to implement the feature, and run with it for a\nwhile, seeing how it can be used. And then if it proves useful, post the\npatch to the list describing your experiences.\n\n-Peff\n"},{"id":"281982","messageId":"xmqqoa9yxuuv.fsf@gitster.mtv.corp.google.com","threadId":"41840","inReplyTo":"20160328191608.GA22602@sigill.intra.peff.net","subject":"Re: git show -m with a parent number","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-03-28T19:31:20Z","receivedAt":"2016-03-28T19:31:20Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Sun, Mar 27, 2016 at 08:46:02PM +0000, Anatoly Borodin wrote:\n>\n>> is there a good reason for `git show -m` to not accept the number of a\n>> parent of a merge commit? I can run `git show --first-parent COMMIT`,\n>> but need to write `git diff COMMIT^2 COMMIT` every time I want to diff\n>> with the second parent!\n>\n> I think it could, but nobody has yet found it useful enough to\n> implement.\n\nFor \"git show\" that does not traverse the history, there may be\noccasions where showing a diff with the second parent might make\nsense (e.g. the user merged two histories in a wrong direction in\nthe past and it is too late to rewrite).\n\nI think there are two reasons behind the current state.  Because it\ndoes not make any sense for \"git log -m 2\" to show diff with its\nsecond parent while traversing many commits, the \"git log\" codepath\nis not prepared to show diff with only nth parent.  Because \"git\nshow\" started its life merely as a thin wrapper around \"git log\",\n\"git show\" does not use such an underlying machinery to show diff\nwith only nth parent that does not exist.\n"},{"id":"282227","messageId":"ndggug$c87$1@ger.gmane.org","threadId":"41840","inReplyTo":"20160328191608.GA22602@sigill.intra.peff.net","subject":"Re: git show -m with a parent number","fromName":"Anatoly Borodin","fromEmail":"anatoly.borodin@gmail.com","sentAt":"2016-03-30T12:31:16Z","receivedAt":"2016-03-30T12:31:16Z","isPatch":false,"sender":{"key":"anatoly.borodin@gmail.com","avatar":"https://gravatar.com/avatar/59f11f1f45cf5ebb7bcca8da94b43cfe5f596d91c0a3e27ad0d2a861cc2bbce7?d=mp&s=160"},"body":"Hi!\n\nJeff King <peff@peff.net> wrote:\n> For the first one, showing all diffs is what I want. For the second, it\n> only makes sense to for the first parent case, as following other\n> parents would zig-zag through history.\n\nLucky you! :) You probably don't need to inspect 9 month old ex-svn\nbranches with sync (i.e. 'trunk'->'feature') merges\n\n*-...-*-...-*-...-*-.......-*---trunk\n \\     \\     \\     \\       /\n  *-...-*-...-*-...-*-...-*---feature\n\n(Not to forget some funny legacy inter-feature merges.)\n\nIt's not like `git diff X^2 X` is a big problem, but too much of a\ncopypaste.\n\nThe other thing that bugs me is that you can easily `git cherry-pick -m 2 X`,\nbut to see the diff that you are going to apply is not that trivial.\n\n> But perhaps you have some other use case in mind. In cases like these, I\n> think it is a good idea to implement the feature, and run with it for a\n> while, seeing how it can be used. And then if it proves useful, post the\n> patch to the list describing your experiences.\n\nI'll try. BTW, should it be like '-m[=parent]' for consistency,\nor '-m [parent]' is ok?\n\nPS Another idea:\n\n'-m parent' makes sence in a normal, 2-branch merge. But what to do in a\ncase of an octopus merge? In a normal case I can treat '-m 2' as 'the\ndiff regarding the second parent', but also as 'the changes contributed\nby the first parent (plus \"evil\")'. But with 3 and more branches '-m 3'\nmeans 'the changes from 1 and 2'. Would it be possible to get only the\ncontribution from the second or third parent in this case?\n\nYeah, I know, there is `git diff parent1...parent3` etc, but not all the\nchanges from parent3 will always get to the merge commit.\n\n-- \nMit freundlichen Grüßen,\nAnatoly Borodin\n"},{"id":"282235","messageId":"871t6rx5vq.fsf@linux-m68k.org","threadId":"41840","inReplyTo":"ndggug$c87$1@ger.gmane.org","subject":"Re: git show -m with a parent number","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2016-03-30T16:55:21Z","receivedAt":"2016-03-30T16:55:21Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Anatoly Borodin <anatoly.borodin@gmail.com> writes:\n\n> It's not like `git diff X^2 X` is a big problem, but too much of a\n> copypaste.\n\nBrace expansion helps a bit: git diff X{^2,}\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"}]}