{"thread":{"id":"12975","subject":"merge conflict diff","startedAt":"2008-04-03T14:13:04Z","lastAt":"2008-04-03T16:48:22Z","messageCount":4,"participants":["Jeremy Ramer","Jeff King","Matthieu Moy"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"73605","messageId":"b9fd99020804030713n3c1a2602t847e8a132f8ccd06@mail.gmail.com","threadId":"12975","inReplyTo":null,"subject":"merge conflict diff","fromName":"Jeremy Ramer","fromEmail":"jdramer@gmail.com","sentAt":"2008-04-03T14:13:04Z","receivedAt":"2008-04-03T14:13:04Z","isPatch":false,"sender":{"key":"jdramer@gmail.com","avatar":null},"body":"Hi,\nI am trying to figure out how to quickly diff two source files that\nled to a merge conflict.  When a conflict occurs the command\n# git diff\nperforms a diff -cc, but I would like to compare the files before any\nmerging takes place so I can decide if I should just take all the\nchanges from one of the sources.\n i.e. take the changes from the merging branch:\n# git checkout-index -f -u --stage=3 foo\n# git add foo\n\nSo far I am thinking of\n# git checkout-index --stage=2 --temp foo\n# git checkout-index --stage=3 --temp foo\n# git diff .merge_x1 .merge_x2\n\nAre there any built-in ways to accomplish this? I'd like to be able to\nbuild a script that can quickly start the diff based on the file name\nI provide.\n\nThanks!\nJeremy\n"},{"id":"73606","messageId":"20080403142649.GA16699@coredump.intra.peff.net","threadId":"12975","inReplyTo":"b9fd99020804030713n3c1a2602t847e8a132f8ccd06@mail.gmail.com","subject":"Re: merge conflict diff","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-04-03T14:26:49Z","receivedAt":"2008-04-03T14:26:49Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Apr 03, 2008 at 08:13:04AM -0600, Jeremy Ramer wrote:\n\n> I am trying to figure out how to quickly diff two source files that\n> led to a merge conflict.  When a conflict occurs the command\n> [...]\n> So far I am thinking of\n> # git checkout-index --stage=2 --temp foo\n> # git checkout-index --stage=3 --temp foo\n> # git diff .merge_x1 .merge_x2\n\nThe special ref syntax :<n>:file refers to the blob in stage <n> of the\nindex. So you can see them with:\n\n  git show :2:foo\n  git show :3:foo\n\nOr diff them with:\n\n  git diff :2:foo :3:foo\n\nYou may also want to look at the git-mergetool script, which uses both\nversions (along with the ancestor) as the arguments to many common merge\nresolution programs.\n\n-Peff\n"},{"id":"73609","messageId":"b9fd99020804030758gced1981s624e50041904665c@mail.gmail.com","threadId":"12975","inReplyTo":"20080403142649.GA16699@coredump.intra.peff.net","subject":"Re: merge conflict diff","fromName":"Jeremy Ramer","fromEmail":"jdramer@gmail.com","sentAt":"2008-04-03T14:58:35Z","receivedAt":"2008-04-03T14:58:35Z","isPatch":false,"sender":{"key":"jdramer@gmail.com","avatar":null},"body":"On Thu, Apr 3, 2008 at 8:26 AM, Jeff King <peff@peff.net> wrote:\n> On Thu, Apr 03, 2008 at 08:13:04AM -0600, Jeremy Ramer wrote:\n>\n>  > I am trying to figure out how to quickly diff two source files that\n>  > led to a merge conflict.  When a conflict occurs the command\n>  > [...]\n>\n> > So far I am thinking of\n>  > # git checkout-index --stage=2 --temp foo\n>  > # git checkout-index --stage=3 --temp foo\n>  > # git diff .merge_x1 .merge_x2\n>\n>  The special ref syntax :<n>:file refers to the blob in stage <n> of the\n>  index. So you can see them with:\n>\n>   git show :2:foo\n>   git show :3:foo\n>\n>  Or diff them with:\n>\n>   git diff :2:foo :3:foo\n\nPerfect! I was not aware of that syntax. That solves the question I asked.\n\n>  You may also want to look at the git-mergetool script, which uses both\n>  versions (along with the ancestor) as the arguments to many common merge\n>  resolution programs.\n\nThis suggestion solves the actual problem in a much better way than I\nwas thinking.  Thanks for the help!\n"},{"id":"73610","messageId":"vpqk5jeubop.fsf@bauges.imag.fr","threadId":"12975","inReplyTo":"20080403142649.GA16699@coredump.intra.peff.net","subject":"Re: merge conflict diff","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2008-04-03T16:48:22Z","receivedAt":"2008-04-03T16:48:22Z","isPatch":false,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Thu, Apr 03, 2008 at 08:13:04AM -0600, Jeremy Ramer wrote:\n>\n>> I am trying to figure out how to quickly diff two source files that\n>> led to a merge conflict.  When a conflict occurs the command\n>> [...]\n>> So far I am thinking of\n>> # git checkout-index --stage=2 --temp foo\n>> # git checkout-index --stage=3 --temp foo\n>> # git diff .merge_x1 .merge_x2\n>\n> The special ref syntax :<n>:file refers to the blob in stage <n> of the\n> index. So you can see them with:\n>\n>   git show :2:foo\n>   git show :3:foo\n>\n> Or diff them with:\n>\n>   git diff :2:foo :3:foo\n\nSee also\n\ngit diff --ours\ngit diff --theirs\ngit diff --base\n\nand man git-diff-files (BTW, it's a pity not to find this in man\ngit-diff).\n\n-- \nMatthieu\n"}]}