{"thread":{"id":"28842","subject":"How do I get a squashed diff for review","startedAt":"2011-11-04T19:15:01Z","lastAt":"2011-11-06T02:33:22Z","messageCount":5,"participants":["Alexander Usov","David Aguilar","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"178851","messageId":"CAH_EFyZ_0JB0-5cw-6VEJkfJhSjbmA=3upByQ3YpmnVSvR+9Pg@mail.gmail.com","threadId":"28842","inReplyTo":null,"subject":"How do I get a squashed diff for review","fromName":"Alexander Usov","fromEmail":"a.s.usov@gmail.com","sentAt":"2011-11-04T19:15:01Z","receivedAt":"2011-11-04T19:15:01Z","isPatch":false,"sender":{"key":"a.s.usov@gmail.com","avatar":null},"body":"Hi,\n\nI'm wondering if there is an easy way to get a squashed diff of the\nchanges done on the feature branch for review.\nIn the simple cases (where feature branch is linear) there is an\nabsolutely fantastic way to get a patch for review:\ngit diff master...feature\n\nHowever if the feature branch happened to be long-lived and had\nmainline merged into it it's not going to work -- the\nresulting diff would contain changes from the merge. The way we are\ndoing things now is to merge master into it\nonce more and then diff, however this is somewhat cumbersome. Is there\neasier way to do it?\n\nAnd while we are on the topic -- is there a tool for git similar to \"bzr qdiff\"?\nIt's a simple graphical diff viewer with 2 nice features -- it shows\ncomplete diff (of multiple files) in a single window and\nhas a checkbox to switch between diff-only & full-text modes.\nI have seen difftool, but it seems to work on per-file basis, and\nsomething like \"vi <(git diff ...)\" lacks the easy way to\nswitch into full-text mode.\n\n--\nBest regards,\n  Alexander.\n"},{"id":"178891","messageId":"20111105091514.GA97860@gmail.com","threadId":"28842","inReplyTo":"CAH_EFyZ_0JB0-5cw-6VEJkfJhSjbmA=3upByQ3YpmnVSvR+9Pg@mail.gmail.com","subject":"Re: How do I get a squashed diff for review","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2011-11-05T09:15:15Z","receivedAt":"2011-11-05T09:15:15Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Fri, Nov 04, 2011 at 07:15:01PM +0000, Alexander Usov wrote:\n> Hi,\n> \n> I'm wondering if there is an easy way to get a squashed diff of the\n> changes done on the feature branch for review.\n> In the simple cases (where feature branch is linear) there is an\n> absolutely fantastic way to get a patch for review:\n> git diff master...feature\n> \n> However if the feature branch happened to be long-lived and had\n> mainline merged into it it's not going to work -- the\n> resulting diff would contain changes from the merge. The way we are\n> doing things now is to merge master into it\n> once more and then diff, however this is somewhat cumbersome. Is there\n> easier way to do it?\n\n\"git diff A...B\" is equivalent to \"git diff <merge-base A B> B\".\nThe merge-base can be found with \"git merge-base A B\"\nand is simply the common ancestor of A and B.\n\nDiffing against the merge base (which doesn't contain the merged\nwork done in master) is why you're seeing the merges in the diff.\n\nIt sounds like you want the simpler form of \"diff\" which doesn't\ndo any merge-base calculation.\n\ne.g. \"git diff A B\" and its synonymn \"git diff A..B\".\n\n\n> And while we are on the topic -- is there a tool for git similar to \"bzr qdiff\"?\n> It's a simple graphical diff viewer with 2 nice features -- it shows\n> complete diff (of multiple files) in a single window and\n> has a checkbox to switch between diff-only & full-text modes.\n> I have seen difftool, but it seems to work on per-file basis, and\n> something like \"vi <(git diff ...)\" lacks the easy way to\n> switch into full-text mode.\n\ndifftool is a wrapper around specialized diff tools, so the\nability to switch from diff to full view is tool-dependent.\n\nA contrib \"git-dirdiff\" script was posted to the list recently.\nIt builds upon diff tools that can diff directory trees.\n\nhttp://thread.gmane.org/gmane.comp.version-control.git/184528\n\nThere may be a newer version of this script, too.  Roland would\nknow for sure...\n-- \n\t\t\t\t\tDavid\n"},{"id":"178922","messageId":"CAH_EFyYUja4cKY5YM4Uqn-bnQZCnhnJCNsxGsUitL+SSqj9qxQ@mail.gmail.com","threadId":"28842","inReplyTo":"20111105091514.GA97860@gmail.com","subject":"Re: How do I get a squashed diff for review","fromName":"Alexander Usov","fromEmail":"a.s.usov@gmail.com","sentAt":"2011-11-05T17:56:58Z","receivedAt":"2011-11-05T17:56:58Z","isPatch":false,"sender":{"key":"a.s.usov@gmail.com","avatar":null},"body":"On 5 November 2011 09:15, David Aguilar <davvid@gmail.com> wrote:\n> On Fri, Nov 04, 2011 at 07:15:01PM +0000, Alexander Usov wrote:\n>> Hi,\n>>\n>> However if the feature branch happened to be long-lived and had\n>> mainline merged into it it's not going to work -- the\n>> resulting diff would contain changes from the merge. The way we are\n>> doing things now is to merge master into it\n>> once more and then diff, however this is somewhat cumbersome. Is there\n>> easier way to do it?\n>\n> \"git diff A...B\" is equivalent to \"git diff <merge-base A B> B\".\n> The merge-base can be found with \"git merge-base A B\"\n> and is simply the common ancestor of A and B.\n>\n> Diffing against the merge base (which doesn't contain the merged\n> work done in master) is why you're seeing the merges in the diff.\n>\n> It sounds like you want the simpler form of \"diff\" which doesn't\n> do any merge-base calculation.\n>\n> e.g. \"git diff A B\" and its synonymn \"git diff A..B\".\n\nJust diffing 2 revisions (or trees) won't do the trick. Let me try to explain\nwhat I'm trying to achieve.\n\nConsider the following history:\n\nmaster: A---B---D---F\n            \\    \\\nbranch:      .-C--E--G\n\nNow I want to review the changes made in the branch prior to merging it.\nWhat I essentially want to be included in the diff are changes committed in\nC & G and conflic resolution done in E (if any).\n\nThere are few ways that I know of to achieve it:\n- use \"git log -p branch ^master \" to get a sequence of patches and try to\nfeed them into combinediff tool (part of the diffutils package). This\nwill require\nsome scripting and I'm not really sure if combinediff would work with\ngit patches.\n\n- \"git diff D..branch\" would do a trick, but I'm not sure how to\ncorrectly determine\nD (if I'm to write a script). This would be the last (in topological\norder) commit which is\nreachable from both master & branch. Any suggestions on it?\n\n\n>> And while we are on the topic -- is there a tool for git similar to \"bzr qdiff\"?\n>> It's a simple graphical diff viewer with 2 nice features -- it shows\n>> complete diff (of multiple files) in a single window and\n>> has a checkbox to switch between diff-only & full-text modes.\n>> I have seen difftool, but it seems to work on per-file basis, and\n>> something like \"vi <(git diff ...)\" lacks the easy way to\n>> switch into full-text mode.\n>\n> difftool is a wrapper around specialized diff tools, so the\n> ability to switch from diff to full view is tool-dependent.\n>\n> A contrib \"git-dirdiff\" script was posted to the list recently.\n> It builds upon diff tools that can diff directory trees.\n>\n> http://thread.gmane.org/gmane.comp.version-control.git/184528\n>\n> There may be a newer version of this script, too.  Roland would\n> know for sure...\n\nThanks. Will have a more carefull look at various tools & see if I can\nfigure something out.\n\n\n-- \nBest regards,\n  Alexander.\n"},{"id":"178932","messageId":"7vobwq86tx.fsf@alter.siamese.dyndns.org","threadId":"28842","inReplyTo":"CAH_EFyYUja4cKY5YM4Uqn-bnQZCnhnJCNsxGsUitL+SSqj9qxQ@mail.gmail.com","subject":"Re: How do I get a squashed diff for review","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-11-05T23:53:14Z","receivedAt":"2011-11-05T23:53:14Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alexander Usov <a.s.usov@gmail.com> writes:\n\n> Consider the following history:\n>\n> master: A---B---D---F\n>             \\    \\\n> branch:      .-C--E--G\n>\n> ...\n> - \"git diff D..branch\" would do a trick, but I'm not sure how to\n> correctly determine\n> D (if I'm to write a script).\n\nD is the merge-base between F and G. So \"git diff $(git merge-base F G) G\"\nwould compare D and G.\n\nModern git lets you write it as \"git diff F...G\" as this is a fairly\nuseful short-hand.\n"},{"id":"178943","messageId":"CAH_EFyZgsGPtJRUTrc2Qhkj1Tr3o9SKd6KZuBM2M5AjU-n_BQA@mail.gmail.com","threadId":"28842","inReplyTo":"7vobwq86tx.fsf@alter.siamese.dyndns.org","subject":"Re: How do I get a squashed diff for review","fromName":"Alexander Usov","fromEmail":"a.s.usov@gmail.com","sentAt":"2011-11-06T02:33:22Z","receivedAt":"2011-11-06T02:33:22Z","isPatch":false,"sender":{"key":"a.s.usov@gmail.com","avatar":null},"body":"On 5 November 2011 23:53, Junio C Hamano <gitster@pobox.com> wrote:\n> Alexander Usov <a.s.usov@gmail.com> writes:\n>\n>> Consider the following history:\n>>\n>> master: A---B---D---F\n>>             \\    \\\n>> branch:      .-C--E--G\n>>\n>> ...\n>> - \"git diff D..branch\" would do a trick, but I'm not sure how to\n>> correctly determine\n>> D (if I'm to write a script).\n>\n> D is the merge-base between F and G. So \"git diff $(git merge-base F G) G\"\n> would compare D and G.\n>\n> Modern git lets you write it as \"git diff F...G\" as this is a fairly\n> useful short-hand.\n\nStrange.\nI definitely remember reading about \"git diff F...G\" and trying it out.\nAnd somehow the result wasn't really correct -- as if commit B was\nchosen to be merge-base.\nI can't reproduce it right now on a sample repo -- will try it once\nmore back in the office.\n\nThanks for help.\n\n-- \nBest regards,\n  Alexander.\n"}]}