3 # Copyright (c) 2005 Linus Torvalds
4 # Copyright (c) 2005 Junio C Hamano
6 USAGE
='[ --diff-options ] <ent>{0,2} [<path>...]'
10 rev=$
(git-rev-parse
--revs-only --no-flags --sq "$@") ||
exit
11 flags
=$
(git-rev-parse
--no-revs --flags --sq "$@")
12 files
=$
(git-rev-parse
--no-revs --no-flags --sq "$@")
14 # I often say 'git diff --cached -p' and get scolded by git-diff-files, but
15 # obviously I mean 'git diff --cached -p HEAD' in that case.
25 # If we have -[123] --ours --theirs --base, don't do --cc by default.
27 *" '-"[123]"' "* |
*" '--ours' "* |
*" '--base' "* |
*" '--theirs' "*)
33 # If we do not have --name-status, --name-only, -r, or -c default to --cc.
35 *" '--name-status' "* |
*" '--name-only' "* |
*" '-r' "* |
*" '-c' "* )
38 flags
="$flags'$cc_or_p' " ;;
41 # If we do not have -B nor -C, default to -M.
43 *" '-"[BCM
]* |
*" '--find-copies-harder' "*)
44 ;; # something like -M50.
46 flags
="$flags'-M' " ;;
54 begin
=$
(expr "$rev" : '.*^.\([0-9a-f]*\).*') &&
55 end
=$
(expr "$rev" : '.\([0-9a-f]*\). .*') ||
exit
56 cmd
="git-diff-tree $flags $begin $end -- $files"
59 cmd
="git-diff-tree $flags $rev -- $files"
62 cmd
="git-diff-index $flags $rev -- $files"
65 cmd
="git-diff-files $flags -- $files"