]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6400-merge-df.sh
Merge branch 'mt/do-not-use-scld-in-working-tree'
[thirdparty/git.git] / t / t6400-merge-df.sh
CommitLineData
72d1216a
FK
1#!/bin/sh
2#
3# Copyright (c) 2005 Fredrik Kuivinen
4#
5
6test_description='Test merge with directory/file conflicts'
7. ./test-lib.sh
8
d09c0a39
EN
9test_expect_success 'prepare repository' '
10 echo Hello >init &&
11 git add init &&
12 git commit -m initial &&
13
14 git branch B &&
15 mkdir dir &&
16 echo foo >dir/foo &&
17 git add dir/foo &&
18 git commit -m "File: dir/foo" &&
19
20 git checkout B &&
21 echo file dir >dir &&
22 git add dir &&
23 git commit -m "File: dir"
24'
72d1216a 25
892e6f7e 26test_expect_success 'Merge with d/f conflicts' '
d45366e8 27 test_expect_code 1 git merge -m "merge msg" master
892e6f7e 28'
72d1216a 29
5a2580d6 30test_expect_success 'F/D conflict' '
1c9b2d3a
AR
31 git reset --hard &&
32 git checkout master &&
33 rm .git/index &&
34
35 mkdir before &&
36 echo FILE >before/one &&
37 echo FILE >after &&
38 git add . &&
39 git commit -m first &&
40
41 rm -f after &&
42 git mv before after &&
43 git commit -m move &&
44
45 git checkout -b para HEAD^ &&
46 echo COMPLETELY ANOTHER FILE >another &&
47 git add . &&
48 git commit -m para &&
49
50 git merge master
51'
52
fa0ae3b1
EN
53test_expect_success 'setup modify/delete + directory/file conflict' '
54 git checkout --orphan modify &&
55 git rm -rf . &&
56 git clean -fdqx &&
57
58 printf "a\nb\nc\nd\ne\nf\ng\nh\n" >letters &&
59 git add letters &&
60 git commit -m initial &&
61
f0fd4d05
EN
62 # Throw in letters.txt for sorting order fun
63 # ("letters.txt" sorts between "letters" and "letters/file")
fa0ae3b1 64 echo i >>letters &&
f0fd4d05
EN
65 echo "version 2" >letters.txt &&
66 git add letters letters.txt &&
fa0ae3b1
EN
67 git commit -m modified &&
68
69 git checkout -b delete HEAD^ &&
70 git rm letters &&
71 mkdir letters &&
72 >letters/file &&
f0fd4d05
EN
73 echo "version 1" >letters.txt &&
74 git add letters letters.txt &&
fa0ae3b1
EN
75 git commit -m deleted
76'
77
84a08a47 78test_expect_success 'modify/delete + directory/file conflict' '
fa0ae3b1
EN
79 git checkout delete^0 &&
80 test_must_fail git merge modify &&
81
f0fd4d05
EN
82 test 5 -eq $(git ls-files -s | wc -l) &&
83 test 4 -eq $(git ls-files -u | wc -l) &&
ef527787
EN
84 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
85 then
86 test 0 -eq $(git ls-files -o | wc -l)
87 else
88 test 1 -eq $(git ls-files -o | wc -l)
89 fi &&
fa0ae3b1 90
b821ca78
EN
91 test_path_is_file letters/file &&
92 test_path_is_file letters.txt &&
93 test_path_is_file letters~modify
fa0ae3b1
EN
94'
95
ef02b317 96test_expect_success 'modify/delete + directory/file conflict; other way' '
fa0ae3b1
EN
97 git reset --hard &&
98 git clean -f &&
99 git checkout modify^0 &&
f0fd4d05 100
fa0ae3b1
EN
101 test_must_fail git merge delete &&
102
f0fd4d05
EN
103 test 5 -eq $(git ls-files -s | wc -l) &&
104 test 4 -eq $(git ls-files -u | wc -l) &&
ef527787
EN
105 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
106 then
107 test 0 -eq $(git ls-files -o | wc -l)
108 else
109 test 1 -eq $(git ls-files -o | wc -l)
110 fi &&
fa0ae3b1 111
b821ca78
EN
112 test_path_is_file letters/file &&
113 test_path_is_file letters.txt &&
114 test_path_is_file letters~HEAD
fa0ae3b1
EN
115'
116
65bf820d
EN
117test_expect_success 'Simple merge in repo with interesting pathnames' '
118 # Simple lexicographic ordering of files and directories would be:
119 # foo
120 # foo/bar
121 # foo/bar-2
122 # foo/bar/baz
123 # foo/bar-2/baz
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 &&
127 (
128 cd name-ordering &&
129
130 mkdir -p foo/bar &&
131 mkdir -p foo/bar-2 &&
132 >foo/bar/baz &&
133 >foo/bar-2/baz &&
134 git add . &&
135 git commit -m initial &&
136
538228ed 137 git branch topic &&
65bf820d
EN
138 git branch other &&
139
140 git checkout other &&
141 echo other >foo/bar-2/baz &&
142 git add -u &&
143 git commit -m other &&
144
538228ed
JS
145 git checkout topic &&
146 echo topic >foo/bar/baz &&
65bf820d 147 git add -u &&
538228ed 148 git commit -m topic &&
65bf820d
EN
149
150 git merge other &&
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
156 )
157
158'
159
72d1216a 160test_done