builtin/maintenance: fix locking race with refs and reflogs tasks

As explained in the preceding commit, git-gc(1) knows to detach only after it has already packed references and expired reflogs. This is done to avoid racing around their respective lockfiles. Adapt git-maintenance(1) accordingly and run the "pack-refs" and "reflog-expire" tasks in the foreground. Note that the "gc" task has the same issue, but the fix is a bit more involved there and will thus be done in a subsequent commit. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Jun 3, 2025 at 16:01 UTC c367852d9e3c114fe02e16f4d56f259f12188e2a
1 file changed +2 -2
builtin/gc.c
+2 -2
@@ -1587,12 +1587,12 @@ static const struct maintenance_task tasks[] = {
1587 },
1588 [TASK_PACK_REFS] = {
1589 .name = "pack-refs",
1590 - .background = maintenance_task_pack_refs,
1590 + .foreground = maintenance_task_pack_refs,
1591 .auto_condition = pack_refs_condition,
1592 },
1593 [TASK_REFLOG_EXPIRE] = {
1594 .name = "reflog-expire",
1595 - .background = maintenance_task_reflog_expire,
1595 + .foreground = maintenance_task_reflog_expire,
1596 .auto_condition = reflog_expire_condition,
1597 },
1598 [TASK_WORKTREE_PRUNE] = {