summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 90e1848)
raw | patch | inline | side by side (parent: 90e1848)
author | Junio C Hamano <junkio@cox.net> | |
Tue, 23 Aug 2005 20:18:00 +0000 (13:18 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Tue, 23 Aug 2005 20:18:00 +0000 (13:18 -0700) |
This uses the fixed rev-parse to allow passing diff options to the
underlying diff command. For example:
$ git diff -r HEAD
shows the output in raw-diff format, and
$ git diff -p -R HEAD | git apply
generates a patch to go back from your working tree to HEAD commit
(i.e. an expensive way to say "git checkout -f HEAD").
At the same time, it accidentally removes the use of shell arrays.
Signed-off-by: Junio C Hamano <junkio@cox.net>
underlying diff command. For example:
$ git diff -r HEAD
shows the output in raw-diff format, and
$ git diff -p -R HEAD | git apply
generates a patch to go back from your working tree to HEAD commit
(i.e. an expensive way to say "git checkout -f HEAD").
At the same time, it accidentally removes the use of shell arrays.
Signed-off-by: Junio C Hamano <junkio@cox.net>
git-diff-script | patch | blob | history |
diff --git a/git-diff-script b/git-diff-script
index 99ff2640f127e36fd4351557e27e7b8a683a07ce..a285a2a4ee056fc4689c139eebe299072c91b46d 100755 (executable)
--- a/git-diff-script
+++ b/git-diff-script
#!/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"