Skip to content

Commit c0441f7

Browse files
chriscoolgitster
authored andcommitted
t1700: test shared index file expiration
Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b968372 commit c0441f7

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

t/t1700-split-index.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,4 +310,48 @@ test_expect_success 'check splitIndex.maxPercentChange set to 0' '
310310
test_cmp expect actual
311311
'
312312

313+
test_expect_success 'shared index files expire after 2 weeks by default' '
314+
: >ten &&
315+
git update-index --add ten &&
316+
test $(ls .git/sharedindex.* | wc -l) -gt 1 &&
317+
just_under_2_weeks_ago=$((5-14*86400)) &&
318+
test-chmtime =$just_under_2_weeks_ago .git/sharedindex.* &&
319+
: >eleven &&
320+
git update-index --add eleven &&
321+
test $(ls .git/sharedindex.* | wc -l) -gt 1 &&
322+
just_over_2_weeks_ago=$((-1-14*86400)) &&
323+
test-chmtime =$just_over_2_weeks_ago .git/sharedindex.* &&
324+
: >twelve &&
325+
git update-index --add twelve &&
326+
test $(ls .git/sharedindex.* | wc -l) = 1
327+
'
328+
329+
test_expect_success 'check splitIndex.sharedIndexExpire set to 16 days' '
330+
git config splitIndex.sharedIndexExpire "16.days.ago" &&
331+
test-chmtime =$just_over_2_weeks_ago .git/sharedindex.* &&
332+
: >thirteen &&
333+
git update-index --add thirteen &&
334+
test $(ls .git/sharedindex.* | wc -l) -gt 1 &&
335+
just_over_16_days_ago=$((-1-16*86400)) &&
336+
test-chmtime =$just_over_16_days_ago .git/sharedindex.* &&
337+
: >fourteen &&
338+
git update-index --add fourteen &&
339+
test $(ls .git/sharedindex.* | wc -l) = 1
340+
'
341+
342+
test_expect_success 'check splitIndex.sharedIndexExpire set to "never" and "now"' '
343+
git config splitIndex.sharedIndexExpire never &&
344+
just_10_years_ago=$((-365*10*86400)) &&
345+
test-chmtime =$just_10_years_ago .git/sharedindex.* &&
346+
: >fifteen &&
347+
git update-index --add fifteen &&
348+
test $(ls .git/sharedindex.* | wc -l) -gt 1 &&
349+
git config splitIndex.sharedIndexExpire now &&
350+
just_1_second_ago=-1 &&
351+
test-chmtime =$just_1_second_ago .git/sharedindex.* &&
352+
: >sixteen &&
353+
git update-index --add sixteen &&
354+
test $(ls .git/sharedindex.* | wc -l) = 1
355+
'
356+
313357
test_done

0 commit comments

Comments
 (0)