t/README: add missing value for GIT_TEST_DEFAULT_REF_FORMAT
[git/gitster.git] / t / t6400-merge-df.sh
blob27d6efdc9a6d377a3eab526b6c4aac46319c33d5
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_PASSES_SANITIZE_LEAK=true
11 . ./test-lib.sh
13 test_expect_success 'prepare repository' '
14 echo Hello >init &&
15 git add init &&
16 git commit -m initial &&
18 git branch B &&
19 mkdir dir &&
20 echo foo >dir/foo &&
21 git add dir/foo &&
22 git commit -m "File: dir/foo" &&
24 git checkout B &&
25 echo file dir >dir &&
26 git add dir &&
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' '
35 git reset --hard &&
36 git checkout main &&
37 rm .git/index &&
39 mkdir before &&
40 echo FILE >before/one &&
41 echo FILE >after &&
42 git add . &&
43 git commit -m first &&
45 rm -f after &&
46 git mv before after &&
47 git commit -m move &&
49 git checkout -b para HEAD^ &&
50 echo COMPLETELY ANOTHER FILE >another &&
51 git add . &&
52 git commit -m para &&
54 git merge main
57 test_expect_success 'setup modify/delete + directory/file conflict' '
58 git checkout --orphan modify &&
59 git rm -rf . &&
60 git clean -fdqx &&
62 printf "a\nb\nc\nd\ne\nf\ng\nh\n" >letters &&
63 git add letters &&
64 git commit -m initial &&
66 # Throw in letters.txt for sorting order fun
67 # ("letters.txt" sorts between "letters" and "letters/file")
68 echo i >>letters &&
69 echo "version 2" >letters.txt &&
70 git add letters letters.txt &&
71 git commit -m modified &&
73 git checkout -b delete HEAD^ &&
74 git rm letters &&
75 mkdir letters &&
76 >letters/file &&
77 echo "version 1" >letters.txt &&
78 git add letters letters.txt &&
79 git commit -m deleted
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
89 then
90 test_stdout_line_count = 0 git ls-files -o
91 else
92 test_stdout_line_count = 1 git ls-files -o
93 fi &&
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' '
101 git reset --hard &&
102 git clean -f &&
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
110 then
111 test_stdout_line_count = 0 git ls-files -o
112 else
113 test_stdout_line_count = 1 git ls-files -o
114 fi &&
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:
123 # foo
124 # foo/bar
125 # foo/bar-2
126 # foo/bar/baz
127 # foo/bar-2/baz
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 &&
132 cd name-ordering &&
134 mkdir -p foo/bar &&
135 mkdir -p foo/bar-2 &&
136 >foo/bar/baz &&
137 >foo/bar-2/baz &&
138 git add . &&
139 git commit -m initial &&
141 git branch topic &&
142 git branch other &&
144 git checkout other &&
145 echo other >foo/bar-2/baz &&
146 git add -u &&
147 git commit -m other &&
149 git checkout topic &&
150 echo topic >foo/bar/baz &&
151 git add -u &&
152 git commit -m topic &&
154 git merge other &&
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
164 test_done