{"thread":{"id":"39584","subject":"\"git difftool\" is not working as expected during MERGING","startedAt":"2015-06-10T13:12:21Z","lastAt":"2015-06-11T09:22:06Z","messageCount":2,"participants":["Bossert, Andre","David Aguilar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"263463","messageId":"CALzBCsGSJJZhWRoSVW6-tb+grxnFTOWSQ8kQFmwk05sC-30Q6w@mail.gmail.com","threadId":"39584","inReplyTo":null,"subject":"\"git difftool\" is not working as expected during MERGING","fromName":"Bossert, Andre","fromEmail":"anb0s@anbos.de","sentAt":"2015-06-10T13:12:21Z","receivedAt":"2015-06-10T13:12:21Z","isPatch":false,"sender":{"key":"anb0s@anbos.de","avatar":null},"body":"Hello,\n\ni've tested \"git difftool\" with -t --ext-cmd and other options to see\nmy diff with external tools, but it always show internal text-diff in\nconsole. The same tests with \"git mergetool\" working as expected. I've\ncompared (nanually reviewed) git-mergetool.sh with git-difftool.pl and\nsee that difftool is mixed / shared implementation with normal \"git\ndiff\" command. So during MERGING state there is no possibility to call\nexternal difftool with this command. Any ideas why this was\nimplemented this way?\n\n-- \nRegards\nAndre (anb0s)\neMail: anb0s@anbos.de\n"},{"id":"263554","messageId":"20150611092205.GA93332@gmail.com","threadId":"39584","inReplyTo":"CALzBCsGSJJZhWRoSVW6-tb+grxnFTOWSQ8kQFmwk05sC-30Q6w@mail.gmail.com","subject":"Re: \"git difftool\" is not working as expected during MERGING","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2015-06-11T09:22:06Z","receivedAt":"2015-06-11T09:22:06Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Wed, Jun 10, 2015 at 03:12:21PM +0200, Bossert, Andre wrote:\n> Hello,\n> \n> i've tested \"git difftool\" with -t --ext-cmd and other options to see\n> my diff with external tools, but it always show internal text-diff in\n> console. The same tests with \"git mergetool\" working as expected. I've\n> compared (nanually reviewed) git-mergetool.sh with git-difftool.pl and\n> see that difftool is mixed / shared implementation with normal \"git\n> diff\" command. So during MERGING state there is no possibility to call\n> external difftool with this command. Any ideas why this was\n> implemented this way?\n> \n> -- \n> Regards\n> Andre (anb0s)\n> eMail: anb0s@anbos.de\n\nThe \"why\" behind this behavior is likely, \"historical reasons\".\n\nThe behavior you described is an unfortunate side-effect of how\nit's implemented under the hood.  As you discovered, difftool is\nbuilt upon git-diff's GIT_EXTERNAL_DIFF feature.\n\nThat feature is not invoked when the index contains multiple\nstages (i.e. when merging) and the combined diff is printed\ninstead.\n\nA logical extension to the GIT_EXTERNAL_DIFF machinery might be\nsomething like supporting a GIT_EXTERNAL_MERGE_DIFF variable to\nhandle the 3-way case.  We could then plug this edge case by\ncreating a new handler that reuses the mergetool code[1].\n\nAlternatively, we could make \"git diff\" stricter and teaach it\nto die() when doing a mergy diff and GIT_EXTERNAL_DIFF is set.\nThat might break existing setups, though, so having a new\nfeature does seem preferable over making it stricter.\n\nAs you mentioned, using \"git mergetool\" works.  That's because\nmergetool is the intended tool for that use case.  The fact that\ndifftool prints a combined diff when when your worktree is in\nthe middle of a conflicted merge is simply an unpolished edge\ncase.\n\nIf you've already resolved all of your conflicts, and everything\nis staged, then \"git difftool --staged\" will work too.\n\nLet me know if you have any questions.  If you're interested in\nimplementing the idea described in [1] then I'd be happy to help\nreview and test the code, but for now you can probably just use\n\"git mergetool\".\n\ncheers,\n-- \nDavid\n"}]}