3 # Copyright (c) 2005 Fredrik Kuivinen
6 test_description
='Test merge with directory/file conflicts'
9 test_expect_success
'prepare repository' '
12 git commit -m initial &&
18 git commit -m "File: dir/foo" &&
23 git commit -m "File: dir"
26 test_expect_success
'Merge with d/f conflicts' '
27 test_expect_code 1 git merge -m "merge msg" master
30 test_expect_success
'F/D conflict' '
32 git checkout master &&
36 echo FILE >before/one &&
39 git commit -m first &&
42 git mv before after &&
45 git checkout -b para HEAD^ &&
46 echo COMPLETELY ANOTHER FILE >another &&
53 test_expect_success
'setup modify/delete + directory/file conflict' '
54 git checkout --orphan modify &&
58 printf "a\nb\nc\nd\ne\nf\ng\nh\n" >letters &&
60 git commit -m initial &&
62 # Throw in letters.txt for sorting order fun
63 # ("letters.txt" sorts between "letters" and "letters/file")
65 echo "version 2" >letters.txt &&
66 git add letters letters.txt &&
67 git commit -m modified &&
69 git checkout -b delete HEAD^ &&
73 echo "version 1" >letters.txt &&
74 git add letters letters.txt &&
78 test_expect_success
'modify/delete + directory/file conflict' '
79 git checkout delete^0 &&
80 test_must_fail git merge modify &&
82 test 5 -eq $(git ls-files -s | wc -l) &&
83 test 4 -eq $(git ls-files -u | wc -l) &&
84 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
86 test 0 -eq $(git ls-files -o | wc -l)
88 test 1 -eq $(git ls-files -o | wc -l)
91 test_path_is_file letters/file &&
92 test_path_is_file letters.txt &&
93 test_path_is_file letters~modify
96 test_expect_success
'modify/delete + directory/file conflict; other way' '
99 git checkout modify^0 &&
101 test_must_fail git merge delete &&
103 test 5 -eq $(git ls-files -s | wc -l) &&
104 test 4 -eq $(git ls-files -u | wc -l) &&
105 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
107 test 0 -eq $(git ls-files -o | wc -l)
109 test 1 -eq $(git ls-files -o | wc -l)
112 test_path_is_file letters/file &&
113 test_path_is_file letters.txt &&
114 test_path_is_file letters~HEAD
117 test_expect_success
'Simple merge in repo with interesting pathnames' '
118 # Simple lexicographic ordering of files and directories would be:
124 # The fact that foo/bar-2 appears between foo/bar and foo/bar/baz
125 # can trip up some codepaths, and is the point of this test.
126 test_create_repo name-ordering &&
131 mkdir -p foo/bar-2 &&
135 git commit -m initial &&
140 git checkout other &&
141 echo other >foo/bar-2/baz &&
143 git commit -m other &&
145 git checkout topic &&
146 echo topic >foo/bar/baz &&
148 git commit -m topic &&
151 git ls-files -s >out &&
152 test_line_count = 2 out &&
153 git rev-parse :0:foo/bar/baz :0:foo/bar-2/baz >actual &&
154 git rev-parse HEAD~1:foo/bar/baz other:foo/bar-2/baz >expect &&
155 test_cmp expect actual