{"thread":{"id":"19394","subject":"Running vimdiff in read-only mode with git-difftool?","startedAt":"2009-05-18T05:01:02Z","lastAt":"2009-05-18T06:06:02Z","messageCount":4,"participants":["Nick Welch","David Aguilar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"114151","messageId":"9e00fd550905172201n6c95dc1bia48c9ac25d8ec98f@mail.gmail.com","threadId":"19394","inReplyTo":null,"subject":"Running vimdiff in read-only mode with git-difftool?","fromName":"Nick Welch","fromEmail":"nick@incise.org","sentAt":"2009-05-18T05:01:02Z","receivedAt":"2009-05-18T05:01:02Z","isPatch":false,"sender":{"key":"nick@incise.org","avatar":null},"body":"I'm running:\n\ngit difftool -y --tool=vimdiff -U99999 --patience\n\nand I have the following in ~/.gitconfig:\n\n[difftool \"vimdiff\"]\n    cmd = \"vimdiff -R\"\n\nBut vimdiff is still run in read/write mode.  In the output of ps, I see:\n\nvim -d -c wincmd l /tmp/.diff_bP2Tjf <original file>\n\nThere should be an -R in there, but there's not.  And if I'm trying to\nedit <original file> in another instance of vim, I get the annoying \"a swap\nfile exists, what should I do?\" message, which is my main motivation in\ntrying to use read-only mode.\n\nAccording to the git-difftool manpage, what I'm trying to do should work:\n\n    Instead of running one of the known diff tools, git-difftool can be\n    customized to run an alternative program by specifying the command line to\n    invoke in a configuration variable difftool.<tool>.cmd.\n\nI've also tried specifying the full path to vim diff, like this:\n\n[difftool \"vimdiff\"]\n    cmd = \"/usr/bin/vimdiff -R\"\n\nand it didn't work either.\n\nAny ideas?\n"},{"id":"114152","messageId":"20090518054224.GA32259@gmail.com","threadId":"19394","inReplyTo":"9e00fd550905172201n6c95dc1bia48c9ac25d8ec98f@mail.gmail.com","subject":"Re: Running vimdiff in read-only mode with git-difftool?","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-05-18T05:42:25Z","receivedAt":"2009-05-18T05:42:25Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Sun, May 17, 2009 at 10:01:02PM -0700, Nick Welch wrote:\n> \n> According to the git-difftool manpage, what I'm trying to do\n> should work:\n> \n>   Instead of running one of the known diff tools,\n>   git-difftool can be customized to run an alternative\n>   program by specifying the command line to invoke in a\n>   configuration variable difftool.<tool>.cmd.\n\n\nCustom difftool.<tool>.cmd settings only work for custom\n(i.e. alternative/non-built-in) tools.\n\nIf you rename that to something like \"myvimdiff\"\n(or anything != \"vimdiff\") then it'll work as expected.\n\nI wouldn't be opposed to a patch making\n{diff,merge}tool.<tool>.cmd work for built-in tools as\nwell as long as it had a testcase and didn't end up\nmaking the code unnecessarily complex.\n\n-- \n\n\tDavid\n"},{"id":"114153","messageId":"20090518055113.GB32259@gmail.com","threadId":"19394","inReplyTo":"9e00fd550905172201n6c95dc1bia48c9ac25d8ec98f@mail.gmail.com","subject":"Re: Running vimdiff in read-only mode with git-difftool?","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-05-18T05:51:14Z","receivedAt":"2009-05-18T05:51:14Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Sun, May 17, 2009 at 10:01:02PM -0700, Nick Welch wrote:\n> I'm running:\n> \n> git difftool -y --tool=vimdiff -U99999 --patience\n> \n> and I have the following in ~/.gitconfig:\n> \n> [difftool \"vimdiff\"]\n>     cmd = \"vimdiff -R\"\n\nI forgot to mention a couple of things.\n\n\nIf you do change that to e.g. \"myvimdiff\" you'll need\nthe $LOCAL and $REMOTE params as well; probably something\nlike:\n\n[difftool \"myvimdiff\"]\n\tcmd = vim -R -d -c wincmd l \\\"$LOCAL\\\" \\\"$REMOTE\\\"\n\n\n$ git difftool -y -t myvimdiff\n\n\nSecondly, git-difftool receives both the pre and post-image\nand doesn't actually receive the output of git-diff, so passing\n--patience unfortunately won't do what you're expecting it to\ndo.  Piping the output of git-diff to something like kompare(?)\nis probably the only way to get the nice --patience result.\n\nIt'd be nice if all diff/merge tools supported the patience\ndiff algorithm but that's not the case right now.\n\n-- \n\n\tDavid\n"},{"id":"114154","messageId":"9e00fd550905172306w2cc7ab88l82bce0799016fec1@mail.gmail.com","threadId":"19394","inReplyTo":"20090518055113.GB32259@gmail.com","subject":"Re: Running vimdiff in read-only mode with git-difftool?","fromName":"Nick Welch","fromEmail":"nick@incise.org","sentAt":"2009-05-18T06:06:02Z","receivedAt":"2009-05-18T06:06:02Z","isPatch":false,"sender":{"key":"nick@incise.org","avatar":null},"body":"As soon as I got your first reply, I started digging and managed to\nfigure out the $LOCAL and $REMOTE part.\n\nAnother interesting issue is that vim doesn't syntax-highlight the temp\nfile, because the file extension hasn't been carried over to the temp\nfile's filename.  I might see if I can figure out how to hack git to\ndo that.\n\nThanks for the help.\n\nNick\n\n\nOn Sun, May 17, 2009 at 10:51 PM, David Aguilar <davvid@gmail.com> wrote:\n> On Sun, May 17, 2009 at 10:01:02PM -0700, Nick Welch wrote:\n>> I'm running:\n>>\n>> git difftool -y --tool=vimdiff -U99999 --patience\n>>\n>> and I have the following in ~/.gitconfig:\n>>\n>> [difftool \"vimdiff\"]\n>>     cmd = \"vimdiff -R\"\n>\n> I forgot to mention a couple of things.\n>\n>\n> If you do change that to e.g. \"myvimdiff\" you'll need\n> the $LOCAL and $REMOTE params as well; probably something\n> like:\n>\n> [difftool \"myvimdiff\"]\n>        cmd = vim -R -d -c wincmd l \\\"$LOCAL\\\" \\\"$REMOTE\\\"\n>\n>\n> $ git difftool -y -t myvimdiff\n>\n>\n> Secondly, git-difftool receives both the pre and post-image\n> and doesn't actually receive the output of git-diff, so passing\n> --patience unfortunately won't do what you're expecting it to\n> do.  Piping the output of git-diff to something like kompare(?)\n> is probably the only way to get the nice --patience result.\n>\n> It'd be nice if all diff/merge tools supported the patience\n> diff algorithm but that's not the case right now.\n>\n> --\n>\n>        David\n>\n>\n>\n"}]}