Skip to content

Strip Only the Remote From a Remote-Tracking Push Target in the Write Guard #2973

Closed

Description

@ptr727

Context

A local review of the change closing #2962 found these. Develop's guard reads both the same way, and the fix for #2962 changes only the local branch read. Neither has been run against git itself, so each rests on git's documented --abbrev-ref behavior.

A Remote-Tracking Push Target Can Lose More or Less Than Its Remote

_read_branch strips the first / segment from the @{push} read as the remote name. Two shapes break that:

  • A local branch named like a remote-tracking ref, such as origin/develop, makes --abbrev-ref print remotes/origin/develop for the real remote-tracking ref, which strips to origin/develop. A bare push under push.default=upstream with upstream origin/develop is then checked against the rules for origin/develop, finds none, and passes, though it updates develop.
  • A remote whose name holds a slash, such as up/stream, strips up/stream/develop to stream/develop.

Possible Direction

Also read the name with a leading remotes/<remote>/ stripped. For a slash-named remote, resolve the remote names with git remote and strip the longest one that matches, or read --symbolic-full-name without --abbrev-ref and match it against refs/remotes/<remote>/.

Activity

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

    @ptr727
    OwnerAuthor

    Claim (engineering round 25, push-target guard lane with #3005, #3007, #2973): branch feature/guard-push-targets, files host-setup/agent-safety/claude/gh-write-guard.py and host-setup/agent-safety/claude/test_install.py.

  3. ptr727 commented on Oct 14, 2026

    @ptr727
    OwnerAuthor

    Claim update: the push-target guard lane branch is feature/3005-3007-2973-guard-push-targets (renamed before its first push, since feature/guard-push-targets was the head of merged #3011). Files unchanged.

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