Skip to content

Commit 5a10f4c

Browse files
committed
Merge branch 'jc/t6424-failing-merge-preserve-local-changes'
The tests that ensured merges stop when interfering local changes are present did not make sure that local changes are preserved; now they do. * jc/t6424-failing-merge-preserve-local-changes: t6424: make sure a failed merge preserves local changes
2 parents 60be293 + 4b31745 commit 5a10f4c

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

t/t6424-merge-unrelated-index-changes.sh

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ test_expect_success 'ff update' '
7171
git merge E^0 &&
7272
7373
test_must_fail git rev-parse HEAD:random_file &&
74-
test "$(git diff --name-only --cached E)" = "random_file"
74+
test "$(git diff --name-only --cached E)" = "random_file" &&
75+
test_path_is_file random_file &&
76+
git rev-parse --verify :random_file
7577
'
7678

7779
test_expect_success 'ff update, important file modified' '
@@ -83,6 +85,8 @@ test_expect_success 'ff update, important file modified' '
8385
git add subdir/e &&
8486
8587
test_must_fail git merge E^0 &&
88+
test_path_is_file subdir/e &&
89+
git rev-parse --verify :subdir/e &&
8690
test_path_is_missing .git/MERGE_HEAD
8791
'
8892

@@ -93,6 +97,8 @@ test_expect_success 'resolve, trivial' '
9397
touch random_file && git add random_file &&
9498
9599
test_must_fail git merge -s resolve C^0 &&
100+
test_path_is_file random_file &&
101+
git rev-parse --verify :random_file &&
96102
test_path_is_missing .git/MERGE_HEAD
97103
'
98104

@@ -103,6 +109,8 @@ test_expect_success 'resolve, non-trivial' '
103109
touch random_file && git add random_file &&
104110
105111
test_must_fail git merge -s resolve D^0 &&
112+
test_path_is_file random_file &&
113+
git rev-parse --verify :random_file &&
106114
test_path_is_missing .git/MERGE_HEAD
107115
'
108116

@@ -113,6 +121,8 @@ test_expect_success 'recursive' '
113121
touch random_file && git add random_file &&
114122
115123
test_must_fail git merge -s recursive C^0 &&
124+
test_path_is_file random_file &&
125+
git rev-parse --verify :random_file &&
116126
test_path_is_missing .git/MERGE_HEAD
117127
'
118128

@@ -145,9 +155,12 @@ test_expect_success 'recursive, when file has staged changes not matching HEAD n
145155
mkdir subdir &&
146156
test_seq 1 10 >subdir/a &&
147157
git add subdir/a &&
158+
git rev-parse --verify :subdir/a >expect &&
148159
149160
# We have staged changes; merge should error out
150161
test_must_fail git merge -s recursive E^0 2>err &&
162+
git rev-parse --verify :subdir/a >actual &&
163+
test_cmp expect actual &&
151164
test_i18ngrep "changes to the following files would be overwritten" err
152165
'
153166

@@ -158,9 +171,12 @@ test_expect_success 'recursive, when file has staged changes matching what a mer
158171
mkdir subdir &&
159172
test_seq 1 11 >subdir/a &&
160173
git add subdir/a &&
174+
git rev-parse --verify :subdir/a >expect &&
161175
162176
# We have staged changes; merge should error out
163177
test_must_fail git merge -s recursive E^0 2>err &&
178+
git rev-parse --verify :subdir/a >actual &&
179+
test_cmp expect actual &&
164180
test_i18ngrep "changes to the following files would be overwritten" err
165181
'
166182

@@ -171,7 +187,9 @@ test_expect_success 'octopus, unrelated file touched' '
171187
touch random_file && git add random_file &&
172188
173189
test_must_fail git merge C^0 D^0 &&
174-
test_path_is_missing .git/MERGE_HEAD
190+
test_path_is_missing .git/MERGE_HEAD &&
191+
git rev-parse --verify :random_file &&
192+
test_path_exists random_file
175193
'
176194

177195
test_expect_success 'octopus, related file removed' '
@@ -181,6 +199,8 @@ test_expect_success 'octopus, related file removed' '
181199
git rm b &&
182200
183201
test_must_fail git merge C^0 D^0 &&
202+
test_path_is_missing b &&
203+
test_must_fail git rev-parse --verify :b &&
184204
test_path_is_missing .git/MERGE_HEAD
185205
'
186206

@@ -189,8 +209,12 @@ test_expect_success 'octopus, related file modified' '
189209
git checkout B^0 &&
190210
191211
echo 12 >>a && git add a &&
212+
git rev-parse --verify :a >expect &&
192213
193214
test_must_fail git merge C^0 D^0 &&
215+
test_path_is_file a &&
216+
git rev-parse --verify :a >actual &&
217+
test_cmp expect actual &&
194218
test_path_is_missing .git/MERGE_HEAD
195219
'
196220

@@ -201,6 +225,8 @@ test_expect_success 'ours' '
201225
touch random_file && git add random_file &&
202226
203227
test_must_fail git merge -s ours C^0 &&
228+
test_path_is_file random_file &&
229+
git rev-parse --verify :random_file &&
204230
test_path_is_missing .git/MERGE_HEAD
205231
'
206232

@@ -211,6 +237,8 @@ test_expect_success 'subtree' '
211237
touch random_file && git add random_file &&
212238
213239
test_must_fail git merge -s subtree E^0 &&
240+
test_path_is_file random_file &&
241+
git rev-parse --verify :random_file &&
214242
test_path_is_missing .git/MERGE_HEAD
215243
'
216244

0 commit comments

Comments
 (0)