@@ -82,7 +82,8 @@ test_expect_success 'ff update, important file modified' '
8282 touch subdir/e &&
8383 git add subdir/e &&
8484
85- test_must_fail git merge E^0
85+ test_must_fail git merge E^0 &&
86+ test_path_is_missing .git/MERGE_HEAD
8687'
8788
8889test_expect_success ' resolve, trivial' '
@@ -91,7 +92,8 @@ test_expect_success 'resolve, trivial' '
9192
9293 touch random_file && git add random_file &&
9394
94- test_must_fail git merge -s resolve C^0
95+ test_must_fail git merge -s resolve C^0 &&
96+ test_path_is_missing .git/MERGE_HEAD
9597'
9698
9799test_expect_success ' resolve, non-trivial' '
@@ -100,7 +102,8 @@ test_expect_success 'resolve, non-trivial' '
100102
101103 touch random_file && git add random_file &&
102104
103- test_must_fail git merge -s resolve D^0
105+ test_must_fail git merge -s resolve D^0 &&
106+ test_path_is_missing .git/MERGE_HEAD
104107'
105108
106109test_expect_success ' recursive' '
@@ -109,7 +112,8 @@ test_expect_success 'recursive' '
109112
110113 touch random_file && git add random_file &&
111114
112- test_must_fail git merge -s recursive C^0
115+ test_must_fail git merge -s recursive C^0 &&
116+ test_path_is_missing .git/MERGE_HEAD
113117'
114118
115119test_expect_success ' recursive, when merge branch matches merge base' '
@@ -118,7 +122,45 @@ test_expect_success 'recursive, when merge branch matches merge base' '
118122
119123 touch random_file && git add random_file &&
120124
121- test_must_fail git merge -s recursive F^0
125+ test_must_fail git merge -s recursive F^0 &&
126+ test_path_is_missing .git/MERGE_HEAD
127+ '
128+
129+ test_expect_success ' merge-recursive, when index==head but head!=HEAD' '
130+ git reset --hard &&
131+ git checkout C^0 &&
132+
133+ # Make index match B
134+ git diff C B -- | git apply --cached &&
135+ # Merge B & F, with B as "head"
136+ git merge-recursive A -- B F > out &&
137+ test_i18ngrep "Already up to date" out
138+ '
139+
140+ test_expect_success ' recursive, when file has staged changes not matching HEAD nor what a merge would give' '
141+ git reset --hard &&
142+ git checkout B^0 &&
143+
144+ mkdir subdir &&
145+ test_seq 1 10 >subdir/a &&
146+ git add subdir/a &&
147+
148+ # We have staged changes; merge should error out
149+ test_must_fail git merge -s recursive E^0 2>err &&
150+ test_i18ngrep "changes to the following files would be overwritten" err
151+ '
152+
153+ test_expect_success ' recursive, when file has staged changes matching what a merge would give' '
154+ git reset --hard &&
155+ git checkout B^0 &&
156+
157+ mkdir subdir &&
158+ test_seq 1 11 >subdir/a &&
159+ git add subdir/a &&
160+
161+ # We have staged changes; merge should error out
162+ test_must_fail git merge -s recursive E^0 2>err &&
163+ test_i18ngrep "changes to the following files would be overwritten" err
122164'
123165
124166test_expect_success ' octopus, unrelated file touched' '
@@ -127,7 +169,8 @@ test_expect_success 'octopus, unrelated file touched' '
127169
128170 touch random_file && git add random_file &&
129171
130- test_must_fail git merge C^0 D^0
172+ test_must_fail git merge C^0 D^0 &&
173+ test_path_is_missing .git/MERGE_HEAD
131174'
132175
133176test_expect_success ' octopus, related file removed' '
@@ -136,7 +179,8 @@ test_expect_success 'octopus, related file removed' '
136179
137180 git rm b &&
138181
139- test_must_fail git merge C^0 D^0
182+ test_must_fail git merge C^0 D^0 &&
183+ test_path_is_missing .git/MERGE_HEAD
140184'
141185
142186test_expect_success ' octopus, related file modified' '
@@ -145,7 +189,8 @@ test_expect_success 'octopus, related file modified' '
145189
146190 echo 12 >>a && git add a &&
147191
148- test_must_fail git merge C^0 D^0
192+ test_must_fail git merge C^0 D^0 &&
193+ test_path_is_missing .git/MERGE_HEAD
149194'
150195
151196test_expect_success ' ours' '
@@ -154,7 +199,8 @@ test_expect_success 'ours' '
154199
155200 touch random_file && git add random_file &&
156201
157- test_must_fail git merge -s ours C^0
202+ test_must_fail git merge -s ours C^0 &&
203+ test_path_is_missing .git/MERGE_HEAD
158204'
159205
160206test_expect_success ' subtree' '
@@ -163,7 +209,8 @@ test_expect_success 'subtree' '
163209
164210 touch random_file && git add random_file &&
165211
166- test_must_fail git merge -s subtree E^0
212+ test_must_fail git merge -s subtree E^0 &&
213+ test_path_is_missing .git/MERGE_HEAD
167214'
168215
169216test_done
0 commit comments