From: Jeff King <peff@peff.net>
To: Toby White <tow21@cam.ac.uk>
Cc: git@vger.kernel.org, Wincent Colaiuta <win@wincent.com>
Subject: Re: Using Filemerge.app as a git-diff viewer
Date: Wed, 21 Nov 2007 06:27:57 -0500 [thread overview]
Message-ID: <20071121112757.GA17231@sigill.intra.peff.net> (raw)
In-Reply-To: <47440912.8010800@cam.ac.uk>
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 ...
> #!/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"
write-tree? Yikes. If you want to diff against the working tree, then do
that. If you want to diff against the index, then you probably want to
git-checkout-index to a tmpdir, and diff against that.
> git-archive --format=tar $OLD | (cd $TMPDIR1; tar xf -)
Again, this could be simpler and faster by using git-checkout-index
(preceded by git-read-tree into a temp index, if you are comparing
against a tree).
-Peff
next prev parent reply other threads:[~2007-11-21 11:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-21 10:31 Using Filemerge.app as a git-diff viewer Toby White
2007-11-21 11:20 ` Jonathan del Strother
2007-11-21 11:27 ` Jeff King [this message]
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=20071121112757.GA17231@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=tow21@cam.ac.uk \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).