Merge branch 'ps/maintenance-geometric-default' into next

"git maintenance" starts using the "geometric" strategy by default.

* ps/maintenance-geometric-default:
  builtin/maintenance: use "geometric" strategy by default
  t7900: prepare for switch of the default strategy
  t6500: explicitly use "gc" strategy
  t5510: explicitly use "gc" strategy
  t5400: explicitly use "gc" strategy
  t34xx: don't expire reflogs where it matters
  t: disable maintenance where we verify object database structure
  t: fix races caused by background maintenance
This commit is contained in:
Junio C Hamano
2026-02-26 10:06:17 -08:00
23 changed files with 64 additions and 12 deletions

View File

@@ -30,8 +30,7 @@ The possible strategies are:
+
* `none`: This strategy implies no tasks are run at all. This is the default
strategy for scheduled maintenance.
* `gc`: This strategy runs the `gc` task. This is the default strategy for
manual maintenance.
* `gc`: This strategy runs the `gc` task.
* `geometric`: This strategy performs geometric repacking of packfiles and
keeps auxiliary data structures up-to-date. The strategy expires data in the
reflog and removes worktrees that cannot be located anymore. When the
@@ -40,7 +39,8 @@ The possible strategies are:
are already part of a cruft pack will be expired.
+
This repacking strategy is a full replacement for the `gc` strategy and is
recommended for large repositories.
recommended for large repositories. This is the default strategy for manual
maintenance.
* `incremental`: This setting optimizes for performing small maintenance
activities that do not delete any data. This does not schedule the `gc`
task, but runs the `prefetch` and `commit-graph` tasks hourly, the

View File

@@ -1980,7 +1980,7 @@ static void initialize_task_config(struct maintenance_run_opts *opts,
strategy = none_strategy;
type = MAINTENANCE_TYPE_SCHEDULED;
} else {
strategy = gc_strategy;
strategy = geometric_strategy;
type = MAINTENANCE_TYPE_MANUAL;
}

View File

@@ -1952,7 +1952,7 @@ int prepare_auto_maintenance(int quiet, struct child_process *maint)
*/
if (repo_config_get_bool(the_repository, "maintenance.autodetach", &auto_detach) &&
repo_config_get_bool(the_repository, "gc.autodetach", &auto_detach))
auto_detach = 1;
auto_detach = git_env_bool("GIT_TEST_MAINT_AUTO_DETACH", true);
maint->git_cmd = 1;
maint->close_object_store = 1;

View File

@@ -68,6 +68,7 @@ test_expect_success 'add more packfiles' '
'
test_expect_success 'add more commits (as loose objects)' '
test_config maintenance.auto false &&
test_commit six &&
test_commit seven &&

View File

@@ -31,6 +31,12 @@ Initial setup:
. "$TEST_DIRECTORY"/lib-rebase.sh
test_expect_success 'setup' '
# Commit dates are hardcoded to 2005, and the reflog entries will have
# a matching timestamp. Maintenance may thus immediately expire
# reflogs if it was running.
git config set gc.reflogExpire never &&
git config set gc.reflogExpireUnreachable never &&
git switch -C primary &&
test_commit A file1 &&
test_commit B file1 &&

View File

@@ -8,6 +8,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success 'setup' '
# Commit dates are hardcoded to 2005, and the reflog entries will have
# a matching timestamp. Maintenance may thus immediately expire
# reflogs if it was running.
git config set gc.reflogExpire never &&
git config set gc.reflogExpireUnreachable never &&
test_commit O fileO &&
test_commit X fileX &&
git branch fast-forward &&

View File

@@ -17,6 +17,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
# C was formerly part of main but main was rewound to remove C
#
test_expect_success setup '
# Commit dates are hardcoded to 2005, and the reflog entries will have
# a matching timestamp. Maintenance may thus immediately expire
# reflogs if it was running.
git config set gc.reflogExpire never &&
git config set gc.reflogExpireUnreachable never &&
test_commit A &&
test_commit B &&
test_commit C &&

View File

@@ -11,6 +11,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success setup '
# Commit dates are hardcoded to 2005, and the reflog entries will have
# a matching timestamp. Maintenance may thus immediately expire
# reflogs if it was running.
git config set gc.reflogExpire never &&
git config set gc.reflogExpireUnreachable never &&
test_commit A &&
test_commit B &&
test_commit C &&

View File

