]> git.ipfire.org Git - thirdparty/git.git/blob - t/t6428-merge-conflicts-sparse.sh
The 19th batch
[thirdparty/git.git] / t / t6428-merge-conflicts-sparse.sh
1 #!/bin/sh
2
3 test_description="merge cases"
4
5 # The setup for all of them, pictorially, is:
6 #
7 # A
8 # o
9 # / \
10 # O o ?
11 # \ /
12 # o
13 # B
14 #
15 # To help make it easier to follow the flow of tests, they have been
16 # divided into sections and each test will start with a quick explanation
17 # of what commits O, A, and B contain.
18 #
19 # Notation:
20 # z/{b,c} means files z/b and z/c both exist
21 # x/d_1 means file x/d exists with content d1. (Purpose of the
22 # underscore notation is to differentiate different
23 # files that might be renamed into each other's paths.)
24
25 TEST_PASSES_SANITIZE_LEAK=true
26 . ./test-lib.sh
27 . "$TEST_DIRECTORY"/lib-merge.sh
28
29
30 # Testcase basic, conflicting changes in 'numerals'
31
32 test_setup_numerals () {
33 git init numerals_$1 &&
34 (
35 cd numerals_$1 &&
36
37 >README &&
38 test_write_lines I II III >numerals &&
39 git add README numerals &&
40 test_tick &&
41 git commit -m "O" &&
42
43 git branch O &&
44 git branch A &&
45 git branch B &&
46
47 git checkout A &&
48 test_write_lines I II III IIII >numerals &&
49 git add numerals &&
50 test_tick &&
51 git commit -m "A" &&
52
53 git checkout B &&
54 test_write_lines I II III IV >numerals &&
55 git add numerals &&
56 test_tick &&
57 git commit -m "B" &&
58
59 cat <<-EOF >expected-index &&
60 H README
61 M numerals
62 M numerals
63 M numerals
64 EOF
65
66 cat <<-EOF >expected-merge
67 I
68 II
69 III
70 <<<<<<< HEAD
71 IIII
72 =======
73 IV
74 >>>>>>> B^0
75 EOF
76
77 )
78 }
79
80 test_expect_success 'conflicting entries written to worktree even if sparse' '
81 test_setup_numerals plain &&
82 (
83 cd numerals_plain &&
84
85 git checkout A^0 &&
86
87 test_path_is_file README &&
88 test_path_is_file numerals &&
89
90 git sparse-checkout init &&
91 git sparse-checkout set --no-cone README &&
92
93 test_path_is_file README &&
94 test_path_is_missing numerals &&
95
96 test_must_fail git merge -s recursive B^0 &&
97
98 git ls-files -t >index_files &&
99 test_cmp expected-index index_files &&
100
101 test_path_is_file README &&
102 test_path_is_file numerals &&
103
104 test_cmp expected-merge numerals &&
105
106 # 4 other files:
107 # * expected-merge
108 # * expected-index
109 # * index_files
110 # * others
111 git ls-files -o >others &&
112 test_line_count = 4 others
113 )
114 '
115
116 test_expect_success 'present-despite-SKIP_WORKTREE handled reasonably' '
117 test_setup_numerals in_the_way &&
118 (
119 cd numerals_in_the_way &&
120
121 git checkout A^0 &&
122
123 test_path_is_file README &&
124 test_path_is_file numerals &&
125
126 git sparse-checkout init &&
127 git sparse-checkout set --no-cone README &&
128
129 test_path_is_file README &&
130 test_path_is_missing numerals &&
131
132 echo foobar >numerals &&
133
134 test_must_fail git merge -s recursive B^0 &&
135
136 test_path_is_missing .git/MERGE_HEAD &&
137
138 test_path_is_file numerals &&
139
140 # numerals should still have "foobar" in it
141 echo foobar >expect &&
142 test_cmp expect numerals
143 )
144 '
145
146 test_done