Skip to content

Commit 18a1d89

Browse files
Clemens Buchachergitster
authored andcommitted
t7607: use test-lib functions and check MERGE_HEAD
Use the test_commit and test_path_is_missing functions from the test library. Also make sure that a merge which fails due to pre-merge checks aborts properly and does not leave MERGE_HEAD behind. The "will not overwrite removed file" test is an exception to this. It notices the untracked file at a stage where the merge is already well under way. Therefore we cannot abort the merge without major restructuring. See the following thread for more details. http://mid.gmane.org/[email protected] Signed-off-by: Clemens Buchacher <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 40d675f commit 18a1d89

File tree

1 file changed

+15
-23
lines changed

1 file changed

+15
-23
lines changed

t/t7607-merge-overwrite.sh

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,38 @@ Do not overwrite changes.'
77
. ./test-lib.sh
88

99
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 &&
10+
test_commit c0 c0.c &&
11+
test_commit c1 c1.c &&
12+
test_commit c1a c1.c "c1 a" &&
1813
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 c1 &&
24-
echo "c1 a" > c1.c &&
25-
git add c1.c &&
26-
git commit -m "c1 a" &&
27-
git tag c1a &&
14+
test_commit c2 c2.c &&
2815
echo "VERY IMPORTANT CHANGES" > important
2916
'
3017

3118
test_expect_success 'will not overwrite untracked file' '
3219
git reset --hard c1 &&
33-
cat important > c2.c &&
20+
cp important c2.c &&
3421
test_must_fail git merge c2 &&
22+
test_path_is_missing .git/MERGE_HEAD &&
3523
test_cmp important c2.c
3624
'
3725

3826
test_expect_success 'will not overwrite new file' '
3927
git reset --hard c1 &&
40-
cat important > c2.c &&
28+
cp important c2.c &&
4129
git add c2.c &&
4230
test_must_fail git merge c2 &&
31+
test_path_is_missing .git/MERGE_HEAD &&
4332
test_cmp important c2.c
4433
'
4534

4635
test_expect_success 'will not overwrite staged changes' '
4736
git reset --hard c1 &&
48-
cat important > c2.c &&
37+
cp important c2.c &&
4938
git add c2.c &&
5039
rm c2.c &&
5140
test_must_fail git merge c2 &&
41+
test_path_is_missing .git/MERGE_HEAD &&
5242
git checkout c2.c &&
5343
test_cmp important c2.c
5444
'
@@ -57,7 +47,7 @@ test_expect_success 'will not overwrite removed file' '
5747
git reset --hard c1 &&
5848
git rm c1.c &&
5949
git commit -m "rm c1.c" &&
60-
cat important > c1.c &&
50+
cp important c1.c &&
6151
test_must_fail git merge c1a &&
6252
test_cmp important c1.c
6353
'
@@ -66,20 +56,22 @@ test_expect_success 'will not overwrite re-added file' '
6656
git reset --hard c1 &&
6757
git rm c1.c &&
6858
git commit -m "rm c1.c" &&
69-
cat important > c1.c &&
59+
cp important c1.c &&
7060
git add c1.c &&
7161
test_must_fail git merge c1a &&
62+
test_path_is_missing .git/MERGE_HEAD &&
7263
test_cmp important c1.c
7364
'
7465

7566
test_expect_success 'will not overwrite removed file with staged changes' '
7667
git reset --hard c1 &&
7768
git rm c1.c &&
7869
git commit -m "rm c1.c" &&
79-
cat important > c1.c &&
70+
cp important c1.c &&
8071
git add c1.c &&
8172
rm c1.c &&
8273
test_must_fail git merge c1a &&
74+
test_path_is_missing .git/MERGE_HEAD &&
8375
git checkout c1.c &&
8476
test_cmp important c1.c
8577
'

0 commit comments

Comments
 (0)