summaryrefslogtreecommitdiff
path: root/git-diff-script
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-08-23 22:32:17 (GMT)
committerJunio C Hamano <junkio@cox.net>2005-08-23 22:32:17 (GMT)
commit58eaf287f1b25f6427b06bd72d8e555615828aeb (patch)
tree6d86eab47d70925761f5923debeaa19c348fb371 /git-diff-script
parent89305da8a230e435109cc97ed88241c158813523 (diff)
parent2a29da7c6d6103c4719c71f6cce88e853260912c (diff)
downloadgit-58eaf287f1b25f6427b06bd72d8e555615828aeb.zip
git-58eaf287f1b25f6427b06bd72d8e555615828aeb.tar.gz
git-58eaf287f1b25f6427b06bd72d8e555615828aeb.tar.bz2
Merge refs/heads/master from .
Diffstat (limited to 'git-diff-script')
-rwxr-xr-xgit-diff-script52
1 files changed, 32 insertions, 20 deletions
diff --git a/git-diff-script b/git-diff-script
index 99ff264..a285a2a 100755
--- a/git-diff-script
+++ b/git-diff-script
@@ -1,23 +1,35 @@
#!/bin/sh
-rev=($(git-rev-parse --revs-only "$@")) || exit
-flags=($(git-rev-parse --no-revs --flags "$@"))
-files=($(git-rev-parse --no-revs --no-flags "$@"))
-case "${#rev[*]}" in
-0)
- git-diff-files -M -p "$@";;
-1)
- git-diff-cache -M -p "$@";;
-2)
- case "${rev[1]}" in
- ^?*)
- begin=$(echo "${rev[1]}" | tr -d '^')
- end="${rev[0]}" ;;
- *)
- begin="${rev[0]}"
- end="${rev[1]}" ;;
- esac
- git-diff-tree -M -p $flags $begin $end $files;;
+#
+# 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-cache $flags $rev $files"
+ ;;
+'')
+ cmd="git-diff-files $flags $files"
+ ;;
*)
- echo "I don't understand"
- exit 1;;
+ die "I don't understand $*"
+ ;;
esac
+
+eval "$cmd"