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 test_expect_success 'retry the merge with longer context' '
74 echo text conflict-marker-size=32 >>.gitattributes &&
75 git checkout -m text &&
76 sed -ne "/^\([<=>]\)\1\1\1*/{
80 grep ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" actual &&
81 grep "================================" actual &&
82 grep "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" actual
85 cat >./custom-merge <<\EOF
88 orig="$1" ours="$2" theirs="$3" exit="$4"
92 echo "theirs is $theirs"
100 cat "$ours+" >"$ours"
104 chmod +x ./custom-merge
106 test_expect_success 'custom merge backend' '
108 echo "* merge=union" >.gitattributes &&
109 echo "text merge=custom" >>.gitattributes &&
111 git reset --hard anchor &&
112 git config --replace-all \
113 merge.custom.driver "./custom-merge %O %A %B 0" &&
114 git config --replace-all \
115 merge.custom.name "custom merge driver for testing" &&
120 sed -e 1,3d text >check-1 &&
121 o=$(git unpack-file master^:text) &&
122 a=$(git unpack-file side^:text) &&
123 b=$(git unpack-file master:text) &&
124 sh -c "./custom-merge $o $a $b 0" &&
125 sed -e 1,3d $a >check-2 &&
126 cmp check-1 check-2 &&
130 test_expect_success 'custom merge backend' '
132 git reset --hard anchor &&
133 git config --replace-all \
134 merge.custom.driver "./custom-merge %O %A %B 1" &&
135 git config --replace-all \
136 merge.custom.name "custom merge driver for testing" &&
140 echo "Eh? should have conflicted"
143 echo "Ok, conflicted"
147 sed -e 1,3d text >check-1 &&
148 o=$(git unpack-file master^:text) &&
149 a=$(git unpack-file anchor:text) &&
150 b=$(git unpack-file master:text) &&
151 sh -c "./custom-merge $o $a $b 0" &&
152 sed -e 1,3d $a >check-2 &&
153 cmp check-1 check-2 &&
157 test_expect_success 'up-to-date merge without common ancestor' '
158 test_create_repo repo1 &&
159 test_create_repo repo2 &&
165 git commit -m initial
170 git commit --allow-empty -m initial
175 git pull ../repo2 master