Skip to content

Commit bcabbf9

Browse files
pks-tgitster
authored andcommitted
builtin/maintenance: fix locking race when packing refs and reflogs
As explained in the preceding commit, git-gc(1) knows to detach only after it has already packed references and 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 before detaching. 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9e0cfc8 commit bcabbf9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

builtin/gc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,12 +1577,12 @@ static const struct maintenance_task tasks[] = {
15771577
},
15781578
[TASK_PACK_REFS] = {
15791579
.name = "pack-refs",
1580-
.after_detach = maintenance_task_pack_refs,
1580+
.before_detach = maintenance_task_pack_refs,
15811581
.auto_condition = pack_refs_condition,
15821582
},
15831583
[TASK_REFLOG_EXPIRE] = {
15841584
.name = "reflog-expire",
1585-
.after_detach = maintenance_task_reflog_expire,
1585+
.before_detach = maintenance_task_reflog_expire,
15861586
.auto_condition = reflog_expire_condition,
15871587
},
15881588
[TASK_WORKTREE_PRUNE] = {

0 commit comments

Comments
 (0)