3 # Copyright (c) 2005 Fredrik Kuivinen
6 test_description
='Test merge with directory/file conflicts'
7 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
8 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10 TEST_PASSES_SANITIZE_LEAK
=true
13 test_expect_success
'prepare repository' '
16 git commit -m initial &&
22 git commit -m "File: dir/foo" &&
27 git commit -m "File: dir"
30 test_expect_success
'Merge with d/f conflicts' '
31 test_expect_code 1 git merge -m "merge msg" main
34 test_expect_success
'F/D conflict' '
40 echo FILE >before/one &&
43 git commit -m first &&
46 git mv before after &&
49 git checkout -b para HEAD^ &&
50 echo COMPLETELY ANOTHER FILE >another &&
57 test_expect_success
'setup modify/delete + directory/file conflict' '
58 git checkout --orphan modify &&
62 printf "a\nb\nc\nd\ne\nf\ng\nh\n" >letters &&
64 git commit -m initial &&
66 # Throw in letters.txt for sorting order fun
67 # ("letters.txt" sorts between "letters" and "letters/file")
69 echo "version 2" >letters.txt &&
70 git add letters letters.txt &&
71 git commit -m modified &&
73 git checkout -b delete HEAD^ &&
77 echo "version 1" >letters.txt &&
78 git add letters letters.txt &&
82 test_expect_success
'modify/delete + directory/file conflict' '
83 git checkout delete^0 &&
84 test_must_fail git merge modify &&
86 test_stdout_line_count = 5 git ls-files -s &&
87 test_stdout_line_count = 4 git ls-files -u &&
88 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
90 test_stdout_line_count = 0 git ls-files -o
92 test_stdout_line_count = 1 git ls-files -o
95 test_path_is_file letters/file &&
96 test_path_is_file letters.txt &&
97 test_path_is_file letters~modify
100 test_expect_success
'modify/delete + directory/file conflict; other way' '
103 git checkout modify^0 &&
105 test_must_fail git merge delete &&
107 test_stdout_line_count = 5 git ls-files -s &&
108 test_stdout_line_count = 4 git ls-files -u &&
109 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
111 test_stdout_line_count = 0 git ls-files -o
113 test_stdout_line_count = 1 git ls-files -o
116 test_path_is_file letters/file &&
117 test_path_is_file letters.txt &&
118 test_path_is_file letters~HEAD
121 test_expect_success
'Simple merge in repo with interesting pathnames' '
122 # Simple lexicographic ordering of files and directories would be:
128 # The fact that foo/bar-2 appears between foo/bar and foo/bar/baz
129 # can trip up some codepaths, and is the point of this test.
130 git init name-ordering &&
135 mkdir -p foo/bar-2 &&
139 git commit -m initial &&
144 git checkout other &&
145 echo other >foo/bar-2/baz &&
147 git commit -m other &&
149 git checkout topic &&
150 echo topic >foo/bar/baz &&
152 git commit -m topic &&
155 git ls-files -s >out &&
156 test_line_count = 2 out &&
157 git rev-parse :0:foo/bar/baz :0:foo/bar-2/baz >actual &&
158 git rev-parse HEAD~1:foo/bar/baz other:foo/bar-2/baz >expect &&
159 test_cmp expect actual