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