Skip to content

Let git pack-refs through the primary integration ref guard - #108

Merged
Yehonal merged 1 commit into
mainfrom
pr/pack-refs-guard
Sep 29, 2026
Merged

Yehonal merged 1 commit into
mainfrom
pr/pack-refs-guard

Conversation

@Yehonal

@Yehonal Yehonal commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

git gc --auto runs after ordinary commits, lane worktrees included, and its pack-refs step was refused by the reference-transaction guard:

error: refusing unauthorized primary integration ref move(s): refs/heads/main-integration 0000000 -> 17c9cd5.
fatal: ref updates aborted by hook
fatal: failed to run pack-refs

The commit itself lands, but maintenance never finishes, so loose refs and objects pile up.

Packing moves a loose ref in two transactions: 0 -> current into packed-refs, then current -> 0 to prune the loose copy. The guard read both as a move of the integration branch.

A line now passes when the ref still resolves to the same commit afterwards:

  • a new value equal to the current one (the pack step)
  • a prune whose old value is the current one and is already in packed-refs

Real moves and deletes of the integration ref are still refused. Deleting a packed ref always carries a 0 -> 0 line for the packed store, and a loose-only ref has no packed value to fall back to, so neither qualifies. A degraded guard lets packing through for every branch the same way.

The check runs before the ref-move authorization, so an authorized Syncwheel command's own gc --auto doesn't spend its single-use authorization on a no-op.

Tests cover pack-refs from the primary and from a linked worktree, armed and degraded, and check that every move and delete form still gets refused on the packed ref. Without the fix they fail with the exact error above.

Bumps to 0.45.1. Full suite: 990 tests OK.

git gc --auto runs pack-refs after ordinary commits, including in lane
worktrees. Packing writes the integration ref into packed-refs as
`0 -> current` and then prunes the loose copy as `current -> 0`, and the
reference-transaction guard refused both as an unauthorized move, so
repository maintenance never completed.

A line now passes when the ref still resolves to the same commit
afterwards. Real moves and deletes stay refused: deleting a packed ref
always carries a `0 -> 0` line for the packed store.
@Yehonal
Yehonal merged commit ddc5b3b into main Sep 29, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant