Skip to content

Instantly share code, notes, and snippets.

@atnan
Created April 1, 2009 06:59

Revisions

  1. atnan revised this gist Apr 1, 2009. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git-opendiff
    Original file line number Diff line number Diff line change
    @@ -5,8 +5,8 @@
    #
    # http://kerneltrap.org/mailarchive/git/2007/11/21/435536
    #
    # Superficial changes have been made to allow the script to be run on Leopard.
    # His instructions follow:
    # 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
  2. atnan created this gist Apr 1, 2009.
    39 changes: 39 additions & 0 deletions git-opendiff
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    #!/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 have been made to allow the script to be run on Leopard.
    # His 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