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