Commit | Line | Data |
---|---|---|
3e52f70b NTND |
1 | #!/bin/sh |
2 | ||
3 | test_description='split index mode tests' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | # We need total control of index splitting here | |
8 | sane_unset GIT_TEST_SPLIT_INDEX | |
9 | ||
10 | test_expect_success 'enable split index' ' | |
11 | git update-index --split-index && | |
12 | test-dump-split-index .git/index >actual && | |
e869c5ea TG |
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 && | |
3e52f70b | 22 | cat >expect <<EOF && |
e869c5ea TG |
23 | own $own |
24 | base $base | |
3e52f70b NTND |
25 | replacements: |
26 | deletions: | |
27 | EOF | |
28 | test_cmp expect actual | |
29 | ' | |
30 | ||
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 && | |
378932d3 | 36 | 100644 $EMPTY_BLOB 0 one |
3e52f70b NTND |
37 | EOF |
38 | test_cmp ls-files.expect ls-files.actual && | |
39 | ||
40 | test-dump-split-index .git/index | sed "/^own/d" >actual && | |
41 | cat >expect <<EOF && | |
e869c5ea | 42 | base $base |
378932d3 | 43 | 100644 $EMPTY_BLOB 0 one |
3e52f70b NTND |
44 | replacements: |
45 | deletions: | |
46 | EOF | |
47 | test_cmp expect actual | |
48 | ' | |
49 | ||
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 && | |
378932d3 | 54 | 100644 $EMPTY_BLOB 0 one |
3e52f70b NTND |
55 | EOF |
56 | test_cmp ls-files.expect ls-files.actual && | |
57 | ||
16149d75 | 58 | BASE=$(test-dump-split-index .git/index | grep "^own" | sed "s/own/base/") && |
3e52f70b NTND |
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 | |
64 | ' | |
65 | ||
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 && | |
378932d3 | 70 | 100644 $EMPTY_BLOB 0 one |
3e52f70b NTND |
71 | EOF |
72 | test_cmp ls-files.expect ls-files.actual && | |
73 | ||
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 | |
81 | ' | |
82 | ||
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 && | |
91 | ||
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 | |
100 | ' | |
101 | ||
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 | |
378932d3 | 108 | 100644 $EMPTY_BLOB 0 two |
3e52f70b NTND |
109 | EOF |
110 | test_cmp ls-files.expect ls-files.actual && | |
111 | ||
112 | test-dump-split-index .git/index | sed "/^own/d" >actual && | |
113 | q_to_tab >expect <<EOF && | |
114 | $BASE | |
115 | 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q | |
378932d3 | 116 | 100644 $EMPTY_BLOB 0 two |
3e52f70b NTND |
117 | replacements: 0 |
118 | deletions: | |
119 | EOF | |
120 | test_cmp expect actual | |
121 | ' | |
122 | ||
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 | |
128 | EOF | |
129 | test_cmp ls-files.expect ls-files.actual && | |
130 | ||
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: | |
137 | EOF | |
138 | test_cmp expect actual | |
139 | ' | |
140 | ||
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 && | |
145 | EOF | |
146 | test_cmp ls-files.expect ls-files.actual && | |
147 | ||
148 | test-dump-split-index .git/index | sed "/^own/d" >actual && | |
149 | cat >expect <<EOF && | |
150 | $BASE | |
151 | replacements: | |
152 | deletions: 0 | |
153 | EOF | |
154 | test_cmp expect actual | |
155 | ' | |
156 | ||
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 && | |
378932d3 | 162 | 100644 $EMPTY_BLOB 0 one |
3e52f70b NTND |
163 | EOF |
164 | test_cmp ls-files.expect ls-files.actual && | |
165 | ||
166 | test-dump-split-index .git/index | sed "/^own/d" >actual && | |
167 | cat >expect <<EOF && | |
168 | $BASE | |
378932d3 | 169 | 100644 $EMPTY_BLOB 0 one |
3e52f70b NTND |
170 | replacements: |
171 | deletions: 0 | |
172 | EOF | |
173 | test_cmp expect actual | |
174 | ' | |
175 | ||
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 && | |
378932d3 NTND |
181 | 100644 $EMPTY_BLOB 0 one |
182 | 100644 $EMPTY_BLOB 0 two | |
3e52f70b NTND |
183 | EOF |
184 | test_cmp expect actual | |
185 | ' | |
186 | ||
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 && | |
378932d3 NTND |
191 | 100644 $EMPTY_BLOB 0 one |
192 | 100644 $EMPTY_BLOB 0 two | |
3e52f70b | 193 | EOF |
8fb26872 | 194 | test_cmp ls-files.expect ls-files.actual && |
3e52f70b NTND |
195 | |
196 | test-dump-split-index .git/index | sed "/^own/d" >actual && | |
197 | cat >expect <<EOF && | |
198 | not a split index | |
199 | EOF | |
200 | test_cmp expect actual | |
201 | ' | |
202 | ||
203 | test_done |