11
# with those checks, so disable it in this test script.
12
sane_unset GIT_FSMONITOR_TEST
13
14
+# Create a file named as $1 with content read from stdin.
15
+# Set the file's mtime to a few seconds in the past to avoid racy situations.
16
+create_non_racy_file () {
17
+ cat >"$1" &&
18
+ test-tool chmtime =-5 "$1"
19
+}
20
+
21
test_expect_success 'enable split index' '
22
git config splitIndex.maxPercentChange 100 &&
23
git update-index --split-index &&
41
'
42
43
test_expect_success 'add one file' '
37
- : >one &&
44
+ create_non_racy_file one &&
45
git update-index --add one &&
46
git ls-files --stage >ls-files.actual &&
47
cat >ls-files.expect <<-EOF &&
93
'
94
95
test_expect_success 'modify original file, base index untouched' '
89
- echo modified >one &&
96
+ echo modified | create_non_racy_file one &&
97
git update-index one &&
98
git ls-files --stage >ls-files.actual &&
99
cat >ls-files.expect <<-EOF &&
112
'
113
114
test_expect_success 'add another file, which stays index' '
108
- : >two &&
115
+ create_non_racy_file two &&
116
git update-index --add two &&
117
git ls-files --stage >ls-files.actual &&
118
cat >ls-files.expect <<-EOF &&
165
'
166
167
test_expect_success 'add original file back' '
161
- : >one &&
168
+ create_non_racy_file one &&
169
git update-index --add one &&
170
git ls-files --stage >ls-files.actual &&
171
cat >ls-files.expect <<-EOF &&
184
'
185
186
test_expect_success 'add new file' '
180
- : >two &&
187
+ create_non_racy_file two &&
188
git update-index --add two &&
189
git ls-files --stage >actual &&
190
cat >expect <<-EOF &&
228
229
test_expect_success 'set core.splitIndex config variable to true' '
230
git config core.splitIndex true &&
224
- : >three &&
231
+ create_non_racy_file three &&
232
git update-index --add three &&
233
git ls-files --stage >ls-files.actual &&
234
cat >ls-files.expect <<-EOF &&
263
test_cmp expect actual
264
'
265
259
-test_expect_success 'set core.splitIndex config variable to true' '
266
+test_expect_success 'set core.splitIndex config variable back to true' '
267
git config core.splitIndex true &&
261
- : >three &&
268
+ create_non_racy_file three &&
269
git update-index --add three &&
270
BASE=$(test-tool dump-split-index .git/index | grep "^base") &&
271
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
275
deletions:
276
EOF
277
test_cmp expect actual &&
271
- : >four &&
278
+ create_non_racy_file four &&
279
git update-index --add four &&
280
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
281
cat >expect <<-EOF &&
289
290
test_expect_success 'check behavior with splitIndex.maxPercentChange unset' '
291
git config --unset splitIndex.maxPercentChange &&
285
- : >five &&
292
+ create_non_racy_file five &&
293
git update-index --add five &&
294
BASE=$(test-tool dump-split-index .git/index | grep "^base") &&
295
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
299
deletions:
300
EOF
301
test_cmp expect actual &&
295
- : >six &&
302
+ create_non_racy_file six &&
303
git update-index --add six &&
304
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
305
cat >expect <<-EOF &&
313
314
test_expect_success 'check splitIndex.maxPercentChange set to 0' '
315
git config splitIndex.maxPercentChange 0 &&
309
- : >seven &&
316
+ create_non_racy_file seven &&
317
git update-index --add seven &&
318
BASE=$(test-tool dump-split-index .git/index | grep "^base") &&
319
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
323
deletions:
324
EOF
325
test_cmp expect actual &&
319
- : >eight &&
326
+ create_non_racy_file eight &&
327
git update-index --add eight &&
328
BASE=$(test-tool dump-split-index .git/index | grep "^base") &&
329
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
336
'
337
338
test_expect_success 'shared index files expire after 2 weeks by default' '
332
- : >ten &&
339
+ create_non_racy_file ten &&
340
git update-index --add ten &&
341
test $(ls .git/sharedindex.* | wc -l) -gt 2 &&
342
just_under_2_weeks_ago=$((5-14*86400)) &&
343
test-tool chmtime =$just_under_2_weeks_ago .git/sharedindex.* &&
337
- : >eleven &&
344
+ create_non_racy_file eleven &&
345
git update-index --add eleven &&
346
test $(ls .git/sharedindex.* | wc -l) -gt 2 &&
347
just_over_2_weeks_ago=$((-1-14*86400)) &&
348
test-tool chmtime =$just_over_2_weeks_ago .git/sharedindex.* &&
342
- : >twelve &&
349
+ create_non_racy_file twelve &&
350
git update-index --add twelve &&
351
test $(ls .git/sharedindex.* | wc -l) -le 2
352
'
354
test_expect_success 'check splitIndex.sharedIndexExpire set to 16 days' '
355
git config splitIndex.sharedIndexExpire "16.days.ago" &&
356
test-tool chmtime =$just_over_2_weeks_ago .git/sharedindex.* &&
350
- : >thirteen &&
357
+ create_non_racy_file thirteen &&
358
git update-index --add thirteen &&
359
test $(ls .git/sharedindex.* | wc -l) -gt 2 &&
360
just_over_16_days_ago=$((-1-16*86400)) &&
361
test-tool chmtime =$just_over_16_days_ago .git/sharedindex.* &&
355
- : >fourteen &&
362
+ create_non_racy_file fourteen &&
363
git update-index --add fourteen &&
364
test $(ls .git/sharedindex.* | wc -l) -le 2
365
'
368
git config splitIndex.sharedIndexExpire never &&
369
just_10_years_ago=$((-365*10*86400)) &&
370
test-tool chmtime =$just_10_years_ago .git/sharedindex.* &&
364
- : >fifteen &&
371
+ create_non_racy_file fifteen &&
372
git update-index --add fifteen &&
373
test $(ls .git/sharedindex.* | wc -l) -gt 2 &&
374
git config splitIndex.sharedIndexExpire now &&
375
just_1_second_ago=-1 &&
376
test-tool chmtime =$just_1_second_ago .git/sharedindex.* &&
370
- : >sixteen &&
377
+ create_non_racy_file sixteen &&
378
git update-index --add sixteen &&
379
test $(ls .git/sharedindex.* | wc -l) -le 2
380
'
389
# Create one new shared index file
390
git config core.sharedrepository "$mode" &&
391
git config core.splitIndex true &&
385
- : >one &&
392
+ create_non_racy_file one &&
393
git update-index --add one &&
394
echo "$modebits" >expect &&
395
test_modebits .git/index >actual &&