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
12 test_expect_success 'prepare repository' '
15 git commit -m initial &&
21 git commit -m "File: dir/foo" &&
26 git commit -m "File: dir"
29 test_expect_success 'Merge with d/f conflicts' '
30 test_expect_code 1 git merge -m "merge msg" main
33 test_expect_success 'F/D conflict' '
39 echo FILE >before/one &&
42 git commit -m first &&
45 git mv before after &&
48 git checkout -b para HEAD^ &&
49 echo COMPLETELY ANOTHER FILE >another &&
56 test_expect_success 'setup modify/delete + directory/file conflict' '
57 git checkout --orphan modify &&
61 printf "a\nb\nc\nd\ne\nf\ng\nh\n" >letters &&
63 git commit -m initial &&
65 # Throw in letters.txt for sorting order fun
66 # ("letters.txt" sorts between "letters" and "letters/file")
68 echo "version 2" >letters.txt &&
69 git add letters letters.txt &&
70 git commit -m modified &&
72 git checkout -b delete HEAD^ &&
76 echo "version 1" >letters.txt &&
77 git add letters letters.txt &&
81 test_expect_success 'modify/delete + directory/file conflict' '
82 git checkout delete^0 &&
83 test_must_fail git merge modify &&
85 test 5 -eq $(git ls-files -s | wc -l) &&
86 test 4 -eq $(git ls-files -u | wc -l) &&
87 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
89 test 0 -eq $(git ls-files -o | wc -l)
91 test 1 -eq $(git ls-files -o | wc -l)
94 test_path_is_file letters/file &&
95 test_path_is_file letters.txt &&
96 test_path_is_file letters~modify
99 test_expect_success 'modify/delete + directory/file conflict; other way' '
102 git checkout modify^0 &&
104 test_must_fail git merge delete &&
106 test 5 -eq $(git ls-files -s | wc -l) &&
107 test 4 -eq $(git ls-files -u | wc -l) &&
108 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
110 test 0 -eq $(git ls-files -o | wc -l)
112 test 1 -eq $(git ls-files -o | wc -l)
115 test_path_is_file letters/file &&
116 test_path_is_file letters.txt &&
117 test_path_is_file letters~HEAD
120 test_expect_success 'Simple merge in repo with interesting pathnames' '
121 # Simple lexicographic ordering of files and directories would be:
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.
129 test_create_repo name-ordering &&
134 mkdir -p foo/bar-2 &&
138 git commit -m initial &&
143 git checkout other &&
144 echo other >foo/bar-2/baz &&
146 git commit -m other &&
148 git checkout topic &&
149 echo topic >foo/bar/baz &&
151 git commit -m topic &&
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