3 test_description='split index mode tests'
7 # We need total control of index splitting here
8 sane_unset GIT_TEST_SPLIT_INDEX
10 test_expect_success 'enable split index' '
11 git update-index --split-index &&
12 test-dump-split-index .git/index >actual &&
13 indexversion=$(test-index-version <.git/index) &&
14 if test "$indexversion" = "4"
16 own=432ef4b63f32193984f339431fd50ca796493569
17 base=508851a7f0dfa8691e9f69c7f055865389012491
19 own=8299b0bcd1ac364e5f1d7768efb62fa2da79a339
20 base=39d890139ee5356c7ef572216cebcd27aa41f9df
28 test_cmp expect actual
31 test_expect_success 'add one file' '
33 git update-index --add one &&
34 git ls-files --stage >ls-files.actual &&
35 cat >ls-files.expect <<EOF &&
36 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
38 test_cmp ls-files.expect ls-files.actual &&
40 test-dump-split-index .git/index | sed "/^own/d" >actual &&
43 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
47 test_cmp expect actual
50 test_expect_success 'disable split index' '
51 git update-index --no-split-index &&
52 git ls-files --stage >ls-files.actual &&
53 cat >ls-files.expect <<EOF &&
54 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
56 test_cmp ls-files.expect ls-files.actual &&
58 BASE=$(test-dump-split-index .git/index | grep "^own" | sed "s/own/base/") &&
59 test-dump-split-index .git/index | sed "/^own/d" >actual &&
63 test_cmp expect actual
66 test_expect_success 'enable split index again, "one" now belongs to base index"' '
67 git update-index --split-index &&
68 git ls-files --stage >ls-files.actual &&
69 cat >ls-files.expect <<EOF &&
70 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
72 test_cmp ls-files.expect ls-files.actual &&
74 test-dump-split-index .git/index | sed "/^own/d" >actual &&
80 test_cmp expect actual
83 test_expect_success 'modify original file, base index untouched' '
85 git update-index one &&
86 git ls-files --stage >ls-files.actual &&
87 cat >ls-files.expect <<EOF &&
88 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
90 test_cmp ls-files.expect ls-files.actual &&
92 test-dump-split-index .git/index | sed "/^own/d" >actual &&
93 q_to_tab >expect <<EOF &&
95 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
99 test_cmp expect actual
102 test_expect_success 'add another file, which stays index' '
104 git update-index --add two &&
105 git ls-files --stage >ls-files.actual &&
106 cat >ls-files.expect <<EOF &&
107 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
108 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
110 test_cmp ls-files.expect ls-files.actual &&
112 test-dump-split-index .git/index | sed "/^own/d" >actual &&
113 q_to_tab >expect <<EOF &&
115 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
116 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
120 test_cmp expect actual
123 test_expect_success 'remove file not in base index' '
124 git update-index --force-remove two &&
125 git ls-files --stage >ls-files.actual &&
126 cat >ls-files.expect <<EOF &&
127 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
129 test_cmp ls-files.expect ls-files.actual &&
131 test-dump-split-index .git/index | sed "/^own/d" >actual &&
132 q_to_tab >expect <<EOF &&
134 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
138 test_cmp expect actual
141 test_expect_success 'remove file in base index' '
142 git update-index --force-remove one &&
143 git ls-files --stage >ls-files.actual &&
144 cat >ls-files.expect <<EOF &&
146 test_cmp ls-files.expect ls-files.actual &&
148 test-dump-split-index .git/index | sed "/^own/d" >actual &&
154 test_cmp expect actual
157 test_expect_success 'add original file back' '
159 git update-index --add one &&
160 git ls-files --stage >ls-files.actual &&
161 cat >ls-files.expect <<EOF &&
162 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
164 test_cmp ls-files.expect ls-files.actual &&
166 test-dump-split-index .git/index | sed "/^own/d" >actual &&
169 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
173 test_cmp expect actual
176 test_expect_success 'add new file' '
178 git update-index --add two &&
179 git ls-files --stage >actual &&
181 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
182 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
184 test_cmp expect actual
187 test_expect_success 'unify index, two files remain' '
188 git update-index --no-split-index &&
189 git ls-files --stage >ls-files.actual &&
190 cat >ls-files.expect <<EOF &&
191 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
192 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
194 test_cmp ls-files.expect ls-files.actual &&
196 test-dump-split-index .git/index | sed "/^own/d" >actual &&
200 test_cmp expect actual