git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Using Filemerge.app as a git-diff viewer

From
Wincent Colaiuta <win@wincent.com>
Date
Nov 21, 2007, 12:59 UTC
Message-ID
<1A9343EE-BB45-4CF8-9F17-E6A73C5F0B83@wincent.com>
In-Reply-To
<20071121112757.GA17231@sigill.intra.peff.net>
El 21/11/2007, a las 12:27, Jeff King escribió:
Show 21 quoted lines
> On Wed, Nov 21, 2007 at 10:31:46AM +0000, Toby White wrote:
>
>> So I wrote a quick script (below) which does what I need. Of all
>> the available git-diff flags, it only understands "--cached", and
>> up to two commit objects, and no paths, but that's enough for me.
>> Within those constraints, it has the same semantics as git-diff.
>
> Have you looked at the documentation for GIT_EXTERNAL_DIFF (try  
> git(7))?
> I think it is a cleaner way of doing what you want (although I think  
> you
> will get each file diffed individually, which is perhaps not what you
> want).
>
> Something like:
>
> $ cat >merge.sh <<EOF
> #!/bin/sh
> opendiff "$1" "$2"
> EOF
> $ GIT_EXTERNAL_DIFF=./merge.sh git-diff ...
A few problems with that:
- FileMerge is broken, and crashes if you pass /dev/null as a param  
(which happens for new/deleted files)
- you need to escape those $-signs
- the params you're interested in are actually $2 and $5, not $1 and  
$2, according to git(7)
- you need to handle the clean tree case (no params are passed)
- and also the 1-param case, "for unmerged paths", whatever that means
- will only work when run from the top of the tree (path parameters  
are passed in relative to that)

So here's a less-broken version of your suggestion, but it's still broken; a relatively complex wrapper is required to do this right:

$ cat >merge.sh <<EOF #!/bin/sh [ \$# -eq 7 ] && opendiff "\$2" "\$5" EOF chmod +x merge.sh GIT_EXTERNAL_DIFF=./merge.sh git-diff ...

Cheers, Wincent

Previous: Jeff KingNext: Jeff King
Message 4 of 9 in “Using Filemerge.app as a git-diff viewer”
  1. Toby WhiteNov 21, 2007
  2. Jonathan del StrotherNov 21, 2007
  3. Jeff KingNov 21, 2007
  4. Wincent ColaiutaNov 21, 2007
  5. Jeff KingNov 21, 2007
  6. Jakub NarebskiNov 21, 2007
  7. Toby WhiteNov 21, 2007
  8. Wincent ColaiutaNov 21, 2007
  9. Jeff KingNov 21, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.