Merge branch 'fixes'
[git/dkf.git] / git-diff.sh
blob84a152af206166e88701b27acdc7d2b033e90bab
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 : ${flags:="'-M' '-p'"}
12 # I often say 'git diff --cached -p' and get scolded by git-diff-files, but
13 # obviously I mean 'git diff --cached -p HEAD' in that case.
14 case "$rev" in
15 '')
16 case " $flags " in
17 *" '--cached' "*)
18 rev='HEAD '
20 esac
21 esac
23 case "$rev" in
24 ?*' '?*' '?*)
25 echo >&2 "I don't understand"
26 exit 1
28 ?*' '^?*)
29 begin=$(expr "$rev" : '.*^.\([0-9a-f]*\).*') &&
30 end=$(expr "$rev" : '.\([0-9a-f]*\). .*') || exit
31 cmd="git-diff-tree $flags $begin $end $files"
33 ?*' '?*)
34 cmd="git-diff-tree $flags $rev $files"
36 ?*' ')
37 cmd="git-diff-index $flags $rev $files"
39 '')
40 cmd="git-diff-files $flags $files"
43 die "I don't understand $*"
45 esac
47 eval "$cmd"