]>
Commit | Line | Data |
---|---|---|
72d1216a FK |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Fredrik Kuivinen | |
4 | # | |
5 | ||
6 | test_description='Test merge with directory/file conflicts' | |
5902f5f4 | 7 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
8 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
9 | ||
72d1216a FK |
10 | . ./test-lib.sh |
11 | ||
d09c0a39 EN |
12 | test_expect_success 'prepare repository' ' |
13 | echo Hello >init && | |
14 | git add init && | |
15 | git commit -m initial && | |
16 | ||
17 | git branch B && | |
18 | mkdir dir && | |
19 | echo foo >dir/foo && | |
20 | git add dir/foo && | |
21 | git commit -m "File: dir/foo" && | |
22 | ||
23 | git checkout B && | |
24 | echo file dir >dir && | |
25 | git add dir && | |
26 | git commit -m "File: dir" | |
27 | ' | |
72d1216a | 28 | |
892e6f7e | 29 | test_expect_success 'Merge with d/f conflicts' ' |
5902f5f4 | 30 | test_expect_code 1 git merge -m "merge msg" main |
892e6f7e | 31 | ' |
72d1216a | 32 | |
5a2580d6 | 33 | test_expect_success 'F/D conflict' ' |
1c9b2d3a | 34 | git reset --hard && |
5902f5f4 | 35 | git checkout main && |
1c9b2d3a AR |
36 | rm .git/index && |
37 | ||
38 | mkdir before && | |
39 | echo FILE >before/one && | |
40 | echo FILE >after && | |
41 | git add . && | |
42 | git commit -m first && | |
43 | ||
44 | rm -f after && | |
45 | git mv before after && | |
46 | git commit -m move && | |
47 | ||
48 | git checkout -b para HEAD^ && | |
49 | echo COMPLETELY ANOTHER FILE >another && | |
50 | git add . && | |
51 | git commit -m para && | |
52 | ||
5902f5f4 | 53 | git merge main |
1c9b2d3a AR |
54 | ' |
55 | ||
fa0ae3b1 EN |
56 | test_expect_success 'setup modify/delete + directory/file conflict' ' |
57 | git checkout --orphan modify && | |
58 | git rm -rf . && | |
59 | git clean -fdqx && | |
60 | ||
61 | printf "a\nb\nc\nd\ne\nf\ng\nh\n" >letters && | |
62 | git add letters && | |
63 | git commit -m initial && | |
64 | ||
f0fd4d05 EN |
65 | # Throw in letters.txt for sorting order fun |
66 | # ("letters.txt" sorts between "letters" and "letters/file") | |
fa0ae3b1 | 67 | echo i >>letters && |
f0fd4d05 EN |
68 | echo "version 2" >letters.txt && |
69 | git add letters letters.txt && | |
fa0ae3b1 EN |
70 | git commit -m modified && |
71 | ||
72 | git checkout -b delete HEAD^ && | |
73 | git rm letters && | |
74 | mkdir letters && | |
75 | >letters/file && | |
f0fd4d05 EN |
76 | echo "version 1" >letters.txt && |
77 | git add letters letters.txt && | |
fa0ae3b1 EN |
78 | git commit -m deleted |
79 | ' | |
80 | ||
84a08a47 | 81 | test_expect_success 'modify/delete + directory/file conflict' ' |
fa0ae3b1 EN |
82 | git checkout delete^0 && |
83 | test_must_fail git merge modify && | |
84 | ||
66c95620 ĐTCD |
85 | test_stdout_line_count = 5 git ls-files -s && |
86 | test_stdout_line_count = 4 git ls-files -u && | |
ef527787 EN |
87 | if test "$GIT_TEST_MERGE_ALGORITHM" = ort |
88 | then | |
66c95620 | 89 | test_stdout_line_count = 0 git ls-files -o |
ef527787 | 90 | else |
66c95620 | 91 | test_stdout_line_count = 1 git ls-files -o |
ef527787 | 92 | fi && |
fa0ae3b1 | 93 | |
b821ca78 EN |
94 | test_path_is_file letters/file && |
95 | test_path_is_file letters.txt && | |
96 | test_path_is_file letters~modify | |
fa0ae3b1 EN |
97 | ' |
98 | ||
ef02b317 | 99 | test_expect_success 'modify/delete + directory/file conflict; other way' ' |
fa0ae3b1 EN |
100 | git reset --hard && |
101 | git clean -f && | |
102 | git checkout modify^0 && | |
f0fd4d05 | 103 | |
fa0ae3b1 EN |
104 | test_must_fail git merge delete && |
105 | ||
66c95620 ĐTCD |
106 | test_stdout_line_count = 5 git ls-files -s && |
107 | test_stdout_line_count = 4 git ls-files -u && | |
ef527787 EN |
108 | if test "$GIT_TEST_MERGE_ALGORITHM" = ort |
109 | then | |
66c95620 | 110 | test_stdout_line_count = 0 git ls-files -o |
ef527787 | 111 | else |
66c95620 | 112 | test_stdout_line_count = 1 git ls-files -o |
ef527787 | 113 | fi && |
fa0ae3b1 | 114 | |
b821ca78 EN |
115 | test_path_is_file letters/file && |
116 | test_path_is_file letters.txt && | |
117 | test_path_is_file letters~HEAD | |
fa0ae3b1 EN |
118 | ' |
119 | ||
65bf820d EN |
120 | test_expect_success 'Simple merge in repo with interesting pathnames' ' |
121 | # Simple lexicographic ordering of files and directories would be: | |
122 | # foo | |
123 | # foo/bar | |
124 | # foo/bar-2 | |
125 | # foo/bar/baz | |
126 | # foo/bar-2/baz | |
127 | # The fact that foo/bar-2 appears between foo/bar and foo/bar/baz | |
128 | # can trip up some codepaths, and is the point of this test. | |
6693fb3f | 129 | git init name-ordering && |
65bf820d EN |
130 | ( |
131 | cd name-ordering && | |
132 | ||
133 | mkdir -p foo/bar && | |
134 | mkdir -p foo/bar-2 && | |
135 | >foo/bar/baz && | |
136 | >foo/bar-2/baz && | |
137 | git add . && | |
138 | git commit -m initial && | |
139 | ||
538228ed | 140 | git branch topic && |
65bf820d EN |
141 | git branch other && |
142 | ||
143 | git checkout other && | |
144 | echo other >foo/bar-2/baz && | |
145 | git add -u && | |
146 | git commit -m other && | |
147 | ||
538228ed JS |
148 | git checkout topic && |
149 | echo topic >foo/bar/baz && | |
65bf820d | 150 | git add -u && |
538228ed | 151 | git commit -m topic && |
65bf820d EN |
152 | |
153 | git merge other && | |
154 | git ls-files -s >out && | |
155 | test_line_count = 2 out && | |
156 | git rev-parse :0:foo/bar/baz :0:foo/bar-2/baz >actual && | |
157 | git rev-parse HEAD~1:foo/bar/baz other:foo/bar-2/baz >expect && | |
158 | test_cmp expect actual | |
159 | ) | |
160 | ||
161 | ' | |
162 | ||
72d1216a | 163 | test_done |