Add "git diff" script
authorLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 13 Jun 2005 22:09:34 +0000 (15:09 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 13 Jun 2005 22:09:34 +0000 (15:09 -0700)
It's a simple helper that depending on the arguments will either
use git-diff-files, git-diff-cache or git-diff-tree.

Makefile
git-diff-script [new file with mode: 0755]

index 8216c99..dd16385 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@ INSTALL=install
 SCRIPTS=git git-apply-patch-script git-merge-one-file-script git-prune-script \
        git-pull-script git-tag-script git-resolve-script git-whatchanged \
        git-deltafy-script git-fetch-script git-status-script git-commit-script \
-       git-log-script git-shortlog git-cvsimport-script
+       git-log-script git-shortlog git-cvsimport-script git-diff-script
 
 PROG=   git-update-cache git-diff-files git-init-db git-write-tree \
        git-read-tree git-commit-tree git-cat-file git-fsck-cache \
diff --git a/git-diff-script b/git-diff-script
new file mode 100755 (executable)
index 0000000..d70e8b9
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+rev=($(git-rev-parse --revs-only "$@"))
+flags=($(git-rev-parse --no-revs "$@"))
+case "${#rev[*]}" in
+0)
+       git-diff-files -p "$@";;
+1)
+       git-diff-cache -p "$@";;
+2)
+       begin=$(echo "${rev[1]}" | tr -d '^')
+       end="${rev[0]}"
+       git-diff-tree -p $flags $begin $end;;
+*)
+       echo "I don't understand"
+       exit 1;;
+esac