summaryrefslogtreecommitdiff
path: root/git-diff.sh
diff options
context:
space:
mode:
Diffstat (limited to 'git-diff.sh')
-rwxr-xr-xgit-diff.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/git-diff.sh b/git-diff.sh
new file mode 100755
index 0000000000..9732c8ac31
--- /dev/null
+++ b/git-diff.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Linus Torvalds
+# Copyright (c) 2005 Junio C Hamano
+
+rev=$(git-rev-parse --revs-only --no-flags --sq "$@") || exit
+flags=$(git-rev-parse --no-revs --flags --sq "$@")
+files=$(git-rev-parse --no-revs --no-flags --sq "$@")
+
+: ${flags:="'-M' '-p'"}
+
+case "$rev" in
+?*' '?*' '?*)
+ die "I don't understand"
+ ;;
+?*' '^?*)
+ begin=$(expr "$rev" : '.*^.\([0-9a-f]*\).*') &&
+ end=$(expr "$rev" : '.\([0-9a-f]*\). .*') || exit
+ cmd="git-diff-tree $flags $begin $end $files"
+ ;;
+?*' '?*)
+ cmd="git-diff-tree $flags $rev $files"
+ ;;
+?*' ')
+ cmd="git-diff-index $flags $rev $files"
+ ;;
+'')
+ cmd="git-diff-files $flags $files"
+ ;;
+*)
+ die "I don't understand $*"
+ ;;
+esac
+
+eval "$cmd"