oidtree: avoid nested struct oidtree_node
[git/debian.git] / t / t6415-merge-dir-to-symlink.sh
blob2ce104aca7cc2923aa88d191efec2894d12eb86e
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
31 test_expect_success 'a/b-2/c/d is kept when clobbering symlink b' '
32 git checkout HEAD^0 &&
33 git reset --hard main &&
34 git rm --cached a/b &&
35 git commit -m "untracked symlink remains" &&
36 git checkout -f start^0 &&
37 test_path_is_file a/b-2/c/d
40 test_expect_success 'checkout should not have deleted a/b-2/c/d' '
41 git checkout HEAD^0 &&
42 git reset --hard main &&
43 git checkout start^0 &&
44 test_path_is_file a/b-2/c/d
47 test_expect_success 'setup for merge test' '
48 git reset --hard &&
49 test_path_is_file a/b-2/c/d &&
50 echo x > a/x &&
51 git add a/x &&
52 git commit -m x &&
53 git tag baseline
56 test_expect_success 'Handle D/F conflict, do not lose a/b-2/c/d in merge (resolve)' '
57 git reset --hard &&
58 git checkout baseline^0 &&
59 git merge -s resolve main &&
60 test_path_is_file a/b-2/c/d
63 test_expect_success SYMLINKS 'a/b was resolved as symlink' '
64 test -h a/b
67 test_expect_success 'Handle D/F conflict, do not lose a/b-2/c/d in merge (recursive)' '
68 git reset --hard &&
69 git checkout baseline^0 &&
70 git merge -s recursive main &&
71 test_path_is_file a/b-2/c/d
74 test_expect_success SYMLINKS 'a/b was resolved as symlink' '
75 test -h a/b
78 test_expect_success 'Handle F/D conflict, do not lose a/b-2/c/d in merge (resolve)' '
79 git reset --hard &&
80 git checkout main^0 &&
81 git merge -s resolve baseline^0 &&
82 test_path_is_file a/b-2/c/d
85 test_expect_success SYMLINKS 'a/b was resolved as symlink' '
86 test -h a/b
89 test_expect_success 'Handle F/D conflict, do not lose a/b-2/c/d in merge (recursive)' '
90 git reset --hard &&
91 git checkout main^0 &&
92 git merge -s recursive baseline^0 &&
93 test_path_is_file a/b-2/c/d
96 test_expect_success SYMLINKS 'a/b was resolved as symlink' '
97 test -h a/b
100 test_expect_failure 'do not lose untracked in merge (resolve)' '
101 git reset --hard &&
102 git checkout baseline^0 &&
103 >a/b/c/e &&
104 test_must_fail git merge -s resolve main &&
105 test_path_is_file a/b/c/e &&
106 test_path_is_file a/b-2/c/d
109 test_expect_success 'do not lose untracked in merge (recursive)' '
110 git reset --hard &&
111 git checkout baseline^0 &&
112 >a/b/c/e &&
113 test_must_fail git merge -s recursive main &&
114 test_path_is_file a/b/c/e &&
115 test_path_is_file a/b-2/c/d
118 test_expect_success 'do not lose modifications in merge (resolve)' '
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 main
125 test_expect_success 'do not lose modifications in merge (recursive)' '
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 main
132 test_expect_success 'setup a merge where dir a/b-2 changed to symlink' '
133 git reset --hard &&
134 git checkout start^0 &&
135 rm -rf a/b-2 &&
136 git add -A &&
137 test_ln_s_add b a/b-2 &&
138 git commit -m "dir a/b-2 to symlink" &&
139 git tag test2
142 test_expect_success 'merge should not have D/F conflicts (resolve)' '
143 git reset --hard &&
144 git checkout baseline^0 &&
145 git merge -s resolve test2 &&
146 test_path_is_file a/b/c/d
149 test_expect_success SYMLINKS 'a/b-2 was resolved as symlink' '
150 test -h a/b-2
153 test_expect_success 'merge should not have D/F conflicts (recursive)' '
154 git reset --hard &&
155 git checkout baseline^0 &&
156 git merge -s recursive test2 &&
157 test_path_is_file a/b/c/d
160 test_expect_success SYMLINKS 'a/b-2 was resolved as symlink' '
161 test -h a/b-2
164 test_expect_success 'merge should not have F/D conflicts (recursive)' '
165 git reset --hard &&
166 git checkout -b foo test2 &&
167 git merge -s recursive baseline^0 &&
168 test_path_is_file a/b/c/d
171 test_expect_success SYMLINKS 'a/b-2 was resolved as symlink' '
172 test -h a/b-2
175 test_done