OSDN Git Service

Add proper git-external-diff script to src/tools.
authorBruce Momjian <bruce@momjian.us>
Thu, 10 Mar 2011 23:06:13 +0000 (18:06 -0500)
committerBruce Momjian <bruce@momjian.us>
Thu, 10 Mar 2011 23:06:13 +0000 (18:06 -0500)
src/tools/git-external-diff [new file with mode: 0644]

diff --git a/src/tools/git-external-diff b/src/tools/git-external-diff
new file mode 100644 (file)
index 0000000..fdc7080
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+# Parameters:
+# $1   $2       $3       $4       $5       $6       $7
+# path old-file old-hash old-mode new-file new-hash new-mode
+# 'path' is the git-tree-relative path of the file being diff'ed
+
+old_hash="$3"
+new_hash=$(git hash-object "$5")
+
+# no change?
+[ "$old_hash" = "$new_hash" ] && exit 0
+
+[ "$DIFF_OPTS" = "" ] && DIFF_OPTS='-pcd'
+
+echo "diff --git a/$1 b/$1"
+echo "new file mode $7"
+echo "index ${old_hash:0:7}..${new_hash:0:7}"
+
+diff --label a/"$1" --label b/"$1" $DIFF_OPTS "$2" "$5"
+
+exit 0