Created
April 1, 2009 06:59
-
-
Save atnan/88581 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# This script was written by Toby White under an unknown license, and published | |
# on the Git mailing list: | |
# | |
# http://kerneltrap.org/mailarchive/git/2007/11/21/435536 | |
# | |
# Superficial changes were made by Nathan de Vries to allow the script to be | |
# run under Leopard. Tony's original instructions follow: | |
# | |
# 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 /tmp/opendiff.XXXX` | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment