3 test_description
='merging when a directory was replaced with a symlink'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
9 test_expect_success
'create a commit where dir a/b changed to symlink' '
10 mkdir -p a/b/c a/b-2/c &&
19 test_ln_s_add b-2 a/b &&
20 git commit -m "dir to symlink"
23 test_expect_success
'checkout does not clobber untracked symlink' '
24 git checkout HEAD^0 &&
25 git reset --hard main &&
26 git rm --cached a/b &&
27 git commit -m "untracked symlink remains" &&
28 test_must_fail git checkout start^0 &&
29 git clean -fd # Do not leave the untracked symlink in the way
32 test_expect_success
'a/b-2/c/d is kept when clobbering symlink b' '
33 git checkout HEAD^0 &&
34 git reset --hard main &&
35 git rm --cached a/b &&
36 git commit -m "untracked symlink remains" &&
37 git checkout -f start^0 &&
38 test_path_is_file a/b-2/c/d &&
39 git clean -fd # Do not leave the untracked symlink in the way
42 test_expect_success
'checkout should not have deleted a/b-2/c/d' '
43 git checkout HEAD^0 &&
44 git reset --hard main &&
45 git checkout start^0 &&
46 test_path_is_file a/b-2/c/d
49 test_expect_success
'setup for merge test' '
51 test_path_is_file a/b-2/c/d &&
58 test_expect_success
'Handle D/F conflict, do not lose a/b-2/c/d in merge (resolve)' '
60 git checkout baseline^0 &&
61 git merge -s resolve main &&
62 test_path_is_file a/b-2/c/d
65 test_expect_success SYMLINKS
'a/b was resolved as symlink' '
69 test_expect_success
'Handle D/F conflict, do not lose a/b-2/c/d in merge (recursive)' '
71 git checkout baseline^0 &&
72 git merge -s recursive main &&
73 test_path_is_file a/b-2/c/d
76 test_expect_success SYMLINKS
'a/b was resolved as symlink' '
80 test_expect_success
'Handle F/D conflict, do not lose a/b-2/c/d in merge (resolve)' '
82 git checkout main^0 &&
83 git merge -s resolve baseline^0 &&
84 test_path_is_file a/b-2/c/d
87 test_expect_success SYMLINKS
'a/b was resolved as symlink' '
91 test_expect_success
'Handle F/D conflict, do not lose a/b-2/c/d in merge (recursive)' '
93 git checkout main^0 &&
94 git merge -s recursive baseline^0 &&
95 test_path_is_file a/b-2/c/d
98 test_expect_success SYMLINKS
'a/b was resolved as symlink' '
102 test_expect_failure
'do not lose untracked in merge (resolve)' '
104 git checkout baseline^0 &&
106 test_must_fail git merge -s resolve main &&
107 test_path_is_file a/b/c/e &&
108 test_path_is_file a/b-2/c/d
111 test_expect_success
'do not lose untracked in merge (recursive)' '
113 git checkout baseline^0 &&
115 test_must_fail git merge -s recursive main &&
116 test_path_is_file a/b/c/e &&
117 test_path_is_file a/b-2/c/d
120 test_expect_success
'do not lose modifications in merge (resolve)' '
122 git checkout baseline^0 &&
123 echo more content >>a/b/c/d &&
124 test_must_fail git merge -s resolve main
127 test_expect_success
'do not lose modifications in merge (recursive)' '
129 git checkout baseline^0 &&
130 echo more content >>a/b/c/d &&
131 test_must_fail git merge -s recursive main
134 test_expect_success
'setup a merge where dir a/b-2 changed to symlink' '
136 git checkout start^0 &&
139 test_ln_s_add b a/b-2 &&
140 git commit -m "dir a/b-2 to symlink" &&
144 test_expect_success
'merge should not have D/F conflicts (resolve)' '
146 git checkout baseline^0 &&
147 git merge -s resolve test2 &&
148 test_path_is_file a/b/c/d
151 test_expect_success SYMLINKS
'a/b-2 was resolved as symlink' '
155 test_expect_success
'merge should not have D/F conflicts (recursive)' '
157 git checkout baseline^0 &&
158 git merge -s recursive test2 &&
159 test_path_is_file a/b/c/d
162 test_expect_success SYMLINKS
'a/b-2 was resolved as symlink' '
166 test_expect_success
'merge should not have F/D conflicts (recursive)' '
168 git checkout -b foo test2 &&
169 git merge -s recursive baseline^0 &&
170 test_path_is_file a/b/c/d
173 test_expect_success SYMLINKS
'a/b-2 was resolved as symlink' '