1#!/bin/sh
2#
3# Copyright (c) 2005 Linus Torvalds
4# Copyright (c) 2005 Junio C Hamano
5
6rev=$(git-rev-parse --revs-only --no-flags --sq "$@") || exit
7flags=$(git-rev-parse --no-revs --flags --sq "$@")
8files=$(git-rev-parse --no-revs --no-flags --sq "$@")
9
10: ${flags:="'-M' '-p'"}
11
12case "$rev" in
13?*' '?*' '?*)
14 die "I don't understand"
15 ;;
16?*' '^?*)
17 begin=$(expr "$rev" : '.*^.\([0-9a-f]*\).*') &&
18 end=$(expr "$rev" : '.\([0-9a-f]*\). .*') || exit
19 cmd="git-diff-tree $flags $begin $end $files"
20 ;;
21?*' '?*)
22 cmd="git-diff-tree $flags $rev $files"
23 ;;
24?*' ')
25 cmd="git-diff-cache $flags $rev $files"
26 ;;
27'')
28 cmd="git-diff-files $flags $files"
29 ;;
30*)
31 die "I don't understand $*"
32 ;;
33esac
34
35eval "$cmd"