gitlab-ci: exercise Git on Windows
[git/gitster.git] / t / t6428-merge-conflicts-sparse.sh
blob8a79bc2e921d433bb9db401c2f9c0f25a9908333
1 #!/bin/sh
3 test_description="merge cases"
5 # The setup for all of them, pictorially, is:
7 # A
8 # o
9 # / \
10 # O o ?
11 # \ /
12 # o
13 # B
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.
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.)
25 TEST_PASSES_SANITIZE_LEAK=true
26 . ./test-lib.sh
27 . "$TEST_DIRECTORY"/lib-merge.sh
30 # Testcase basic, conflicting changes in 'numerals'
32 test_setup_numerals () {
33 git init numerals_$1 &&
35 cd numerals_$1 &&
37 >README &&
38 test_write_lines I II III >numerals &&
39 git add README numerals &&
40 test_tick &&
41 git commit -m "O" &&
43 git branch O &&
44 git branch A &&
45 git branch B &&
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" &&
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" &&
59 cat <<-EOF >expected-index &&
60 H README
61 M numerals
62 M numerals
63 M numerals
64 EOF
66 cat <<-EOF >expected-merge
69 III
70 <<<<<<< HEAD
71 IIII
72 =======
74 >>>>>>> B^0
75 EOF
80 test_expect_success 'conflicting entries written to worktree even if sparse' '
81 test_setup_numerals plain &&
83 cd numerals_plain &&
85 git checkout A^0 &&
87 test_path_is_file README &&
88 test_path_is_file numerals &&
90 git sparse-checkout init &&
91 git sparse-checkout set --no-cone README &&
93 test_path_is_file README &&
94 test_path_is_missing numerals &&
96 test_must_fail git merge -s recursive B^0 &&
98 git ls-files -t >index_files &&
99 test_cmp expected-index index_files &&
101 test_path_is_file README &&
102 test_path_is_file numerals &&
104 test_cmp expected-merge numerals &&
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
116 test_expect_success 'present-despite-SKIP_WORKTREE handled reasonably' '
117 test_setup_numerals in_the_way &&
119 cd numerals_in_the_way &&
121 git checkout A^0 &&
123 test_path_is_file README &&
124 test_path_is_file numerals &&
126 git sparse-checkout init &&
127 git sparse-checkout set --no-cone README &&
129 test_path_is_file README &&
130 test_path_is_missing numerals &&
132 echo foobar >numerals &&
134 test_must_fail git merge -s recursive B^0 &&
136 test_path_is_missing .git/MERGE_HEAD &&
138 test_path_is_file numerals &&
140 # numerals should still have "foobar" in it
141 echo foobar >expect &&
142 test_cmp expect numerals
146 test_done