]>
git.ipfire.org Git - thirdparty/git.git/blob - t/t7601-merge-pull-config.sh
3 test_description
='git merge
5 Testing pull.* configuration parsing.'
9 test_expect_success
'setup' '
18 git reset --hard c0 &&
23 git reset --hard c0 &&
30 test_expect_success
'merge c1 with c2' '
31 git reset --hard c1 &&
41 test_expect_success
'fast-forward pull succeeds with "true" in pull.ff' '
42 git reset --hard c0 &&
43 test_config pull.ff true &&
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 &&
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 &&
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 &&
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" &&
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 &&
103 git diff-files
--name-only
104 git ls-files
--unmerged
111 # There are two conflicts here:
113 # 1) Because foo.c is renamed to bar.c, recursive will handle this,
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 &&
126 echo B >conflict.c &&
127 git add conflict.c &&
128 git mv foo.c bar.c &&
131 git reset --hard c4 &&
132 echo C >conflict.c &&
133 git add conflict.c &&
134 echo secondline >> foo.c &&
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