t4200: make "rerere gc" test more robust

The test blindly trusted that there may be _some_ entries left in the rerere database, and used them by updating their timestamps to see if the gc threshold variables are honoured correctly. This won't work if there is no entry in the database when the test begins. Instead, clear the rerere database, and populate it with a few known entries (which are bogus, but for the purpose of testing "garbage collection", it does not matter---we want to make sure we collect old cruft, even if the files are corrupt rerere database entries), and use them for the expiry test. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Aug 22, 2017 at 14:14 UTC c277344182b6ff423b8395ea0bf7a75ee0db78e2
1 file changed +14 -5
t/t4200-rerere.sh
+14 -5
@@ -420,19 +420,28 @@ count_pre_post () {
420 }
421
422 test_expect_success 'rerere gc' '
423 - find .git/rr-cache -type f >original &&
424 - xargs test-chmtime -172800 <original &&
423 + rm -fr .git/rr-cache &&
424 + rr=.git/rr-cache/$_z40 &&
425 + mkdir -p "$rr" &&
426 + >"$rr/preimage" &&
427 + >"$rr/postimage" &&
428 +
429 + two_days_ago=$((-2*86400)) &&
430 + test-chmtime =$two_days_ago "$rr/preimage" &&
431 + test-chmtime =$two_days_ago "$rr/postimage" &&
432 +
433 + find .git/rr-cache -type f | sort >original &&
434
435 git -c gc.rerereresolved=5 -c gc.rerereunresolved=5 rerere gc &&
427 - find .git/rr-cache -type f >actual &&
436 + find .git/rr-cache -type f | sort >actual &&
437 test_cmp original actual &&
438
439 git -c gc.rerereresolved=5 -c gc.rerereunresolved=0 rerere gc &&
431 - find .git/rr-cache -type f >actual &&
440 + find .git/rr-cache -type f | sort >actual &&
441 test_cmp original actual &&
442
443 git -c gc.rerereresolved=0 -c gc.rerereunresolved=0 rerere gc &&
435 - find .git/rr-cache -type f >actual &&
444 + find .git/rr-cache -type f | sort >actual &&
445 >expect &&
446 test_cmp expect actual
447 '