3 # Copyright (c) 2007 Junio C Hamano
6 test_description='per path merge controlled by merge attribute'
10 test_expect_success setup '
12 for f in text binary union
14 echo Initial >$f && git add $f || break
17 git commit -m Initial &&
20 for f in text binary union
22 echo Master >>$f && git add $f || break
25 git commit -m Master &&
28 for f in text binary union
30 echo Side >>$f && git add $f || break
38 test_expect_success merge '
42 echo "union merge=union"
47 echo Gaah, should have conflicted
54 test_expect_success 'check merge result in index' '
56 git ls-files -u | grep binary &&
57 git ls-files -u | grep text &&
58 ! (git ls-files -u | grep union)
62 test_expect_success 'check merge result in working tree' '
64 git cat-file -p HEAD:binary >binary-orig &&
65 grep "<<<<<<<" text &&
66 cmp binary-orig binary &&
67 ! grep "<<<<<<<" union &&
73 cat >./custom-merge <<\EOF
76 orig="$1" ours="$2" theirs="$3" exit="$4"
80 echo "theirs is $theirs"
92 chmod +x ./custom-merge
94 test_expect_success 'custom merge backend' '
96 echo "* merge=union" >.gitattributes &&
97 echo "text merge=custom" >>.gitattributes &&
99 git reset --hard anchor &&
100 git config --replace-all \
101 merge.custom.driver "./custom-merge %O %A %B 0" &&
102 git config --replace-all \
103 merge.custom.name "custom merge driver for testing" &&
108 sed -e 1,3d text >check-1 &&
109 o=$(git unpack-file master^:text) &&
110 a=$(git unpack-file side^:text) &&
111 b=$(git unpack-file master:text) &&
112 sh -c "./custom-merge $o $a $b 0" &&
113 sed -e 1,3d $a >check-2 &&
114 cmp check-1 check-2 &&
118 test_expect_success 'custom merge backend' '
120 git reset --hard anchor &&
121 git config --replace-all \
122 merge.custom.driver "./custom-merge %O %A %B 1" &&
123 git config --replace-all \
124 merge.custom.name "custom merge driver for testing" &&
128 echo "Eh? should have conflicted"
131 echo "Ok, conflicted"
135 sed -e 1,3d text >check-1 &&
136 o=$(git unpack-file master^:text) &&
137 a=$(git unpack-file anchor:text) &&
138 b=$(git unpack-file master:text) &&
139 sh -c "./custom-merge $o $a $b 0" &&
140 sed -e 1,3d $a >check-2 &&
141 cmp check-1 check-2 &&