]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/maintenance: introduce "reflog-expire" task
authorPatrick Steinhardt <ps@pks.im>
Tue, 8 Apr 2025 06:22:17 +0000 (08:22 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 8 Apr 2025 14:53:27 +0000 (07:53 -0700)
commit8e0a1ec0762405e045d924eed68b872fd29844c9
tree425bf86da49083ab267a2c403f5bbc229e21005c
parent3fef24ac3fbcc6ad9e325a293b59ee38645f2407
builtin/maintenance: introduce "reflog-expire" task

By default, git-maintenance(1) uses the "gc" task to ensure that the
repository is well-maintained. This can be changed, for example by
either explicitly configuring which tasks should be enabled or by using
the "incremental" maintenance strategy. If so, git-maintenance(1) does
not know to expire reflog entries, which is a subtask that git-gc(1)
knows to perform for the user. Consequently, the reflog will grow
indefinitely unless the user manually trims it.

Introduce a new "reflog-expire" task that plugs this gap:

  - When running the task directly, then we simply execute `git reflog
    expire --all`, which is the same as git-gc(1).

  - When running git-maintenance(1) with the `--auto` flag, then we only
    run the task in case the "HEAD" reflog has at least N reflog entries
    that would be discarded. By default, N is set to 100, but this can
    be configured via "maintenance.reflog-expire.auto". When a negative
    integer has been provided we always expire entries, zero causes us
    to never expire entries, and a positive value specifies how many
    entries need to exist before we consider pruning the entries.

Note that the condition for the `--auto` flags is merely a heuristic and
optimized for being fast. This is because `git maintenance run --auto`
will be executed quite regularly, so scanning through all reflogs would
likely be too expensive in many repositories.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/maintenance.adoc
Documentation/git-maintenance.adoc
builtin/gc.c
t/t7900-maintenance.sh