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