Skip to content

Read a Dash-Named Refspec After End-of-Options in the Write Guard #3029

Closed

Description

@ptr727

Context

Found by the local review of the change closing #3007. Develop's guard shares it. It was confirmed against git 2.47.3 in a throwaway repository, where git update-ref created a local ref whose name starts with --.

A Refspec After -- or --end-of-options That Starts With a Dash Is Not Read

Git's option parser ends options at a bare -- or at --end-of-options, and reads every later word as a positional, a dash-named one included. _push_targets' option loop has no such boundary, so it reads a later dash-named word as an option or drops it, and never as a refspec. With a local ref named like --x, git push origin -- --x:refs/heads/develop writes develop. The guard reads only the remote, takes the push as a bare push of the current branch, and allows it from a feature branch.

The change closing #3007 stops a --no-prune after the boundary from cancelling --prune. Every other option the loop reads only adds an op, so reading those past the boundary over-denies rather than allows.

Possible Direction

Read every word after the first -- or --end-of-options as a positional, the rule _args_before_double_dash already states for git clean. Keep reading those words for the ops they would add, so no verdict develop denies becomes an allow, and add a case for a dash-named refspec after each boundary.

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