Skip to content

Read a Bare Push's Destination From Branch Config, Not a Remote-Tracking Ref, in the Write Guard #3019

Closed

Description

@ptr727

Context

Found by the local review of the change closing #2973. Develop's guard shares both shapes. Each was confirmed against git 2.47.3 in throwaway repositories, with git push --dry-run --porcelain showing what a bare push writes.

A Bare Push's Branch Is Read From the Remote-Tracking Ref, Not the Remote Branch

_current_push_branch reads @{push}, which names the remote-tracking ref a push updates, and derives the remote branch from that ref's name. Two shapes make the two differ:

  • A fetch refspec that maps into a sub-path of the remote's own namespace, such as +refs/heads/*:refs/remotes/origin/mirror/*. With push.default=upstream and branch.feature/example.merge=refs/heads/develop, @{push} is refs/remotes/origin/mirror/develop. The guard reads mirror/develop and allows, while git writes develop.
  • No remote-tracking ref for the destination, such as a --single-branch clone of another branch, or one never fetched. With push.default=upstream and the merge ref refs/heads/develop, @{push} fails with "not stored as a remote-tracking branch". The read then falls back to --abbrev-ref HEAD, reads feature/example, and allows, while git writes develop.

Possible Direction

Read the destination from the branch's own configuration rather than from a remote-tracking ref name. branch.<name>.merge names the upstream branch for push.default=upstream, and the current name is the destination for current. Where push.default cannot be read, read both, and fail closed where neither resolves.

Activity

  1. added
    script
    on Oct 14, 2026
  2. ptr727 commented on Oct 15, 2026

    @ptr727
    OwnerAuthor

    Claimed for an engineering-track lane (handoff #3040 resume). Branch: feature/guard-bare-push-target-3019. Predicted file set: host-setup/agent-safety/claude/gh-write-guard.py, host-setup/agent-safety/claude/test_install.py, host-setup/agent-safety/README.md, host-setup/agent-safety/claude/README.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    script

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions