[PATCH 1/2] gc: add tests for --cruft and friends
- From
Emily Shaffer <emilyshaffer@google.com>
- Date
- Aug 3, 2022, 20:57 UTC
- Message-ID
- <20220803205721.3686361-2-emilyshaffer@google.com>
- In-Reply-To
- <20220803205721.3686361-1-emilyshaffer@google.com>
In 5b92477f89 (builtin/gc.c: conditionally avoid pruning objects via loose, 2022-05-20) gc learned to respect '--cruft' and 'gc.cruftPacks'. '--cruft' is exercised in t5329-pack-objects-cruft.sh, but in a way that doesn't check whether a lone gc run generates these cruft packs. 'gc.cruftPacks' is never exercised.
Add some tests to exercise these options to gc in the gc test suite.
Signed-off-by: Emily Shaffer <emilyshaffer@google.com> --- t/t6500-gc.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh index cd6c53360d..e4c2c3583d 100755 --- a/t/t6500-gc.sh +++ b/t/t6500-gc.sh @@ -202,6 +202,42 @@ test_expect_success 'one of gc.reflogExpire{Unreachable,}=never does not skip "e grep -E "^trace: (built-in|exec|run_command): git reflog expire --" trace.out ' +test_expect_success 'gc --cruft generates a cruft pack' ' + git init crufts && + test_when_finished "rm -fr crufts" && + ( + cd crufts && + test_commit base && + + test_commit --no-tag foo && + test_commit --no-tag bar && + git reset HEAD^^ && + + git gc --cruft && + + cruft=$(basename $(ls .git/objects/pack/pack-*.mtimes) .mtimes) && + test_path_is_file .git/objects/pack/$cruft.pack + ) +' + +test_expect_success 'gc.cruftPacks=true generates a cruft pack' ' + git init crufts && + test_when_finished "rm -fr crufts" && + ( + cd crufts && + test_commit base && + + test_commit --no-tag foo && + test_commit --no-tag bar && + git reset HEAD^^ && + + git -c gc.cruftPacks=true gc && + + cruft=$(basename $(ls .git/objects/pack/pack-*.mtimes) .mtimes) && + test_path_is_file .git/objects/pack/$cruft.pack + ) +' + run_and_wait_for_auto_gc () { # We read stdout from gc for the side effect of waiting until the # background gc process exits, closing its fd 9. Furthermore, the
-- 2.37.1.455.g008518b4e5-goog