@@ -48,6 +48,7 @@ test_description='pack-objects breaks long cross-pack delta chains'
# repeatedly-modified file to generate the delta chain).
test_expect_success 'create series of packs' '
test_config maintenance.auto false &&
test-tool genrandom foo 4096 >content &&
prev= &&
for i in $(test_seq 1 10)

View File

@@ -1315,6 +1315,7 @@ test_expect_success 'bitmapped packs are stored via the BTMP chunk' '
git init repo &&
(
cd repo &&
git config set maintenance.auto false &&
for i in 1 2 3 4 5
do

View File

@@ -93,7 +93,8 @@ test_midx_bitmap_cases () {
test_expect_success 'setup test_repository' '
rm -rf * .git &&
git init &&
git config pack.writeBitmapLookupTable '"$writeLookupTable"'
git config pack.writeBitmapLookupTable '"$writeLookupTable"' &&
git config maintenance.auto false
'
midx_bitmap_core

View File

@@ -30,7 +30,8 @@ test_midx_bitmap_rev () {
test_expect_success 'setup bitmap config' '
rm -rf * .git &&
git init &&
git config pack.writeBitmapLookupTable '"$writeLookupTable"'
git config pack.writeBitmapLookupTable '"$writeLookupTable"' &&
git config maintenance.auto false
'
midx_bitmap_core rev

View File

@@ -14,6 +14,7 @@ packed_objects () {
test_expect_success 'setup for --stdin-packs tests' '
git init stdin-packs &&
git -C stdin-packs config set maintenance.auto false &&
(
cd stdin-packs &&
@@ -255,6 +256,7 @@ test_expect_success '--stdin-packs=follow walks into unknown packs' '
git init repo &&
(
cd repo &&
git config set maintenance.auto false &&
for c in A B C D
do

View File

@@ -59,6 +59,7 @@ test_pack_objects_reused () {
test_expect_success 'preferred pack is reused for single-pack reuse' '
test_config pack.allowPackReuse single &&
git config set maintenance.auto false &&
for i in A B
do

View File

@@ -15,6 +15,7 @@ midx_chain=$midxdir/multi-pack-index-chain
test_expect_success 'convert non-incremental MIDX to incremental' '
test_commit base &&
git config set maintenance.auto false &&
git repack -ad &&
git multi-pack-index write &&

View File

@@ -187,6 +187,7 @@ test_expect_success 'receive-pack runs auto-gc in remote repo' '
cd child &&
git config gc.autopacklimit 1 &&
git config gc.autodetach false &&
git config maintenance.strategy gc &&
git branch test_auto_gc &&
# And create a file that follows the temporary object naming
# convention for the auto-gc to remove

View File

@@ -154,7 +154,8 @@ test_expect_success 'clone shallow depth 1 with fsck' '
'
test_expect_success 'clone shallow' '
git clone --no-single-branch --depth 2 "file://$(pwd)/." shallow
git clone --no-single-branch --depth 2 "file://$(pwd)/." shallow &&
git -C shallow config set maintenance.auto false
'
test_expect_success 'clone shallow depth count' '

View File

@@ -1321,6 +1321,7 @@ test_expect_success 'fetching with auto-gc does not lock up' '
git config fetch.unpackLimit 1 &&
git config gc.autoPackLimit 1 &&
git config gc.autoDetach false &&
git config maintenance.strategy gc &&
GIT_ASK_YESNO="$TRASH_DIRECTORY/askyesno" git fetch --verbose >fetch.out 2>&1 &&
test_grep "Auto packing the repository" fetch.out &&
! grep "Should I try again" fetch.out

View File

@@ -229,7 +229,7 @@ test_expect_success 'fetch --refetch triggers repacking' '
GIT_TRACE2_EVENT="$PWD/trace1.event" \
git -C pc1 fetch --refetch origin &&
test_subcommand git maintenance run --auto --no-quiet --detach <trace1.event &&
test_subcommand git maintenance run --auto --no-quiet --no-detach <trace1.event &&
grep \"param\":\"gc.autopacklimit\",\"value\":\"1\" trace1.event &&
grep \"param\":\"maintenance.incremental-repack.auto\",\"value\":\"-1\" trace1.event &&
@@ -238,7 +238,7 @@ test_expect_success 'fetch --refetch triggers repacking' '
-c gc.autoPackLimit=0 \
-c maintenance.incremental-repack.auto=1234 \
-C pc1 fetch --refetch origin &&
test_subcommand git maintenance run --auto --no-quiet --detach <trace2.event &&
test_subcommand git maintenance run --auto --no-quiet --no-detach <trace2.event &&
grep \"param\":\"gc.autopacklimit\",\"value\":\"0\" trace2.event &&
grep \"param\":\"maintenance.incremental-repack.auto\",\"value\":\"-1\" trace2.event &&
@@ -247,7 +247,7 @@ test_expect_success 'fetch --refetch triggers repacking' '
-c gc.autoPackLimit=1234 \
-c maintenance.incremental-repack.auto=0 \
-C pc1 fetch --refetch origin &&
test_subcommand git maintenance run --auto --no-quiet --detach <trace3.event &&
test_subcommand git maintenance run --auto --no-quiet --no-detach <trace3.event &&
grep \"param\":\"gc.autopacklimit\",\"value\":\"1\" trace3.event &&
grep \"param\":\"maintenance.incremental-repack.auto\",\"value\":\"0\" trace3.event
'
@@ -585,6 +585,7 @@ test_expect_success 'verify fetch downloads only one pack when updating refs' '
git clone --filter=blob:none "file://$(pwd)/srv.bare" pack-test &&
ls pack-test/.git/objects/pack/*pack >pack-list &&
test_line_count = 2 pack-list &&
test_config -C pack-test maintenance.auto false &&
for i in A B C
do
test_commit -C src $i &&

View File

@@ -11,6 +11,7 @@ test_expect_success 'setup' '
# behavior, make sure we always pack everything to one pack by
# default
git config gc.bigPackThreshold 2g &&
git config set --global maintenance.strategy gc &&
test_oid_init
'

View File

@@ -217,6 +217,7 @@ test_expect_success 'repack --keep-pack' '
cd keep-pack &&
# avoid producing different packs due to delta/base choices
git config pack.window 0 &&
git config maintenance.auto false &&
P1=$(commit_and_pack 1) &&
P2=$(commit_and_pack 2) &&
P3=$(commit_and_pack 3) &&
@@ -260,6 +261,7 @@ test_expect_success 'repacking fails when missing .pack actually means missing o
# Avoid producing different packs due to delta/base choices
git config pack.window 0 &&
git config maintenance.auto false &&
P1=$(commit_and_pack 1) &&
P2=$(commit_and_pack 2) &&
P3=$(commit_and_pack 3) &&
@@ -534,6 +536,7 @@ test_expect_success 'setup for --write-midx tests' '
(
cd midx &&
git config core.multiPackIndex true &&
git config maintenance.auto false &&
test_commit base
)

View File

@@ -7,6 +7,9 @@ test_description='git maintenance builtin'
GIT_TEST_COMMIT_GRAPH=0
GIT_TEST_MULTI_PACK_INDEX=0
# Ensure that auto-maintenance detaches as usual.
sane_unset GIT_TEST_MAINT_AUTO_DETACH
test_lazy_prereq XMLLINT '
xmllint --version
'
@@ -42,7 +45,8 @@ test_expect_success 'help text' '
test_grep "usage: git maintenance" err
'
test_expect_success 'run [--auto|--quiet]' '
test_expect_success 'run [--auto|--quiet] with gc strategy' '
test_config maintenance.strategy gc &&
GIT_TRACE2_EVENT="$(pwd)/run-no-auto.txt" \
git maintenance run 2>/dev/null &&
GIT_TRACE2_EVENT="$(pwd)/run-auto.txt" \
@@ -496,6 +500,7 @@ test_expect_success 'maintenance.incremental-repack.auto' '
(
cd incremental-repack-true &&
git config core.multiPackIndex true &&
git config maintenance.auto false &&
run_incremental_repack_and_verify
)
'
@@ -506,6 +511,7 @@ test_expect_success 'maintenance.incremental-repack.auto (when config is unset)'
(
cd incremental-repack-unset &&
test_unconfig core.multiPackIndex &&
git config maintenance.auto false &&
run_incremental_repack_and_verify
)
'
@@ -616,6 +622,7 @@ test_expect_success 'geometric repacking with --auto' '
git init repo &&
(
cd repo &&
git config set maintenance.auto false &&
# An empty repository does not need repacking, except when
# explicitly told to do it.

View File

@@ -1957,6 +1957,10 @@ test_lazy_prereq COMPAT_HASH '
GIT_TEST_MAINT_SCHEDULER="none:exit 1"
export GIT_TEST_MAINT_SCHEDULER
# Ensure that tests cannot race with background maintenance by default.
GIT_TEST_MAINT_AUTO_DETACH="false"
export GIT_TEST_MAINT_AUTO_DETACH
# Does this platform support `git fsmonitor--daemon`
#
test_lazy_prereq FSMONITOR_DAEMON '