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 &&
14 own 8299b0bcd1ac364e5f1d7768efb62fa2da79a339
15 base 39d890139ee5356c7ef572216cebcd27aa41f9df
19 test_cmp expect actual
22 test_expect_success 'add one file' '
24 git update-index --add one &&
25 git ls-files --stage >ls-files.actual &&
26 cat >ls-files.expect <<EOF &&
27 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
29 test_cmp ls-files.expect ls-files.actual &&
31 test-dump-split-index .git/index | sed "/^own/d" >actual &&
33 base 39d890139ee5356c7ef572216cebcd27aa41f9df
34 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
38 test_cmp expect actual
41 test_expect_success 'disable split index' '
42 git update-index --no-split-index &&
43 git ls-files --stage >ls-files.actual &&
44 cat >ls-files.expect <<EOF &&
45 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
47 test_cmp ls-files.expect ls-files.actual &&
49 BASE=`test-dump-split-index .git/index | grep "^own" | sed "s/own/base/"` &&
50 test-dump-split-index .git/index | sed "/^own/d" >actual &&
54 test_cmp expect actual
57 test_expect_success 'enable split index again, "one" now belongs to base index"' '
58 git update-index --split-index &&
59 git ls-files --stage >ls-files.actual &&
60 cat >ls-files.expect <<EOF &&
61 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
63 test_cmp ls-files.expect ls-files.actual &&
65 test-dump-split-index .git/index | sed "/^own/d" >actual &&
71 test_cmp expect actual
74 test_expect_success 'modify original file, base index untouched' '
76 git update-index one &&
77 git ls-files --stage >ls-files.actual &&
78 cat >ls-files.expect <<EOF &&
79 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
81 test_cmp ls-files.expect ls-files.actual &&
83 test-dump-split-index .git/index | sed "/^own/d" >actual &&
84 q_to_tab >expect <<EOF &&
86 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
90 test_cmp expect actual
93 test_expect_success 'add another file, which stays index' '
95 git update-index --add two &&
96 git ls-files --stage >ls-files.actual &&
97 cat >ls-files.expect <<EOF &&
98 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
99 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
101 test_cmp ls-files.expect ls-files.actual &&
103 test-dump-split-index .git/index | sed "/^own/d" >actual &&
104 q_to_tab >expect <<EOF &&
106 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
107 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
111 test_cmp expect actual
114 test_expect_success 'remove file not in base index' '
115 git update-index --force-remove two &&
116 git ls-files --stage >ls-files.actual &&
117 cat >ls-files.expect <<EOF &&
118 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
120 test_cmp ls-files.expect ls-files.actual &&
122 test-dump-split-index .git/index | sed "/^own/d" >actual &&
123 q_to_tab >expect <<EOF &&
125 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
129 test_cmp expect actual
132 test_expect_success 'remove file in base index' '
133 git update-index --force-remove one &&
134 git ls-files --stage >ls-files.actual &&
135 cat >ls-files.expect <<EOF &&
137 test_cmp ls-files.expect ls-files.actual &&
139 test-dump-split-index .git/index | sed "/^own/d" >actual &&
145 test_cmp expect actual
148 test_expect_success 'add original file back' '
150 git update-index --add one &&
151 git ls-files --stage >ls-files.actual &&
152 cat >ls-files.expect <<EOF &&
153 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
155 test_cmp ls-files.expect ls-files.actual &&
157 test-dump-split-index .git/index | sed "/^own/d" >actual &&
160 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
164 test_cmp expect actual
167 test_expect_success 'add new file' '
169 git update-index --add two &&
170 git ls-files --stage >actual &&
172 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
173 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
175 test_cmp expect actual
178 test_expect_success 'unify index, two files remain' '
179 git update-index --no-split-index &&
180 git ls-files --stage >ls-files.actual &&
181 cat >ls-files.expect <<EOF &&
182 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
183 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
185 test_cmp ls-files.expect ls-files.actual
187 test-dump-split-index .git/index | sed "/^own/d" >actual &&
191 test_cmp expect actual