t6044: recursive can silently incorporate dirty changes in a merge
The recursive merge strategy has some special handling when the tree for the merge branch exactly matches the merge base, but that code path is missing checks for the index having changes relative to HEAD. Add a testcase covering this scenario. Reported-by: Andreas Krey <a.krey@gmx.de> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Dec 21, 2017 at 11:19 UTC
eab3f2850e7cc63a8087fbeae608a1b72ea70c7b
1 file changed
+21
-5
t/t6044-merge-unrelated-index-changes.sh
+21
-5
@@ -6,18 +6,21 @@ test_description="merges with unrelated index changes"
6
7
# Testcase for some simple merges
8
# A
9
-# o-----o B
9
+# o-------o B
10
# \
11
-# \---o C
11
+# \-----o C
12
# \
13
-# \-o D
13
+# \---o D
14
# \
15
-# o E
15
+# \-o E
16
+# \
17
+# o F
18
# Commit A: some file a
19
# Commit B: adds file b, modifies end of a
20
# Commit C: adds file c
21
# Commit D: adds file d, modifies beginning of a
22
# Commit E: renames a->subdir/a, adds subdir/e
23
+# Commit F: empty commit
24
25
test_expect_success 'setup trivial merges' '
26
test_seq 1 10 >a &&
@@ -29,6 +32,7 @@ test_expect_success 'setup trivial merges' '
32
git branch C &&
33
git branch D &&
34
git branch E &&
35
+ git branch F &&
36
37
git checkout B &&
38
echo b >b &&
@@ -52,7 +56,10 @@ test_expect_success 'setup trivial merges' '
56
git mv a subdir/a &&
57
echo e >subdir/e &&
58
git add subdir &&
55
- test_tick && git commit -m E
59
+ test_tick && git commit -m E &&
60
+
61
+ git checkout F &&
62
+ test_tick && git commit --allow-empty -m F
63
'
64
65
test_expect_success 'ff update' '
@@ -105,6 +112,15 @@ test_expect_success 'recursive' '
112
test_must_fail git merge -s recursive C^0
113
'
114
115
+test_expect_failure 'recursive, when merge branch matches merge base' '
116
+ git reset --hard &&
117
+ git checkout B^0 &&
118
+
119
+ touch random_file && git add random_file &&
120
+
121
+ test_must_fail git merge -s recursive F^0
122
+'
123
+
124
test_expect_success 'octopus, unrelated file touched' '
125
git reset --hard &&
126
git checkout B^0 &&