1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-06 09:13:01 +01:00
git/git-diff-script
Linus Torvalds d288a70030 [PATCH] Make "git diff" work inside relative subdirectories
We always show the diff as an absolute path, but pathnames to diff are
taken relative to the current working directory (and if no pathnames are
given, the default ends up being all of the current working directory).

Note that "../xyz" also works, so you can do

	cd linux/drivers/char
	git diff ../block

and it will generate a diff of the linux/drivers/block changes.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-16 18:47:22 -07:00

17 lines
395 B
Bash
Executable file

#!/bin/sh
rev=($(git-rev-parse --revs-only "$@")) || exit
flags=($(git-rev-parse --no-revs --flags "$@"))
files=($(git-rev-parse --no-revs --no-flags "$@"))
case "${#rev[*]}" in
0)
git-diff-files -M -p "$@";;
1)
git-diff-cache -M -p "$@";;
2)
begin=$(echo "${rev[1]}" | tr -d '^')
end="${rev[0]}"
git-diff-tree -M -p $flags $begin $end $files;;
*)
echo "I don't understand"
exit 1;;
esac