From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: [PATCH] Add git-external-diff-script
Date: Thu, 26 May 2005 02:31:05 -0700 [thread overview]
Message-ID: <7vll62cp0m.fsf@assigned-by-dhcp.cox.net> (raw)
This is a demonstration of GIT_EXTERNAL_DIFF mechanism, and a
testbed for tweaking and enhancing what the built-in diff should
do. This script is designed to output exactly the same output
as what the built-in diff driver produces when used as the
GIT_EXTERNAL_DIFF command.
I've run this and updated built-in diff on the entire history of
linux-2.6 git repository, and JG's udev.git repository which has
interesting symlink cases to make sure it is equivalent to the
built-in diff driver.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
git-external-diff-script | 67 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 67 insertions(+)
new file (100755): git-external-diff-script
diff --git a/git-external-diff-script b/git-external-diff-script
new file mode 100755
--- /dev/null
+++ b/git-external-diff-script
@@ -0,0 +1,67 @@
+#!/bin/sh
+# Copyright (C) 2005 Junio C Hamano
+#
+# This script is designed to emulate what the built-in diff driver
+# does when set as GIT_EXTERNAL_SCRIPT.
+
+case "$#" in
+1)
+ echo "* Unmerged path $1"
+ exit 0 ;;
+*)
+ name1="$1" tmp1="$2" hex1="$3" mode1="$4" tmp2="$5" hex2="$6" mode2="$7"
+ case "$#" in
+ 7)
+ name2="$name1" ;;
+ 9)
+ name2="$8" xfrm_msg="$9" ;;
+ esac ;;
+esac
+
+show_create () {
+ name_="$1" tmp_="$2" hex_="$3" mode_="$4"
+ echo "diff --git a/$name_ b/$name_"
+ echo "new file mode $mode_"
+ diff ${GIT_DIFF_OPTS-'-pu'} -L /dev/null -L "b/$name_" /dev/null "$tmp_"
+}
+
+show_delete () {
+ name_="$1" tmp_="$2" hex_="$3" mode_="$4"
+ echo "diff --git a/$name_ b/$name_"
+ echo "deleted file mode $mode_"
+ diff ${GIT_DIFF_OPTS-'-pu'} -L "a/$name_" -L /dev/null "$tmp_" /dev/null
+}
+
+case "$mode1" in
+120*) type1=l ;;
+100*) type1=f ;;
+.) show_create "$name2" "$tmp2" "$hex2" "$mode2"
+ exit 0 ;;
+esac
+case "$mode2" in
+120*) type2=l ;;
+100*) type2=f ;;
+.) show_delete "$name1" "$tmp1" "$hex1" "$mode1"
+ exit 0 ;;
+esac
+
+if test "$type1" != "$type2"
+then
+ show_delete "$name1" "$tmp1" "$hex1" "$mode1"
+ show_create "$name2" "$tmp2" "$hex2" "$mode2"
+ exit 0
+fi
+
+echo diff --git "a/$name1" "b/$name2"
+if test "$mode1" != "$mode2"
+then
+ echo "old mode $mode1"
+ echo "new mode $mode2"
+ if test "$xfrm_msg" != ""
+ then
+ echo -n $xfrm_msg
+ fi
+fi
+diff ${GIT_DIFF_OPTS-'-pu'} -L "a/$name1" -L "b/$name2" "$tmp1" "$tmp2"
+exit 0
+
------------------------------------------------
reply other threads:[~2005-05-26 9:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vll62cp0m.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox