2005-06-14 02:09:34 +04:00
|
|
|
#!/bin/sh
|
2005-08-24 00:18:00 +04: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-09-23 11:53:02 +04: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-24 00:18:00 +04:00
|
|
|
case "$rev" in
|
|
|
|
?*' '?*' '?*)
|
2005-09-23 11:53:02 +04:00
|
|
|
echo >&2 "I don't understand"
|
|
|
|
exit 1
|
2005-08-24 00:18:00 +04:00
|
|
|
;;
|
|
|
|
?*' '^?*)
|
|
|
|
begin=$(expr "$rev" : '.*^.\([0-9a-f]*\).*') &&
|
|
|
|
end=$(expr "$rev" : '.\([0-9a-f]*\). .*') || exit
|
2005-10-18 11:16:45 +04:00
|
|
|
cmd="git-diff-tree $flags $begin $end -- $files"
|
2005-08-24 00:18:00 +04:00
|
|
|
;;
|
|
|
|
?*' '?*)
|
2005-10-18 11:16:45 +04:00
|
|
|
cmd="git-diff-tree $flags $rev -- $files"
|
2005-08-24 00:18:00 +04:00
|
|
|
;;
|
|
|
|
?*' ')
|
2005-10-18 11:16:45 +04:00
|
|
|
cmd="git-diff-index $flags $rev -- $files"
|
2005-08-24 00:18:00 +04:00
|
|
|
;;
|
|
|
|
'')
|
2005-10-18 11:16:45 +04:00
|
|
|
cmd="git-diff-files $flags -- $files"
|
2005-08-24 00:18:00 +04:00
|
|
|
;;
|
2005-06-14 02:09:34 +04:00
|
|
|
*)
|
2005-08-24 00:18:00 +04:00
|
|
|
die "I don't understand $*"
|
|
|
|
;;
|
2005-06-14 02:09:34 +04:00
|
|
|
esac
|
2005-08-24 00:18:00 +04:00
|
|
|
|
|
|
|
eval "$cmd"
|