Skip to content

Commit 175659b

Browse files
Clemens Buchachergitster
authored andcommitted
t7607: add leading-path tests
Signed-off-by: Clemens Buchacher <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 18a1d89 commit 175659b

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

t/t7607-merge-overwrite.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ test_expect_success 'setup' '
1212
test_commit c1a c1.c "c1 a" &&
1313
git reset --hard c0 &&
1414
test_commit c2 c2.c &&
15+
git reset --hard c0 &&
16+
mkdir sub &&
17+
echo "sub/f" > sub/f &&
18+
git add sub/f &&
19+
git commit -m sub &&
20+
git tag sub &&
1521
echo "VERY IMPORTANT CHANGES" > important
1622
'
1723

@@ -23,6 +29,14 @@ test_expect_success 'will not overwrite untracked file' '
2329
test_cmp important c2.c
2430
'
2531

32+
test_expect_success 'will overwrite tracked file' '
33+
git reset --hard c1 &&
34+
cp important c2.c &&
35+
git add c2.c &&
36+
git commit -m important &&
37+
git checkout c2
38+
'
39+
2640
test_expect_success 'will not overwrite new file' '
2741
git reset --hard c1 &&
2842
cp important c2.c &&
@@ -76,6 +90,43 @@ test_expect_success 'will not overwrite removed file with staged changes' '
7690
test_cmp important c1.c
7791
'
7892

93+
test_expect_success 'will not overwrite untracked subtree' '
94+
git reset --hard c0 &&
95+
rm -rf sub &&
96+
mkdir -p sub/f &&
97+
cp important sub/f/important &&
98+
test_must_fail git merge sub &&
99+
test_path_is_missing .git/MERGE_HEAD &&
100+
test_cmp important sub/f/important
101+
'
102+
103+
test_expect_failure 'will not overwrite untracked file in leading path' '
104+
git reset --hard c0 &&
105+
rm -rf sub &&
106+
cp important sub &&
107+
test_must_fail git merge sub &&
108+
test_path_is_missing .git/MERGE_HEAD &&
109+
test_cmp important sub
110+
'
111+
112+
test_expect_failure SYMLINKS 'will not overwrite untracked symlink in leading path' '
113+
git reset --hard c0 &&
114+
rm -rf sub &&
115+
mkdir sub2 &&
116+
ln -s sub2 sub &&
117+
test_must_fail git merge sub &&
118+
test_path_is_missing .git/MERGE_HEAD
119+
'
120+
121+
test_expect_success SYMLINKS 'will not be confused by symlink in leading path' '
122+
git reset --hard c0 &&
123+
rm -rf sub &&
124+
ln -s sub2 sub &&
125+
git add sub &&
126+
git commit -m ln &&
127+
git checkout sub
128+
'
129+
79130
cat >expect <<\EOF
80131
error: Untracked working tree file 'c0.c' would be overwritten by merge.
81132
fatal: read-tree failed

0 commit comments

Comments
 (0)