]> git.99rst.org Git - git.git/commit
odb: run "pre-auto-gc" hook for all maintenance tasks
authorPatrick Steinhardt <redacted>
Mon, 13 Jul 2026 05:52:05 +0000 (07:52 +0200)
committerJunio C Hamano <redacted>
Mon, 13 Jul 2026 15:13:16 +0000 (08:13 -0700)
commit37deb9b4be807643ef264738f7fa3dc97588e33d
tree090398ec5b4b89a6faf5f88a5b13d781727b22fb
parent368565e55d5cff377efaee5cf86f092709480314
odb: run "pre-auto-gc" hook for all maintenance tasks

The "pre-auto-gc" hook is supposed to run before auto-maintenance
starts. The intent of this is to give users the ability to intercept
running maintenance in case there's for example an event that is not
supposed to run in parallel with repository maintenance.

This hook runs via `need_to_gc()`, which is invoked via two paths:

  - It is called directly by git-gc(1).

  - It is called indirectly by git-maintenance(1) via the "gc" task.

While the former makes sense, the latter is somewhat off. While the hook
is indeed strongly tied to gc'ing a repository, the original intent of
the hook is rather to inhibit any kind of automated garbage collection.
That noticeably also includes all the other maintenance tasks that our
new infrastructure may run, but those aren't getting intercepted at all.
The move towards our new maintenance strategy has thus somewhat neutered
the effectiveness of the hook.

Fix this issue by running the hook before the first auto-maintenance
task that would run as determined by the tasks's auto condition. Note
that this requires us to lift the call to `run_hooks()` out of
`needs_to_gc()`, as the hook would otherwise potentially run multiple
times.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
builtin/gc.c
t/t7900-maintenance.sh
git clone https://git.99rst.org/PROJECT