]>
Commit | Line | Data |
---|---|---|
4f6339b0 PJ |
1 | #!/bin/sh |
2 | ||
3 | test_description='merging when a directory was replaced with a symlink' | |
5902f5f4 | 4 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
5 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
6 | ||
e5e37517 | 7 | TEST_PASSES_SANITIZE_LEAK=true |
4f6339b0 PJ |
8 | . ./test-lib.sh |
9 | ||
bfd7804e | 10 | test_expect_success 'create a commit where dir a/b changed to symlink' ' |
4f6339b0 PJ |
11 | mkdir -p a/b/c a/b-2/c && |
12 | > a/b/c/d && | |
13 | > a/b-2/c/d && | |
14 | > a/x && | |
15 | git add -A && | |
16 | git commit -m base && | |
17 | git tag start && | |
18 | rm -rf a/b && | |
4f6339b0 | 19 | git add -A && |
bfd7804e | 20 | test_ln_s_add b-2 a/b && |
4f6339b0 PJ |
21 | git commit -m "dir to symlink" |
22 | ' | |
23 | ||
bfd7804e | 24 | test_expect_success 'checkout does not clobber untracked symlink' ' |
4f6339b0 | 25 | git checkout HEAD^0 && |
5902f5f4 | 26 | git reset --hard main && |
4f6339b0 PJ |
27 | git rm --cached a/b && |
28 | git commit -m "untracked symlink remains" && | |
f222bd34 EN |
29 | test_must_fail git checkout start^0 && |
30 | git clean -fd # Do not leave the untracked symlink in the way | |
1d718a51 CB |
31 | ' |
32 | ||
bfd7804e | 33 | test_expect_success 'a/b-2/c/d is kept when clobbering symlink b' ' |
1d718a51 | 34 | git checkout HEAD^0 && |
5902f5f4 | 35 | git reset --hard main && |
1d718a51 CB |
36 | git rm --cached a/b && |
37 | git commit -m "untracked symlink remains" && | |
38 | git checkout -f start^0 && | |
f222bd34 EN |
39 | test_path_is_file a/b-2/c/d && |
40 | git clean -fd # Do not leave the untracked symlink in the way | |
4f6339b0 PJ |
41 | ' |
42 | ||
bfd7804e | 43 | test_expect_success 'checkout should not have deleted a/b-2/c/d' ' |
4f6339b0 | 44 | git checkout HEAD^0 && |
5902f5f4 | 45 | git reset --hard main && |
4f6339b0 | 46 | git checkout start^0 && |
b821ca78 | 47 | test_path_is_file a/b-2/c/d |
4f6339b0 PJ |
48 | ' |
49 | ||
bfd7804e | 50 | test_expect_success 'setup for merge test' ' |
4f6339b0 | 51 | git reset --hard && |
b821ca78 | 52 | test_path_is_file a/b-2/c/d && |
4f6339b0 PJ |
53 | echo x > a/x && |
54 | git add a/x && | |
55 | git commit -m x && | |
56 | git tag baseline | |
57 | ' | |
58 | ||
bfd7804e | 59 | test_expect_success 'Handle D/F conflict, do not lose a/b-2/c/d in merge (resolve)' ' |
4f6339b0 PJ |
60 | git reset --hard && |
61 | git checkout baseline^0 && | |
5902f5f4 | 62 | git merge -s resolve main && |
b821ca78 | 63 | test_path_is_file a/b-2/c/d |
4f6339b0 PJ |
64 | ' |
65 | ||
bfd7804e JS |
66 | test_expect_success SYMLINKS 'a/b was resolved as symlink' ' |
67 | test -h a/b | |
68 | ' | |
69 | ||
70 | test_expect_success 'Handle D/F conflict, do not lose a/b-2/c/d in merge (recursive)' ' | |
4f6339b0 PJ |
71 | git reset --hard && |
72 | git checkout baseline^0 && | |
5902f5f4 | 73 | git merge -s recursive main && |
b821ca78 | 74 | test_path_is_file a/b-2/c/d |
4f6339b0 PJ |
75 | ' |
76 | ||
bfd7804e JS |
77 | test_expect_success SYMLINKS 'a/b was resolved as symlink' ' |
78 | test -h a/b | |
79 | ' | |
80 | ||
81 | test_expect_success 'Handle F/D conflict, do not lose a/b-2/c/d in merge (resolve)' ' | |
f15652d9 | 82 | git reset --hard && |
5902f5f4 | 83 | git checkout main^0 && |
f15652d9 | 84 | git merge -s resolve baseline^0 && |
b821ca78 | 85 | test_path_is_file a/b-2/c/d |
f15652d9 EN |
86 | ' |
87 | ||
bfd7804e JS |
88 | test_expect_success SYMLINKS 'a/b was resolved as symlink' ' |
89 | test -h a/b | |
90 | ' | |
91 | ||
92 | test_expect_success 'Handle F/D conflict, do not lose a/b-2/c/d in merge (recursive)' ' | |
f15652d9 | 93 | git reset --hard && |
5902f5f4 | 94 | git checkout main^0 && |
f15652d9 | 95 | git merge -s recursive baseline^0 && |
b821ca78 | 96 | test_path_is_file a/b-2/c/d |
f15652d9 EN |
97 | ' |
98 | ||
bfd7804e JS |
99 | test_expect_success SYMLINKS 'a/b was resolved as symlink' ' |
100 | test -h a/b | |
101 | ' | |
102 | ||
103 | test_expect_failure 'do not lose untracked in merge (resolve)' ' | |
f15652d9 EN |
104 | git reset --hard && |
105 | git checkout baseline^0 && | |
106 | >a/b/c/e && | |
5902f5f4 | 107 | test_must_fail git merge -s resolve main && |
b821ca78 EN |
108 | test_path_is_file a/b/c/e && |
109 | test_path_is_file a/b-2/c/d | |
f15652d9 EN |
110 | ' |
111 | ||
bfd7804e | 112 | test_expect_success 'do not lose untracked in merge (recursive)' ' |
f15652d9 EN |
113 | git reset --hard && |
114 | git checkout baseline^0 && | |
115 | >a/b/c/e && | |
5902f5f4 | 116 | test_must_fail git merge -s recursive main && |
b821ca78 EN |
117 | test_path_is_file a/b/c/e && |
118 | test_path_is_file a/b-2/c/d | |
f15652d9 EN |
119 | ' |
120 | ||
bfd7804e | 121 | test_expect_success 'do not lose modifications in merge (resolve)' ' |
f15652d9 EN |
122 | git reset --hard && |
123 | git checkout baseline^0 && | |
124 | echo more content >>a/b/c/d && | |
5902f5f4 | 125 | test_must_fail git merge -s resolve main |
f15652d9 EN |
126 | ' |
127 | ||
bfd7804e | 128 | test_expect_success 'do not lose modifications in merge (recursive)' ' |
f15652d9 EN |
129 | git reset --hard && |
130 | git checkout baseline^0 && | |
131 | echo more content >>a/b/c/d && | |
5902f5f4 | 132 | test_must_fail git merge -s recursive main |
f15652d9 EN |
133 | ' |
134 | ||
bfd7804e | 135 | test_expect_success 'setup a merge where dir a/b-2 changed to symlink' ' |
4f6339b0 PJ |
136 | git reset --hard && |
137 | git checkout start^0 && | |
138 | rm -rf a/b-2 && | |
4f6339b0 | 139 | git add -A && |
bfd7804e | 140 | test_ln_s_add b a/b-2 && |
4f6339b0 PJ |
141 | git commit -m "dir a/b-2 to symlink" && |
142 | git tag test2 | |
143 | ' | |
144 | ||
bfd7804e | 145 | test_expect_success 'merge should not have D/F conflicts (resolve)' ' |
4f6339b0 PJ |
146 | git reset --hard && |
147 | git checkout baseline^0 && | |
148 | git merge -s resolve test2 && | |
b821ca78 | 149 | test_path_is_file a/b/c/d |
4f6339b0 PJ |
150 | ' |
151 | ||
bfd7804e JS |
152 | test_expect_success SYMLINKS 'a/b-2 was resolved as symlink' ' |
153 | test -h a/b-2 | |
154 | ' | |
155 | ||
156 | test_expect_success 'merge should not have D/F conflicts (recursive)' ' | |
4f6339b0 PJ |
157 | git reset --hard && |
158 | git checkout baseline^0 && | |
159 | git merge -s recursive test2 && | |
b821ca78 | 160 | test_path_is_file a/b/c/d |
4f6339b0 PJ |
161 | ' |
162 | ||
bfd7804e JS |
163 | test_expect_success SYMLINKS 'a/b-2 was resolved as symlink' ' |
164 | test -h a/b-2 | |
165 | ' | |
166 | ||
167 | test_expect_success 'merge should not have F/D conflicts (recursive)' ' | |
f15652d9 EN |
168 | git reset --hard && |
169 | git checkout -b foo test2 && | |
170 | git merge -s recursive baseline^0 && | |
b821ca78 | 171 | test_path_is_file a/b/c/d |
f15652d9 EN |
172 | ' |
173 | ||
bfd7804e JS |
174 | test_expect_success SYMLINKS 'a/b-2 was resolved as symlink' ' |
175 | test -h a/b-2 | |
176 | ' | |
177 | ||
4f6339b0 | 178 | test_done |