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
|
|
|
|
|
2005-12-16 01:47:57 +03:00
|
|
|
USAGE='[ --diff-options ] <ent>{0,2} [<path>...]'
|
|
|
|
SUBDIRECTORY_OK='Yes'
|
|
|
|
. git-sh-setup
|
|
|
|
|
2005-08-24 00:18:00 +04:00
|
|
|
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 "$@")
|
|
|
|
|
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-11-30 08:59:04 +03:00
|
|
|
# If we do not have --name-status, --name-only nor -r, default to -p.
|
|
|
|
# If we do not have -B nor -C, default to -M.
|
|
|
|
case " $flags " in
|
|
|
|
*" '--name-status' "* | *" '--name-only' "* | *" '-r' "* )
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
flags="$flags'-p' " ;;
|
|
|
|
esac
|
|
|
|
case " $flags " in
|
|
|
|
*" '-"[BCM]* | *" '--find-copies-harder' "*)
|
|
|
|
;; # something like -M50.
|
|
|
|
*)
|
|
|
|
flags="$flags'-M' " ;;
|
|
|
|
esac
|
|
|
|
|
2005-08-24 00:18:00 +04:00
|
|
|
case "$rev" in
|
|
|
|
?*' '?*' '?*)
|
2005-12-16 01:47:57 +03:00
|
|
|
usage
|
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-12-16 01:47:57 +03:00
|
|
|
usage
|
2005-08-24 00:18:00 +04:00
|
|
|
;;
|
2005-06-14 02:09:34 +04:00
|
|
|
esac
|
2005-08-24 00:18:00 +04:00
|
|
|
|
|
|
|
eval "$cmd"
|