clone_submodule: avoid using `access()` on directories
[git.git] / t / t6400-merge-df.sh
blob3de4ef6bd9e640d2f82deb111dd307e9a000db91
1 #!/bin/sh
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-lib.sh
12 test_expect_success 'prepare repository' '
13 echo Hello >init &&
14 git add init &&
15 git commit -m initial &&
17 git branch B &&
18 mkdir dir &&
19 echo foo >dir/foo &&
20 git add dir/foo &&
21 git commit -m "File: dir/foo" &&
23 git checkout B &&
24 echo file dir >dir &&
25 git add dir &&
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' '
34 git reset --hard &&
35 git checkout main &&
36 rm .git/index &&
38 mkdir before &&
39 echo FILE >before/one &&
40 echo FILE >after &&
41 git add . &&
42 git commit -m first &&
44 rm -f after &&
45 git mv before after &&
46 git commit -m move &&
48 git checkout -b para HEAD^ &&
49 echo COMPLETELY ANOTHER FILE >another &&
50 git add . &&
51 git commit -m para &&
53 git merge main
56 test_expect_success 'setup modify/delete + directory/file conflict' '
57 git checkout --orphan modify &&
58 git rm -rf . &&
59 git clean -fdqx &&
61 printf "a\nb\nc\nd\ne\nf\ng\nh\n" >letters &&
62 git add letters &&
63 git commit -m initial &&
65 # Throw in letters.txt for sorting order fun
66 # ("letters.txt" sorts between "letters" and "letters/file")
67 echo i >>letters &&
68 echo "version 2" >letters.txt &&
69 git add letters letters.txt &&
70 git commit -m modified &&
72 git checkout -b delete HEAD^ &&
73 git rm letters &&
74 mkdir letters &&
75 >letters/file &&
76 echo "version 1" >letters.txt &&
77 git add letters letters.txt &&
78 git commit -m deleted
81 test_expect_success 'modify/delete + directory/file conflict' '
82 git checkout delete^0 &&
83 test_must_fail git merge modify &&
85 test_stdout_line_count = 5 git ls-files -s &&
86 test_stdout_line_count = 4 git ls-files -u &&
87 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
88 then
89 test_stdout_line_count = 0 git ls-files -o
90 else
91 test_stdout_line_count = 1 git ls-files -o
92 fi &&
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' '
100 git reset --hard &&
101 git clean -f &&
102 git checkout modify^0 &&
104 test_must_fail git merge delete &&
106 test_stdout_line_count = 5 git ls-files -s &&
107 test_stdout_line_count = 4 git ls-files -u &&
108 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
109 then
110 test_stdout_line_count = 0 git ls-files -o
111 else
112 test_stdout_line_count = 1 git ls-files -o
113 fi &&
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:
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.
129 git init name-ordering &&
131 cd name-ordering &&
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 &&
140 git branch topic &&
141 git branch other &&
143 git checkout other &&
144 echo other >foo/bar-2/baz &&
145 git add -u &&
146 git commit -m other &&
148 git checkout topic &&
149 echo topic >foo/bar/baz &&
150 git add -u &&
151 git commit -m topic &&
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
163 test_done