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
31 test_expect_success 'a/b-2/c/d is kept when clobbering symlink b' '
32 git checkout HEAD^0 &&
33 git reset --hard main &&
34 git rm --cached a/b &&
35 git commit -m "untracked symlink remains" &&
36 git checkout -f start^0 &&
37 test_path_is_file a/b-2/c/d
40 test_expect_success 'checkout should not have deleted a/b-2/c/d' '
41 git checkout HEAD^0 &&
42 git reset --hard main &&
43 git checkout start^0 &&
44 test_path_is_file a/b-2/c/d
47 test_expect_success 'setup for merge test' '
49 test_path_is_file a/b-2/c/d &&
56 test_expect_success 'Handle D/F conflict, do not lose a/b-2/c/d in merge (resolve)' '
58 git checkout baseline^0 &&
59 git merge -s resolve main &&
60 test_path_is_file a/b-2/c/d
63 test_expect_success SYMLINKS 'a/b was resolved as symlink' '
67 test_expect_success 'Handle D/F conflict, do not lose a/b-2/c/d in merge (recursive)' '
69 git checkout baseline^0 &&
70 git merge -s recursive main &&
71 test_path_is_file a/b-2/c/d
74 test_expect_success SYMLINKS 'a/b was resolved as symlink' '
78 test_expect_success 'Handle F/D conflict, do not lose a/b-2/c/d in merge (resolve)' '
80 git checkout main^0 &&
81 git merge -s resolve baseline^0 &&
82 test_path_is_file a/b-2/c/d
85 test_expect_success SYMLINKS 'a/b was resolved as symlink' '
89 test_expect_success 'Handle F/D conflict, do not lose a/b-2/c/d in merge (recursive)' '
91 git checkout main^0 &&
92 git merge -s recursive baseline^0 &&
93 test_path_is_file a/b-2/c/d
96 test_expect_success SYMLINKS 'a/b was resolved as symlink' '
100 test_expect_failure 'do not lose untracked in merge (resolve)' '
102 git checkout baseline^0 &&
104 test_must_fail git merge -s resolve main &&
105 test_path_is_file a/b/c/e &&
106 test_path_is_file a/b-2/c/d
109 test_expect_success 'do not lose untracked in merge (recursive)' '
111 git checkout baseline^0 &&
113 test_must_fail git merge -s recursive main &&
114 test_path_is_file a/b/c/e &&
115 test_path_is_file a/b-2/c/d
118 test_expect_success 'do not lose modifications in merge (resolve)' '
120 git checkout baseline^0 &&
121 echo more content >>a/b/c/d &&
122 test_must_fail git merge -s resolve main
125 test_expect_success 'do not lose modifications in merge (recursive)' '
127 git checkout baseline^0 &&
128 echo more content >>a/b/c/d &&
129 test_must_fail git merge -s recursive main
132 test_expect_success 'setup a merge where dir a/b-2 changed to symlink' '
134 git checkout start^0 &&
137 test_ln_s_add b a/b-2 &&
138 git commit -m "dir a/b-2 to symlink" &&
142 test_expect_success 'merge should not have D/F conflicts (resolve)' '
144 git checkout baseline^0 &&
145 git merge -s resolve test2 &&
146 test_path_is_file a/b/c/d
149 test_expect_success SYMLINKS 'a/b-2 was resolved as symlink' '
153 test_expect_success 'merge should not have D/F conflicts (recursive)' '
155 git checkout baseline^0 &&
156 git merge -s recursive test2 &&
157 test_path_is_file a/b/c/d
160 test_expect_success SYMLINKS 'a/b-2 was resolved as symlink' '
164 test_expect_success 'merge should not have F/D conflicts (recursive)' '
166 git checkout -b foo test2 &&
167 git merge -s recursive baseline^0 &&
168 test_path_is_file a/b/c/d
171 test_expect_success SYMLINKS 'a/b-2 was resolved as symlink' '