[PATCH] Subject: [PATCH] Add some documentation.
[git/fastimport.git] / git-external-diff-script
blob137280ac724ac95fc9784e092868fafcf6c35e8d
1 #!/bin/sh
2 # Copyright (C) 2005 Junio C Hamano
4 # This script is designed to emulate what the built-in diff driver
5 # does when set as GIT_EXTERNAL_SCRIPT.
7 case "$#" in
8 1)
9 echo "* Unmerged path $1"
10 exit 0 ;;
12 name1="$1" tmp1="$2" hex1="$3" mode1="$4" tmp2="$5" hex2="$6" mode2="$7"
13 case "$#" in
15 name2="$name1" ;;
17 name2="$8" xfrm_msg="$9" ;;
18 esac ;;
19 esac
21 show_create () {
22 name_="$1" tmp_="$2" hex_="$3" mode_="$4"
23 echo "diff --git a/$name_ b/$name_"
24 echo "new file mode $mode_"
25 diff ${GIT_DIFF_OPTS-'-pu'} -L /dev/null -L "b/$name_" /dev/null "$tmp_"
28 show_delete () {
29 name_="$1" tmp_="$2" hex_="$3" mode_="$4"
30 echo "diff --git a/$name_ b/$name_"
31 echo "deleted file mode $mode_"
32 diff ${GIT_DIFF_OPTS-'-pu'} -L "a/$name_" -L /dev/null "$tmp_" /dev/null
35 case "$mode1" in
36 120*) type1=l ;;
37 100*) type1=f ;;
38 .) show_create "$name2" "$tmp2" "$hex2" "$mode2"
39 exit 0 ;;
40 esac
41 case "$mode2" in
42 120*) type2=l ;;
43 100*) type2=f ;;
44 .) show_delete "$name1" "$tmp1" "$hex1" "$mode1"
45 exit 0 ;;
46 esac
48 if test "$type1" != "$type2"
49 then
50 show_delete "$name1" "$tmp1" "$hex1" "$mode1"
51 show_create "$name2" "$tmp2" "$hex2" "$mode2"
52 exit 0
55 echo diff --git "a/$name1" "b/$name2"
56 if test "$mode1" != "$mode2"
57 then
58 echo "old mode $mode1"
59 echo "new mode $mode2"
60 if test "$xfrm_msg" != ""
61 then
62 echo "$xfrm_msg"
65 diff ${GIT_DIFF_OPTS-'-pu'} -L "a/$name1" -L "b/$name2" "$tmp1" "$tmp2"
66 exit 0