diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-03-25 11:03:32 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-03-25 09:54:07 -0700 |
commit | bfc2f9eb8e83f394cc397f978c833edced507923 (patch) | |
tree | a8eb857a4de1286dcff6967887f315487e8cbf3b /t | |
parent | 77257e3c7e342acc0022c8c206db6c248cbfeb85 (diff) | |
download | git-bfc2f9eb8e83f394cc397f978c833edced507923.tar.gz |
builtin/gc: forward git-gc(1)'s `--auto` flag when packing refs
Forward the `--auto` flag to git-pack-refs(1) when it has been invoked
with this flag itself. This does not change anything for the "files"
backend, which will continue to eagerly pack refs. But it does ensure
that the "reftable" backend only compacts refs as required.
This change does not impact git-maintenance(1) because this command will
in fact never run the pack-refs task when run with `--auto`. This issue
will be addressed in a subsequent commit.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t0610-reftable-basics.sh | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/t/t0610-reftable-basics.sh b/t/t0610-reftable-basics.sh index 6de7529575..b37d8bf3b1 100755 --- a/t/t0610-reftable-basics.sh +++ b/t/t0610-reftable-basics.sh @@ -387,7 +387,9 @@ test_expect_success 'pack-refs: compaction raises locking errors' ' test_cmp expect err ' -test_expect_success 'pack-refs: auto compaction' ' +for command in pack-refs gc +do +test_expect_success "$command: auto compaction" ' test_when_finished "rm -rf repo" && git init repo && ( @@ -395,14 +397,24 @@ test_expect_success 'pack-refs: auto compaction' ' test_commit A && + # We need a bit of setup to ensure that git-gc(1) actually + # triggers, and that it does not write anything to the refdb. + git config gc.auto 1 && + git config gc.autoDetach 0 && + git config gc.reflogExpire never && + git config gc.reflogExpireUnreachable never && + test_oid blob17_1 | git hash-object -w --stdin && + # The tables should have been auto-compacted, and thus auto # compaction should not have to do anything. ls -1 .git/reftable >tables-expect && test_line_count = 4 tables-expect && - git pack-refs --auto && + git $command --auto && ls -1 .git/reftable >tables-actual && test_cmp tables-expect tables-actual && + test_oid blob17_2 | git hash-object -w --stdin && + # Lock all tables write some refs. Auto-compaction will be # unable to compact tables and thus fails gracefully, leaving # the stack in a sub-optimal state. @@ -416,10 +428,11 @@ test_expect_success 'pack-refs: auto compaction' ' rm .git/reftable/*.lock && test_line_count = 5 .git/reftable/tables.list && - git pack-refs --auto && + git $command --auto && test_line_count = 1 .git/reftable/tables.list ) ' +done test_expect_success 'pack-refs: prunes stale tables' ' test_when_finished "rm -rf repo" && |