[PATCH v2 00/12] odb: make optimizations pluggable
From: Patrick Steinhardt <hidden>
Date: 2026-07-13 05:52:17
Hi,
this patch series converts object housekeeping to become pluggable.
There isn't really anything else to say about this.
The series is built on top of f85a7e6620 (Start Git 2.56 cycle,
2026-07-06).
Changes in v2:
- Make tests in t7900 a bit more robust by not checking for exact
commands, but instead by checking for executed tasks.
- Link to v1: https://patch.msgid.link/20260707-b4-pks-odb-optimize-v1-0-aae607667be4@pks.im
Thanks!
Patrick
---
Patrick Steinhardt (12):
t7900: simplify how we check for maintenance tasks
odb: run "pre-auto-gc" hook for all maintenance tasks
builtin/gc: move worktree and rerere tasks before object optimizations
builtin/gc: extract object database optimizations into separate function
builtin/gc: make repack arguments self-contained
builtin/gc: inline config values specific to the "files" backend
builtin/gc: introduce object database optimization options
builtin/gc: move geometric repacking into `odb_optimize()`
builtin/gc: introduce `odb_optimize_required()`
builtin/gc: refactor ODB optimizations to operate on "files" source
builtin/gc: fix signedness issues in ODB-related functionality
odb: make optimizations pluggable
builtin/gc.c | 534 ++++++++-----------------------------------------
odb.c | 12 ++
odb.h | 45 +++++
odb/source-files.c | 470 +++++++++++++++++++++++++++++++++++++++++++
odb/source-files.h | 15 ++
odb/source.h | 36 ++++
t/t7900-maintenance.sh | 338 +++++++++++++++++++++----------
7 files changed, 894 insertions(+), 556 deletions(-)
Range-diff versus v1:
-: ---------- > 1: b05988c150 t7900: simplify how we check for maintenance tasks
1: df9ed71c10 ! 2: 734d3c6d17 odb: run "pre-auto-gc" hook for all maintenance tasks
@@ t/t7900-maintenance.sh: test_expect_success 'geometric repacking honors configur
+ git maintenance run --auto 2>/dev/null &&
+
+ # The successful hook does not inhibit any of the tasks...
-+ test_subcommand git reflog expire --all <trace2.txt &&
-+ test_subcommand_flex git repack <trace2.txt &&
-+ test_subcommand git rerere gc <trace2.txt &&
++ test_maintenance_tasks trace2.txt <<-\EOF &&
++ reflog-expire foreground
++ geometric-repack
++ rerere-gc
++ EOF
+ # ... but it must only have been executed a single time.
+ test_line_count = 1 hook.log
+ )
@@ t/t7900-maintenance.sh: test_expect_success 'geometric repacking honors configur
+ # is expected to be the only child process being spawned, and
+ # it must only run a single time.
+ test_grep "child_start.*pre-auto-gc" trace2.txt &&
-+ test_subcommand_flex ! git trace2 &&
++ test_maintenance_tasks trace2.txt <<-\EOF &&
++ EOF
+ test_line_count = 1 hook.log
+ )
+'
@@ t/t7900-maintenance.sh: test_expect_success 'geometric repacking honors configur
+ # is expected to be the only child process being spawned, and
+ # it must only run a single time.
+ test_grep "child_start.*pre-auto-gc" trace2.txt &&
++ test_maintenance_tasks trace2.txt <<-\EOF &&
++ EOF
+ test_subcommand_flex ! git trace2 &&
+ test_line_count = 1 hook.log
+ )
2: ba358cede1 = 3: a61f01a1c1 builtin/gc: move worktree and rerere tasks before object optimizations
3: ffbaf71f46 = 4: 3d6ea9927b builtin/gc: extract object database optimizations into separate function
4: 7b568dcd0c = 5: de2c2c084d builtin/gc: make repack arguments self-contained
5: e18465b4b2 = 6: 0b4f6a553d builtin/gc: inline config values specific to the "files" backend
6: 4ee5a61e44 = 7: e231c437ba builtin/gc: introduce object database optimization options
7: 2b428d4516 ! 8: b015c35c8a builtin/gc: move geometric repacking into `odb_optimize()`
@@ t/t7900-maintenance.sh: test_expect_success 'geometric repacking honors configur
)
'
-@@ t/t7900-maintenance.sh: test_expect_success 'maintenance.strategy is respected' '
- test_strategy geometric <<-\EOF &&
- git pack-refs --all --prune
- git reflog expire --all
-- git repack -d -l --geometric=2 --quiet --write-midx
-+ git repack -d -l -q --geometric=2 --write-midx
- git commit-graph write --split --reachable --no-progress
- git worktree prune --expire 3.months.ago
- git rerere gc
-@@ t/t7900-maintenance.sh: test_expect_success 'maintenance.strategy is respected' '
- test_strategy geometric --schedule=weekly <<-\EOF
- git pack-refs --all --prune
- git reflog expire --all
-- git repack -d -l --geometric=2 --quiet --write-midx
-+ git repack -d -l -q --geometric=2 --write-midx
- git commit-graph write --split --reachable --no-progress
- git worktree prune --expire 3.months.ago
- git rerere gc
8: 79c3d77210 = 9: 426a06b349 builtin/gc: introduce `odb_optimize_required()`
9: 15f65ab0bf = 10: cfb6014c30 builtin/gc: refactor ODB optimizations to operate on "files" source
10: 9035d7d679 = 11: a478e0e0b3 builtin/gc: fix signedness issues in ODB-related functionality
11: 8fa84c3aa0 = 12: 5383b9027c odb: make optimizations pluggable
---
base-commit: f85a7e662054a7b0d9070e432508831afa214b47
change-id: 20260612-b4-pks-odb-optimize-3426c57e5c30