Merge branch 'sb/push-options-via-transport'
[git/debian.git] / t / t1700-split-index.sh
blob292a0720fccb0becca47fad2945634cbffeb89d6
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 indexversion=$(test-index-version <.git/index) &&
14 if test "$indexversion" = "4"
15 then
16 own=432ef4b63f32193984f339431fd50ca796493569
17 base=508851a7f0dfa8691e9f69c7f055865389012491
18 else
19 own=8299b0bcd1ac364e5f1d7768efb62fa2da79a339
20 base=39d890139ee5356c7ef572216cebcd27aa41f9df
21 fi &&
22 cat >expect <<EOF &&
23 own $own
24 base $base
25 replacements:
26 deletions:
27 EOF
28 test_cmp expect actual
31 test_expect_success 'add one file' '
32 : >one &&
33 git update-index --add one &&
34 git ls-files --stage >ls-files.actual &&
35 cat >ls-files.expect <<EOF &&
36 100644 $EMPTY_BLOB 0 one
37 EOF
38 test_cmp ls-files.expect ls-files.actual &&
40 test-dump-split-index .git/index | sed "/^own/d" >actual &&
41 cat >expect <<EOF &&
42 base $base
43 100644 $EMPTY_BLOB 0 one
44 replacements:
45 deletions:
46 EOF
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 $EMPTY_BLOB 0 one
55 EOF
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 &&
60 cat >expect <<EOF &&
61 not a split index
62 EOF
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 $EMPTY_BLOB 0 one
71 EOF
72 test_cmp ls-files.expect ls-files.actual &&
74 test-dump-split-index .git/index | sed "/^own/d" >actual &&
75 cat >expect <<EOF &&
76 $BASE
77 replacements:
78 deletions:
79 EOF
80 test_cmp expect actual
83 test_expect_success 'modify original file, base index untouched' '
84 echo modified >one &&
85 git update-index one &&
86 git ls-files --stage >ls-files.actual &&
87 cat >ls-files.expect <<EOF &&
88 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
89 EOF
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 &&
94 $BASE
95 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
96 replacements: 0
97 deletions:
98 EOF
99 test_cmp expect actual
102 test_expect_success 'add another file, which stays index' '
103 : >two &&
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 $EMPTY_BLOB 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 &&
114 $BASE
115 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
116 100644 $EMPTY_BLOB 0 two
117 replacements: 0
118 deletions:
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 &&
133 $BASE
134 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
135 replacements: 0
136 deletions:
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 &&
149 cat >expect <<EOF &&
150 $BASE
151 replacements:
152 deletions: 0
154 test_cmp expect actual
157 test_expect_success 'add original file back' '
158 : >one &&
159 git update-index --add one &&
160 git ls-files --stage >ls-files.actual &&
161 cat >ls-files.expect <<EOF &&
162 100644 $EMPTY_BLOB 0 one
164 test_cmp ls-files.expect ls-files.actual &&
166 test-dump-split-index .git/index | sed "/^own/d" >actual &&
167 cat >expect <<EOF &&
168 $BASE
169 100644 $EMPTY_BLOB 0 one
170 replacements:
171 deletions: 0
173 test_cmp expect actual
176 test_expect_success 'add new file' '
177 : >two &&
178 git update-index --add two &&
179 git ls-files --stage >actual &&
180 cat >expect <<EOF &&
181 100644 $EMPTY_BLOB 0 one
182 100644 $EMPTY_BLOB 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 $EMPTY_BLOB 0 one
192 100644 $EMPTY_BLOB 0 two
194 test_cmp ls-files.expect ls-files.actual &&
196 test-dump-split-index .git/index | sed "/^own/d" >actual &&
197 cat >expect <<EOF &&
198 not a split index
200 test_cmp expect actual
203 test_done