rebase: use correct base for --keep-base when a branch is given
[alt-git.git] / t / t6415-merge-dir-to-symlink.sh
blob2655e295f5ae4536eaf86dcf95e8062f61cc2948
1 #!/bin/sh
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
7 . ./test-lib.sh
9 test_expect_success 'create a commit where dir a/b changed to symlink' '
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 &&
18 git add -A &&
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 &&
29 git clean -fd # Do not leave the untracked symlink in the way
32 test_expect_success 'a/b-2/c/d is kept when clobbering symlink b' '
33 git checkout HEAD^0 &&
34 git reset --hard main &&
35 git rm --cached a/b &&
36 git commit -m "untracked symlink remains" &&
37 git checkout -f start^0 &&
38 test_path_is_file a/b-2/c/d &&
39 git clean -fd # Do not leave the untracked symlink in the way
42 test_expect_success 'checkout should not have deleted a/b-2/c/d' '
43 git checkout HEAD^0 &&
44 git reset --hard main &&
45 git checkout start^0 &&
46 test_path_is_file a/b-2/c/d
49 test_expect_success 'setup for merge test' '
50 git reset --hard &&
51 test_path_is_file a/b-2/c/d &&
52 echo x > a/x &&
53 git add a/x &&
54 git commit -m x &&
55 git tag baseline
58 test_expect_success 'Handle D/F conflict, do not lose a/b-2/c/d in merge (resolve)' '
59 git reset --hard &&
60 git checkout baseline^0 &&
61 git merge -s resolve main &&
62 test_path_is_file a/b-2/c/d
65 test_expect_success SYMLINKS 'a/b was resolved as symlink' '
66 test -h a/b
69 test_expect_success 'Handle D/F conflict, do not lose a/b-2/c/d in merge (recursive)' '
70 git reset --hard &&
71 git checkout baseline^0 &&
72 git merge -s recursive main &&
73 test_path_is_file a/b-2/c/d
76 test_expect_success SYMLINKS 'a/b was resolved as symlink' '
77 test -h a/b
80 test_expect_success 'Handle F/D conflict, do not lose a/b-2/c/d in merge (resolve)' '
81 git reset --hard &&
82 git checkout main^0 &&
83 git merge -s resolve baseline^0 &&
84 test_path_is_file a/b-2/c/d
87 test_expect_success SYMLINKS 'a/b was resolved as symlink' '
88 test -h a/b
91 test_expect_success 'Handle F/D conflict, do not lose a/b-2/c/d in merge (recursive)' '
92 git reset --hard &&
93 git checkout main^0 &&
94 git merge -s recursive baseline^0 &&
95 test_path_is_file a/b-2/c/d
98 test_expect_success SYMLINKS 'a/b was resolved as symlink' '
99 test -h a/b
102 test_expect_failure 'do not lose untracked in merge (resolve)' '
103 git reset --hard &&
104 git checkout baseline^0 &&
105 >a/b/c/e &&
106 test_must_fail git merge -s resolve main &&
107 test_path_is_file a/b/c/e &&
108 test_path_is_file a/b-2/c/d
111 test_expect_success 'do not lose untracked in merge (recursive)' '
112 git reset --hard &&
113 git checkout baseline^0 &&
114 >a/b/c/e &&
115 test_must_fail git merge -s recursive main &&
116 test_path_is_file a/b/c/e &&
117 test_path_is_file a/b-2/c/d
120 test_expect_success 'do not lose modifications in merge (resolve)' '
121 git reset --hard &&
122 git checkout baseline^0 &&
123 echo more content >>a/b/c/d &&
124 test_must_fail git merge -s resolve main
127 test_expect_success 'do not lose modifications in merge (recursive)' '
128 git reset --hard &&
129 git checkout baseline^0 &&
130 echo more content >>a/b/c/d &&
131 test_must_fail git merge -s recursive main
134 test_expect_success 'setup a merge where dir a/b-2 changed to symlink' '
135 git reset --hard &&
136 git checkout start^0 &&
137 rm -rf a/b-2 &&
138 git add -A &&
139 test_ln_s_add b a/b-2 &&
140 git commit -m "dir a/b-2 to symlink" &&
141 git tag test2
144 test_expect_success 'merge should not have D/F conflicts (resolve)' '
145 git reset --hard &&
146 git checkout baseline^0 &&
147 git merge -s resolve test2 &&
148 test_path_is_file a/b/c/d
151 test_expect_success SYMLINKS 'a/b-2 was resolved as symlink' '
152 test -h a/b-2
155 test_expect_success 'merge should not have D/F conflicts (recursive)' '
156 git reset --hard &&
157 git checkout baseline^0 &&
158 git merge -s recursive test2 &&
159 test_path_is_file a/b/c/d
162 test_expect_success SYMLINKS 'a/b-2 was resolved as symlink' '
163 test -h a/b-2
166 test_expect_success 'merge should not have F/D conflicts (recursive)' '
167 git reset --hard &&
168 git checkout -b foo test2 &&
169 git merge -s recursive baseline^0 &&
170 test_path_is_file a/b/c/d
173 test_expect_success SYMLINKS 'a/b-2 was resolved as symlink' '
174 test -h a/b-2
177 test_done