Merge branch 'nd/maint-fix-replace'
[git/jnareb-git.git] / t / t6035-merge-dir-to-symlink.sh
blobdc09513be5a78bf12139efd931ee0344b2710764
1 #!/bin/sh
3 test_description='merging when a directory was replaced with a symlink'
4 . ./test-lib.sh
6 if ! test_have_prereq SYMLINKS
7 then
8 skip_all='Symbolic links not supported, skipping tests.'
9 test_done
12 test_expect_success 'create a commit where dir a/b changed to symlink' '
13 mkdir -p a/b/c a/b-2/c &&
14 > a/b/c/d &&
15 > a/b-2/c/d &&
16 > a/x &&
17 git add -A &&
18 git commit -m base &&
19 git tag start &&
20 rm -rf a/b &&
21 ln -s b-2 a/b &&
22 git add -A &&
23 git commit -m "dir to symlink"
26 test_expect_success 'keep a/b-2/c/d across checkout' '
27 git checkout HEAD^0 &&
28 git reset --hard master &&
29 git rm --cached a/b &&
30 git commit -m "untracked symlink remains" &&
31 git checkout start^0 &&
32 test -f a/b-2/c/d
35 test_expect_success 'checkout should not have deleted a/b-2/c/d' '
36 git checkout HEAD^0 &&
37 git reset --hard master &&
38 git checkout start^0 &&
39 test -f a/b-2/c/d
42 test_expect_success 'setup for merge test' '
43 git reset --hard &&
44 test -f a/b-2/c/d &&
45 echo x > a/x &&
46 git add a/x &&
47 git commit -m x &&
48 git tag baseline
51 test_expect_success 'Handle D/F conflict, do not lose a/b-2/c/d in merge (resolve)' '
52 git reset --hard &&
53 git checkout baseline^0 &&
54 git merge -s resolve master &&
55 test -h a/b &&
56 test -f a/b-2/c/d
59 test_expect_success 'Handle D/F conflict, do not lose a/b-2/c/d in merge (recursive)' '
60 git reset --hard &&
61 git checkout baseline^0 &&
62 git merge -s recursive master &&
63 test -h a/b &&
64 test -f a/b-2/c/d
67 test_expect_success 'Handle F/D conflict, do not lose a/b-2/c/d in merge (resolve)' '
68 git reset --hard &&
69 git checkout master^0 &&
70 git merge -s resolve baseline^0 &&
71 test -h a/b &&
72 test -f a/b-2/c/d
75 test_expect_success 'Handle F/D conflict, do not lose a/b-2/c/d in merge (recursive)' '
76 git reset --hard &&
77 git checkout master^0 &&
78 git merge -s recursive baseline^0 &&
79 test -h a/b &&
80 test -f a/b-2/c/d
83 test_expect_failure 'do not lose untracked in merge (resolve)' '
84 git reset --hard &&
85 git checkout baseline^0 &&
86 >a/b/c/e &&
87 test_must_fail git merge -s resolve master &&
88 test -f a/b/c/e &&
89 test -f a/b-2/c/d
92 test_expect_success 'do not lose untracked in merge (recursive)' '
93 git reset --hard &&
94 git checkout baseline^0 &&
95 >a/b/c/e &&
96 test_must_fail git merge -s recursive master &&
97 test -f a/b/c/e &&
98 test -f a/b-2/c/d
101 test_expect_success 'do not lose modifications in merge (resolve)' '
102 git reset --hard &&
103 git checkout baseline^0 &&
104 echo more content >>a/b/c/d &&
105 test_must_fail git merge -s resolve master
108 test_expect_success 'do not lose modifications in merge (recursive)' '
109 git reset --hard &&
110 git checkout baseline^0 &&
111 echo more content >>a/b/c/d &&
112 test_must_fail git merge -s recursive master
115 test_expect_success 'setup a merge where dir a/b-2 changed to symlink' '
116 git reset --hard &&
117 git checkout start^0 &&
118 rm -rf a/b-2 &&
119 ln -s b a/b-2 &&
120 git add -A &&
121 git commit -m "dir a/b-2 to symlink" &&
122 git tag test2
125 test_expect_success 'merge should not have D/F conflicts (resolve)' '
126 git reset --hard &&
127 git checkout baseline^0 &&
128 git merge -s resolve test2 &&
129 test -h a/b-2 &&
130 test -f a/b/c/d
133 test_expect_success 'merge should not have D/F conflicts (recursive)' '
134 git reset --hard &&
135 git checkout baseline^0 &&
136 git merge -s recursive test2 &&
137 test -h a/b-2 &&
138 test -f a/b/c/d
141 test_expect_success 'merge should not have F/D conflicts (recursive)' '
142 git reset --hard &&
143 git checkout -b foo test2 &&
144 git merge -s recursive baseline^0 &&
145 test -h a/b-2 &&
146 test -f a/b/c/d
149 test_done