3 test_description
='git-merge
5 Do not overwrite changes.'
9 test_expect_success
'setup' '
10 test_commit c0 c0.c &&
11 test_commit c1 c1.c &&
12 test_commit c1a c1.c "c1 a" &&
13 git reset --hard c0 &&
14 test_commit c2 c2.c &&
15 git reset --hard c0 &&
17 echo "sub/f" > sub/f &&
21 echo "VERY IMPORTANT CHANGES" > important
24 test_expect_success
'will not overwrite untracked file' '
25 git reset --hard c1 &&
27 test_must_fail git merge c2 &&
28 test_path_is_missing .git/MERGE_HEAD &&
29 test_cmp important c2.c
32 test_expect_success
'will overwrite tracked file' '
33 git reset --hard c1 &&
36 git commit -m important &&
40 test_expect_success
'will not overwrite new file' '
41 git reset --hard c1 &&
44 test_must_fail git merge c2 &&
45 test_path_is_missing .git/MERGE_HEAD &&
46 test_cmp important c2.c
49 test_expect_success
'will not overwrite staged changes' '
50 git reset --hard c1 &&
54 test_must_fail git merge c2 &&
55 test_path_is_missing .git/MERGE_HEAD &&
57 test_cmp important c2.c
60 test_expect_success
'will not overwrite removed file' '
61 git reset --hard c1 &&
63 git commit -m "rm c1.c" &&
65 test_must_fail git merge c1a &&
66 test_cmp important c1.c
69 test_expect_success
'will not overwrite re-added file' '
70 git reset --hard c1 &&
72 git commit -m "rm c1.c" &&
75 test_must_fail git merge c1a &&
76 test_path_is_missing .git/MERGE_HEAD &&
77 test_cmp important c1.c
80 test_expect_success
'will not overwrite removed file with staged changes' '
81 git reset --hard c1 &&
83 git commit -m "rm c1.c" &&
87 test_must_fail git merge c1a &&
88 test_path_is_missing .git/MERGE_HEAD &&
90 test_cmp important c1.c
93 test_expect_success
'will not overwrite untracked subtree' '
94 git reset --hard c0 &&
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
103 test_expect_success
'will not overwrite untracked file in leading path' '
104 git reset --hard c0 &&
107 test_must_fail git merge sub &&
108 test_path_is_missing .git/MERGE_HEAD &&
109 test_cmp important sub
112 test_expect_failure SYMLINKS
'will not overwrite untracked symlink in leading path' '
113 git reset --hard c0 &&
117 test_must_fail git merge sub &&
118 test_path_is_missing .git/MERGE_HEAD
121 test_expect_success SYMLINKS
'will not be confused by symlink in leading path' '
122 git reset --hard c0 &&