French translation: copy -> copie.
[git/dscho.git] / t / t6026-merge-attr.sh
blob5e439972bea358f700ded4266df31f7dc4514800
1 #!/bin/sh
3 # Copyright (c) 2007 Junio C Hamano
6 test_description='per path merge controlled by merge attribute'
8 . ./test-lib.sh
10 test_expect_success setup '
12 for f in text binary union
14 echo Initial >$f && git add $f || break
15 done &&
16 test_tick &&
17 git commit -m Initial &&
19 git branch side &&
20 for f in text binary union
22 echo Master >>$f && git add $f || break
23 done &&
24 test_tick &&
25 git commit -m Master &&
27 git checkout side &&
28 for f in text binary union
30 echo Side >>$f && git add $f || break
31 done &&
32 test_tick &&
33 git commit -m Side &&
35 git tag anchor
38 test_expect_success merge '
41 echo "binary -merge"
42 echo "union merge=union"
43 } >.gitattributes &&
45 if git merge master
46 then
47 echo Gaah, should have conflicted
48 false
49 else
50 echo Ok, 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 &&
68 grep Master union &&
69 grep Side 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*/{
77 s/ .*$//
79 }" >actual text &&
80 grep ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" actual &&
81 grep "================================" actual &&
82 grep "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" actual
85 cat >./custom-merge <<\EOF
86 #!/bin/sh
88 orig="$1" ours="$2" theirs="$3" exit="$4"
90 echo "orig is $orig"
91 echo "ours is $ours"
92 echo "theirs is $theirs"
93 echo "=== orig ==="
94 cat "$orig"
95 echo "=== ours ==="
96 cat "$ours"
97 echo "=== theirs ==="
98 cat "$theirs"
99 ) >"$ours+"
100 cat "$ours+" >"$ours"
101 rm -f "$ours+"
102 exit "$exit"
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" &&
117 git merge master &&
119 cmp binary union &&
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 &&
127 rm -f $o $a $b
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" &&
138 if git merge master
139 then
140 echo "Eh? should have conflicted"
141 false
142 else
143 echo "Ok, conflicted"
144 fi &&
146 cmp binary union &&
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 &&
154 rm -f $o $a $b
157 test_expect_success 'up-to-date merge without common ancestor' '
158 test_create_repo repo1 &&
159 test_create_repo repo2 &&
160 test_tick &&
162 cd repo1 &&
163 >a &&
164 git add a &&
165 git commit -m initial
166 ) &&
167 test_tick &&
169 cd repo2 &&
170 git commit --allow-empty -m initial
171 ) &&
172 test_tick &&
174 cd repo1 &&
175 git pull ../repo2 master
179 test_done