Update git-diff-script.

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>
This commit is contained in:
Junio C Hamano
2005-08-23 13:18:00 -07:00
parent 90e1848113
commit 0a5a9ea433

View File

@ -1,23 +1,35 @@
#!/bin/sh #!/bin/sh
rev=($(git-rev-parse --revs-only "$@")) || exit #
flags=($(git-rev-parse --no-revs --flags "$@")) # Copyright (c) 2005 Linus Torvalds
files=($(git-rev-parse --no-revs --no-flags "$@")) # Copyright (c) 2005 Junio C Hamano
case "${#rev[*]}" in
0) rev=$(git-rev-parse --revs-only --no-flags --sq "$@") || exit
git-diff-files -M -p "$@";; flags=$(git-rev-parse --no-revs --flags --sq "$@")
1) files=$(git-rev-parse --no-revs --no-flags --sq "$@")
git-diff-cache -M -p "$@";;
2) : ${flags:="'-M' '-p'"}
case "${rev[1]}" in
^?*) case "$rev" in
begin=$(echo "${rev[1]}" | tr -d '^') ?*' '?*' '?*)
end="${rev[0]}" ;; 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"
;;
*) *)
begin="${rev[0]}" die "I don't understand $*"
end="${rev[1]}" ;; ;;
esac
git-diff-tree -M -p $flags $begin $end $files;;
*)
echo "I don't understand"
exit 1;;
esac esac
eval "$cmd"