{"thread":{"id":"722","subject":"[PATCH] Add git-external-diff-script","startedAt":"2005-05-26T09:31:05Z","lastAt":"2005-05-26T09:31:05Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"3982","messageId":"7vll62cp0m.fsf@assigned-by-dhcp.cox.net","threadId":"722","inReplyTo":null,"subject":"[PATCH] Add git-external-diff-script","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-05-26T09:31:05Z","receivedAt":"2005-05-26T09:31:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This is a demonstration of GIT_EXTERNAL_DIFF mechanism, and a\ntestbed for tweaking and enhancing what the built-in diff should\ndo.  This script is designed to output exactly the same output\nas what the built-in diff driver produces when used as the\nGIT_EXTERNAL_DIFF command.\n\nI've run this and updated built-in diff on the entire history of\nlinux-2.6 git repository, and JG's udev.git repository which has\ninteresting symlink cases to make sure it is equivalent to the\nbuilt-in diff driver.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\ngit-external-diff-script |   67 +++++++++++++++++++++++++++++++++++++++++++++++\n1 files changed, 67 insertions(+)\nnew file (100755): git-external-diff-script\n\ndiff --git a/git-external-diff-script b/git-external-diff-script\nnew file mode 100755\n--- /dev/null\n+++ b/git-external-diff-script\n@@ -0,0 +1,67 @@\n+#!/bin/sh\n+# Copyright (C) 2005 Junio C Hamano\n+#\n+# This script is designed to emulate what the built-in diff driver\n+# does when set as GIT_EXTERNAL_SCRIPT.\n+\n+case \"$#\" in\n+1)\n+    echo \"* Unmerged path $1\"\n+    exit 0 ;;\n+*)\n+    name1=\"$1\" tmp1=\"$2\" hex1=\"$3\" mode1=\"$4\" tmp2=\"$5\" hex2=\"$6\" mode2=\"$7\"\n+    case \"$#\" in\n+    7)\n+\tname2=\"$name1\" ;;\n+    9)\n+\tname2=\"$8\" xfrm_msg=\"$9\" ;;\n+    esac ;;\t\n+esac\n+\n+show_create () {\n+    name_=\"$1\" tmp_=\"$2\" hex_=\"$3\" mode_=\"$4\"\n+    echo \"diff --git a/$name_ b/$name_\"\n+    echo \"new file mode $mode_\"\n+    diff ${GIT_DIFF_OPTS-'-pu'} -L /dev/null -L \"b/$name_\" /dev/null \"$tmp_\"\n+}\n+\n+show_delete () {\n+    name_=\"$1\" tmp_=\"$2\" hex_=\"$3\" mode_=\"$4\"\n+    echo \"diff --git a/$name_ b/$name_\"\n+    echo \"deleted file mode $mode_\"\n+    diff ${GIT_DIFF_OPTS-'-pu'} -L \"a/$name_\" -L /dev/null \"$tmp_\" /dev/null\n+}\n+\n+case \"$mode1\" in\n+120*) type1=l ;;\n+100*) type1=f ;;\n+.)    show_create \"$name2\" \"$tmp2\" \"$hex2\" \"$mode2\"\n+      exit 0 ;;\n+esac\n+case \"$mode2\" in\n+120*) type2=l ;;\n+100*) type2=f ;;\n+.)    show_delete \"$name1\" \"$tmp1\" \"$hex1\" \"$mode1\"\n+      exit 0 ;;\n+esac\n+\n+if test \"$type1\" != \"$type2\"\n+then\n+\tshow_delete \"$name1\" \"$tmp1\" \"$hex1\" \"$mode1\"\n+\tshow_create \"$name2\" \"$tmp2\" \"$hex2\" \"$mode2\"\n+\texit 0\n+fi\n+\n+echo diff --git \"a/$name1\" \"b/$name2\"\n+if test \"$mode1\" != \"$mode2\"\n+then\n+    echo \"old mode $mode1\"\n+    echo \"new mode $mode2\"\n+    if test \"$xfrm_msg\" != \"\"\n+    then\n+\techo -n $xfrm_msg\n+    fi\n+fi\n+diff ${GIT_DIFF_OPTS-'-pu'} -L \"a/$name1\" -L \"b/$name2\" \"$tmp1\" \"$tmp2\"\n+exit 0\n+\n------------------------------------------------\n\n"}]}