2005-06-14 00:09:34 +02:00
|
|
|
#!/bin/sh
|
2005-08-23 22:18:00 +02:00
|
|
|
#
|
|
|
|
# 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'"}
|
|
|
|
|
2005-11-28 08:33:54 +01:00
|
|
|
die () {
|
|
|
|
echo >&2 "$*"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2005-09-23 09:53:02 +02:00
|
|
|
# I often say 'git diff --cached -p' and get scolded by git-diff-files, but
|
|
|
|
# obviously I mean 'git diff --cached -p HEAD' in that case.
|
|
|
|
case "$rev" in
|
|
|
|
'')
|
|
|
|
case " $flags " in
|
|
|
|
*" '--cached' "*)
|
|
|
|
rev='HEAD '
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
esac
|
|
|
|
|
2005-08-23 22:18:00 +02:00
|
|
|
case "$rev" in
|
|
|
|
?*' '?*' '?*)
|
2005-09-23 09:53:02 +02:00
|
|
|
echo >&2 "I don't understand"
|
|
|
|
exit 1
|
2005-08-23 22:18:00 +02:00
|
|
|
;;
|
|
|
|
?*' '^?*)
|
|
|
|
begin=$(expr "$rev" : '.*^.\([0-9a-f]*\).*') &&
|
|
|
|
end=$(expr "$rev" : '.\([0-9a-f]*\). .*') || exit
|
2005-10-18 09:16:45 +02:00
|
|
|
cmd="git-diff-tree $flags $begin $end -- $files"
|
2005-08-23 22:18:00 +02:00
|
|
|
;;
|
|
|
|
?*' '?*)
|
2005-10-18 09:16:45 +02:00
|
|
|
cmd="git-diff-tree $flags $rev -- $files"
|
2005-08-23 22:18:00 +02:00
|
|
|
;;
|
|
|
|
?*' ')
|
2005-10-18 09:16:45 +02:00
|
|
|
cmd="git-diff-index $flags $rev -- $files"
|
2005-08-23 22:18:00 +02:00
|
|
|
;;
|
|
|
|
'')
|
2005-10-18 09:16:45 +02:00
|
|
|
cmd="git-diff-files $flags -- $files"
|
2005-08-23 22:18:00 +02:00
|
|
|
;;
|
2005-06-14 00:09:34 +02:00
|
|
|
*)
|
2005-08-23 22:18:00 +02:00
|
|
|
die "I don't understand $*"
|
|
|
|
;;
|
2005-06-14 00:09:34 +02:00
|
|
|
esac
|
2005-08-23 22:18:00 +02:00
|
|
|
|
|
|
|
eval "$cmd"
|