All of lore.kernel.org
 help / color / mirror / Atom feed
From: Toby White <tow21@cam.ac.uk>
To: git@vger.kernel.org
Cc: Wincent Colaiuta <win@wincent.com>
Subject: Using Filemerge.app as a git-diff viewer
Date: Wed, 21 Nov 2007 10:31:46 +0000	[thread overview]
Message-ID: <47440912.8010800@cam.ac.uk> (raw)

Mac OS X bundles a rather nice graphical diff viewer (Filemerge.app)
with its developer tools.

While git-merge knows how to use this as a merge tool, I couldn't
find any way to easily use Filemerge as a viewer for the output
of git-diff.

(http://thread.gmane.org/gmane.comp.version-control.git/58702
discusses the problem, and recommends piping git-diff into kompare.
Filemerge unfortunately won't accept diff output on stdin)

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.

It's not very nice, but in case anyone else wants this:

#!/bin/sh
#
# Filemerge.app must not already be open before running
# this script, or opendiff below will return immediately,
# and the TMPDIRs deleted before it gets the chance to read
# them.

if test $# = 0; then
   OLD=`git-write-tree`
elif test "$1" = --cached; then
   OLD=HEAD
   NEW=`git-write-tree`
   shift
fi
if test $# -gt 0; then
   OLD="$1"; shift
fi
test $# -gt 0 && test -z "$CACHED" && NEW="$1"

TMPDIR1=`mktemp -d`
git-archive --format=tar $OLD | (cd $TMPDIR1; tar xf -)
if test -z "$NEW"; then
   TMPDIR2=$(git rev-parse --show-cdup)
   test -z "$cdup" && TMPDIR2=.
else
   TMPDIR2=`mktemp -d`
   git-archive --format=tar $NEW | (cd $TMPDIR2; tar xf -)
fi

opendiff $TMPDIR1 $TMPDIR2 | cat
rm -rf $TMPDIR1
test ! -z "$NEW" && rm -rf $TMPDIR2

-- 
Dr. Toby O. H. White
Dept. Earth Sciences,
Downing Street,
Cambridge CB2 3EQ
United Kingdom

Tel: +44 1223 333464
Fax: +44 1223 333450
Web: http://uszla.me.uk

             reply	other threads:[~2007-11-21 11:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-21 10:31 Toby White [this message]
2007-11-21 11:20 ` Using Filemerge.app as a git-diff viewer Jonathan del Strother
2007-11-21 11:27 ` Jeff King
2007-11-21 12:59   ` Wincent Colaiuta
2007-11-21 13:04     ` Jeff King
2007-11-21 13:58     ` Jakub Narebski
2007-11-21 13:10   ` Toby White
2007-11-21 13:28     ` Wincent Colaiuta
2007-11-21 14:36     ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47440912.8010800@cam.ac.uk \
    --to=tow21@cam.ac.uk \
    --cc=git@vger.kernel.org \
    --cc=win@wincent.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.