]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/maintenance: fix locking race with refs and reflogs tasks
authorPatrick Steinhardt <ps@pks.im>
Tue, 3 Jun 2025 14:01:17 +0000 (16:01 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Jun 2025 15:30:51 +0000 (08:30 -0700)
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>
builtin/gc.c

index 72a695853e5418e3c61281c84cd85f9d6e766032..fdd0dd09be7dcd75242556fa286c2dbf143c4342 100644 (file)
@@ -1587,12 +1587,12 @@ static const struct maintenance_task tasks[] = {
        },
        [TASK_PACK_REFS] = {
                .name = "pack-refs",
-               .background = maintenance_task_pack_refs,
+               .foreground = maintenance_task_pack_refs,
                .auto_condition = pack_refs_condition,
        },
        [TASK_REFLOG_EXPIRE] = {
                .name = "reflog-expire",
-               .background = maintenance_task_reflog_expire,
+               .foreground = maintenance_task_reflog_expire,
                .auto_condition = reflog_expire_condition,
        },
        [TASK_WORKTREE_PRUNE] = {