mingw: mark t9100's test cases with appropriate prereqs
[git/raj.git] / t / t7601-merge-pull-config.sh
blobc6c44ec570dac66ca9a800ac687280cd3597e886
1 #!/bin/sh
3 test_description='git merge
5 Testing pull.* configuration parsing.'
7 . ./test-lib.sh
9 test_expect_success 'setup' '
10 echo c0 >c0.c &&
11 git add c0.c &&
12 git commit -m c0 &&
13 git tag c0 &&
14 echo c1 >c1.c &&
15 git add c1.c &&
16 git commit -m c1 &&
17 git tag c1 &&
18 git reset --hard c0 &&
19 echo c2 >c2.c &&
20 git add c2.c &&
21 git commit -m c2 &&
22 git tag c2 &&
23 git reset --hard c0 &&
24 echo c3 >c3.c &&
25 git add c3.c &&
26 git commit -m c3 &&
27 git tag c3
30 test_expect_success 'merge c1 with c2' '
31 git reset --hard c1 &&
32 test -f c0.c &&
33 test -f c1.c &&
34 test ! -f c2.c &&
35 test ! -f c3.c &&
36 git merge c2 &&
37 test -f c1.c &&
38 test -f c2.c
41 test_expect_success 'fast-forward pull succeeds with "true" in pull.ff' '
42 git reset --hard c0 &&
43 test_config pull.ff true &&
44 git pull . c1 &&
45 test "$(git rev-parse HEAD)" = "$(git rev-parse c1)"
48 test_expect_success 'pull.ff=true overrides merge.ff=false' '
49 git reset --hard c0 &&
50 test_config merge.ff false &&
51 test_config pull.ff true &&
52 git pull . c1 &&
53 test "$(git rev-parse HEAD)" = "$(git rev-parse c1)"
56 test_expect_success 'fast-forward pull creates merge with "false" in pull.ff' '
57 git reset --hard c0 &&
58 test_config pull.ff false &&
59 git pull . c1 &&
60 test "$(git rev-parse HEAD^1)" = "$(git rev-parse c0)" &&
61 test "$(git rev-parse HEAD^2)" = "$(git rev-parse c1)"
64 test_expect_success 'pull prevents non-fast-forward with "only" in pull.ff' '
65 git reset --hard c1 &&
66 test_config pull.ff only &&
67 test_must_fail git pull . c3
70 test_expect_success 'merge c1 with c2 (ours in pull.twohead)' '
71 git reset --hard c1 &&
72 git config pull.twohead ours &&
73 git merge c2 &&
74 test -f c1.c &&
75 ! test -f c2.c
78 test_expect_success 'merge c1 with c2 and c3 (recursive in pull.octopus)' '
79 git reset --hard c1 &&
80 git config pull.octopus "recursive" &&
81 test_must_fail git merge c2 c3 &&
82 test "$(git rev-parse c1)" = "$(git rev-parse HEAD)"
85 test_expect_success 'merge c1 with c2 and c3 (recursive and octopus in pull.octopus)' '
86 git reset --hard c1 &&
87 git config pull.octopus "recursive octopus" &&
88 git merge c2 c3 &&
89 test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" &&
90 test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" &&
91 test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" &&
92 test "$(git rev-parse c3)" = "$(git rev-parse HEAD^3)" &&
93 git diff --exit-code &&
94 test -f c0.c &&
95 test -f c1.c &&
96 test -f c2.c &&
97 test -f c3.c
100 conflict_count()
103 git diff-files --name-only
104 git ls-files --unmerged
105 } | wc -l
108 # c4 - c5
109 # \ c6
111 # There are two conflicts here:
113 # 1) Because foo.c is renamed to bar.c, recursive will handle this,
114 # resolve won't.
116 # 2) One in conflict.c and that will always fail.
118 test_expect_success 'setup conflicted merge' '
119 git reset --hard c0 &&
120 echo A >conflict.c &&
121 git add conflict.c &&
122 echo contents >foo.c &&
123 git add foo.c &&
124 git commit -m c4 &&
125 git tag c4 &&
126 echo B >conflict.c &&
127 git add conflict.c &&
128 git mv foo.c bar.c &&
129 git commit -m c5 &&
130 git tag c5 &&
131 git reset --hard c4 &&
132 echo C >conflict.c &&
133 git add conflict.c &&
134 echo secondline >> foo.c &&
135 git add foo.c &&
136 git commit -m c6 &&
137 git tag c6
140 # First do the merge with resolve and recursive then verify that
141 # recursive is chosen.
143 test_expect_success 'merge picks up the best result' '
144 git config --unset-all pull.twohead &&
145 git reset --hard c5 &&
146 test_must_fail git merge -s resolve c6 &&
147 resolve_count=$(conflict_count) &&
148 git reset --hard c5 &&
149 test_must_fail git merge -s recursive c6 &&
150 recursive_count=$(conflict_count) &&
151 git reset --hard c5 &&
152 test_must_fail git merge -s recursive -s resolve c6 &&
153 auto_count=$(conflict_count) &&
154 test $auto_count = $recursive_count &&
155 test $auto_count != $resolve_count
158 test_expect_success 'merge picks up the best result (from config)' '
159 git config pull.twohead "recursive resolve" &&
160 git reset --hard c5 &&
161 test_must_fail git merge -s resolve c6 &&
162 resolve_count=$(conflict_count) &&
163 git reset --hard c5 &&
164 test_must_fail git merge -s recursive c6 &&
165 recursive_count=$(conflict_count) &&
166 git reset --hard c5 &&
167 test_must_fail git merge c6 &&
168 auto_count=$(conflict_count) &&
169 test $auto_count = $recursive_count &&
170 test $auto_count != $resolve_count
173 test_expect_success 'merge errors out on invalid strategy' '
174 git config pull.twohead "foobar" &&
175 git reset --hard c5 &&
176 test_must_fail git merge c6
179 test_expect_success 'merge errors out on invalid strategy' '
180 git config --unset-all pull.twohead &&
181 git reset --hard c5 &&
182 test_must_fail git merge -s "resolve recursive" c6
185 test_done