aboutsummaryrefslogtreecommitdiff
path: root/git-diff-script
blob: a285a2a4ee056fc4689c139eebe299072c91b46d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh
#
# 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'"}

case "$rev" in
?*' '?*' '?*)
	die "I don't understand"
	;;
?*' '^?*)
	begin=$(expr "$rev" : '.*^.\([0-9a-f]*\).*') &&
	end=$(expr "$rev" : '.\([0-9a-f]*\). .*') || exit
	cmd="git-diff-tree $flags $begin $end $files"
	;;
?*' '?*)
	cmd="git-diff-tree $flags $rev $files"
	;;
?*' ')
	cmd="git-diff-cache $flags $rev $files"
	;;
'')
	cmd="git-diff-files $flags $files"
	;;
*)
	die "I don't understand $*"
	;;
esac

eval "$cmd"