Revert "Add deltifier test."
[git/dscho.git] / git-diff.sh
blobb62e58341cd9d11fc893613949426126871531e2
1 #!/bin/sh
3 # Copyright (c) 2005 Linus Torvalds
4 # Copyright (c) 2005 Junio C Hamano
6 rev=$(git-rev-parse --revs-only --no-flags --sq "$@") || exit
7 flags=$(git-rev-parse --no-revs --flags --sq "$@")
8 files=$(git-rev-parse --no-revs --no-flags --sq "$@")
10 die () {
11 echo >&2 "$*"
12 exit 1
15 # I often say 'git diff --cached -p' and get scolded by git-diff-files, but
16 # obviously I mean 'git diff --cached -p HEAD' in that case.
17 case "$rev" in
18 '')
19 case " $flags " in
20 *" '--cached' "*)
21 rev='HEAD '
23 esac
24 esac
26 # If we do not have --name-status, --name-only nor -r, default to -p.
27 # If we do not have -B nor -C, default to -M.
28 case " $flags " in
29 *" '--name-status' "* | *" '--name-only' "* | *" '-r' "* )
32 flags="$flags'-p' " ;;
33 esac
34 case " $flags " in
35 *" '-"[BCM]* | *" '--find-copies-harder' "*)
36 ;; # something like -M50.
38 flags="$flags'-M' " ;;
39 esac
41 case "$rev" in
42 ?*' '?*' '?*)
43 echo >&2 "I don't understand"
44 exit 1
46 ?*' '^?*)
47 begin=$(expr "$rev" : '.*^.\([0-9a-f]*\).*') &&
48 end=$(expr "$rev" : '.\([0-9a-f]*\). .*') || exit
49 cmd="git-diff-tree $flags $begin $end -- $files"
51 ?*' '?*)
52 cmd="git-diff-tree $flags $rev -- $files"
54 ?*' ')
55 cmd="git-diff-index $flags $rev -- $files"
57 '')
58 cmd="git-diff-files $flags -- $files"
61 die "I don't understand $*"
63 esac
65 eval "$cmd"