fetch.c: change s_update_ref to use a ref transaction
[git/mjg.git] / t / t1700-split-index.sh
blob94fb473e7c309b823a9abdc1e7c38b1299bf80f3
1 #!/bin/sh
3 test_description='split index mode tests'
5 . ./test-lib.sh
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 cat >expect <<EOF &&
14 own 8299b0bcd1ac364e5f1d7768efb62fa2da79a339
15 base 39d890139ee5356c7ef572216cebcd27aa41f9df
16 replacements:
17 deletions:
18 EOF
19 test_cmp expect actual
22 test_expect_success 'add one file' '
23 : >one &&
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
28 EOF
29 test_cmp ls-files.expect ls-files.actual &&
31 test-dump-split-index .git/index | sed "/^own/d" >actual &&
32 cat >expect <<EOF &&
33 base 39d890139ee5356c7ef572216cebcd27aa41f9df
34 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
35 replacements:
36 deletions:
37 EOF
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
46 EOF
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 &&
51 cat >expect <<EOF &&
52 not a split index
53 EOF
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
62 EOF
63 test_cmp ls-files.expect ls-files.actual &&
65 test-dump-split-index .git/index | sed "/^own/d" >actual &&
66 cat >expect <<EOF &&
67 $BASE
68 replacements:
69 deletions:
70 EOF
71 test_cmp expect actual
74 test_expect_success 'modify original file, base index untouched' '
75 echo modified >one &&
76 git update-index one &&
77 git ls-files --stage >ls-files.actual &&
78 cat >ls-files.expect <<EOF &&
79 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
80 EOF
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 &&
85 $BASE
86 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
87 replacements: 0
88 deletions:
89 EOF
90 test_cmp expect actual
93 test_expect_success 'add another file, which stays index' '
94 : >two &&
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 &&
105 $BASE
106 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
107 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
108 replacements: 0
109 deletions:
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 &&
124 $BASE
125 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
126 replacements: 0
127 deletions:
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 &&
140 cat >expect <<EOF &&
141 $BASE
142 replacements:
143 deletions: 0
145 test_cmp expect actual
148 test_expect_success 'add original file back' '
149 : >one &&
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 &&
158 cat >expect <<EOF &&
159 $BASE
160 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
161 replacements:
162 deletions: 0
164 test_cmp expect actual
167 test_expect_success 'add new file' '
168 : >two &&
169 git update-index --add two &&
170 git ls-files --stage >actual &&
171 cat >expect <<EOF &&
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 &&
188 cat >expect <<EOF &&
189 not a split index
191 test_cmp expect actual
194 test_done