1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-06 01:03:02 +01:00
git/git-diff-script
Junio C Hamano 0a5a9ea433 Update git-diff-script.
This uses the fixed rev-parse to allow passing diff options to the
underlying diff command.  For example:

    $ git diff -r HEAD

shows the output in raw-diff format, and

    $ git diff -p -R HEAD | git apply

generates a patch to go back from your working tree to HEAD commit
(i.e. an expensive way to say "git checkout -f HEAD").

At the same time, it accidentally removes the use of shell arrays.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-23 13:18:00 -07:00

35 lines
701 B
Bash
Executable file

#!/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"