Add new test to ensure git-merge handles pull.twohead and pull.octopus
Test if the given strategies are used and test the case when multiple strategies are configured using a space separated list. Also test if the best strategy is picked if none is specified. This is done by adding a simple test case where recursive detects a rename, but resolve does not, and verify that finally merge will pick up the previous. Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Miklos Vajna committed
Jun 29, 2008 at 16:51 UTC
b2eabcc2539c021ea6cb2d1d2d28c8213986a186
1 file changed
+129
t/t7601-merge-pull-config.sh
new
+129
@@ -0,0 +1,129 @@
1
+#!/bin/sh
2
+
3
+test_description='git-merge
4
+
5
+Testing pull.* configuration parsing.'
6
+
7
+. ./test-lib.sh
8
+
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
28
+'
29
+
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
39
+'
40
+
41
+test_expect_success 'merge c1 with c2 (ours in pull.twohead)' '
42
+ git reset --hard c1 &&
43
+ git config pull.twohead ours &&
44
+ git merge c2 &&
45
+ test -f c1.c &&
46
+ ! test -f c2.c
47
+'
48
+
49
+test_expect_success 'merge c1 with c2 and c3 (recursive in pull.octopus)' '
50
+ git reset --hard c1 &&
51
+ git config pull.octopus "recursive" &&
52
+ test_must_fail git merge c2 c3 &&
53
+ test "$(git rev-parse c1)" = "$(git rev-parse HEAD)"
54
+'
55
+
56
+test_expect_success 'merge c1 with c2 and c3 (recursive and octopus in pull.octopus)' '
57
+ git reset --hard c1 &&
58
+ git config pull.octopus "recursive octopus" &&
59
+ git merge c2 c3 &&
60
+ test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" &&
61
+ test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" &&
62
+ test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" &&
63
+ test "$(git rev-parse c3)" = "$(git rev-parse HEAD^3)" &&
64
+ git diff --exit-code &&
65
+ test -f c0.c &&
66
+ test -f c1.c &&
67
+ test -f c2.c &&
68
+ test -f c3.c
69
+'
70
+
71
+conflict_count()
72
+{
73
+ eval $1=`{
74
+ git diff-files --name-only
75
+ git ls-files --unmerged
76
+ } | wc -l`
77
+}
78
+
79
+# c4 - c5
80
+# \ c6
81
+#
82
+# There are two conflicts here:
83
+#
84
+# 1) Because foo.c is renamed to bar.c, recursive will handle this,
85
+# resolve won't.
86
+#
87
+# 2) One in conflict.c and that will always fail.
88
+
89
+test_expect_success 'setup conflicted merge' '
90
+ git reset --hard c0 &&
91
+ echo A >conflict.c &&
92
+ git add conflict.c &&
93
+ echo contents >foo.c &&
94
+ git add foo.c &&
95
+ git commit -m c4 &&
96
+ git tag c4 &&
97
+ echo B >conflict.c &&
98
+ git add conflict.c &&
99
+ git mv foo.c bar.c &&
100
+ git commit -m c5 &&
101
+ git tag c5 &&
102
+ git reset --hard c4 &&
103
+ echo C >conflict.c &&
104
+ git add conflict.c &&
105
+ echo secondline >> foo.c &&
106
+ git add foo.c &&
107
+ git commit -m c6 &&
108
+ git tag c6
109
+'
110
+
111
+# First do the merge with resolve and recursive then verify that
112
+# recusive is choosen.
113
+
114
+test_expect_success 'merge picks up the best result' '
115
+ git config pull.twohead "recursive resolve" &&
116
+ git reset --hard c5 &&
117
+ git merge -s resolve c6
118
+ conflict_count resolve_count &&
119
+ git reset --hard c5 &&
120
+ git merge -s recursive c6
121
+ conflict_count recursive_count &&
122
+ git reset --hard c5 &&
123
+ git merge c6
124
+ conflict_count auto_count &&
125
+ test "$auto_count" = "$recursive_count" &&
126
+ test "$auto_count" != "$resolve_count"
127
+'
128
+
129
+test_done