Skip to content

Resolve Git Bash Drive-Prefixed Paths in the Primary-Checkout Rule on Windows #2460

Closed

Description

@ptr727

What happens

On Windows, Claude Code's Bash tool runs Git Bash. MSYS converts a POSIX-style path argument before git.exe sees it, and the guard reads the command text without that conversion. Its primary-checkout rule can then resolve a directory other than the one git acts on.

  • A drive-prefixed spelling such as git -C /c/repos/Example reset --hard reaches git as C:/repos/Example. The guard joins it as a path with no drive and gets <drive>:\c\repos\Example.
  • That directory holds no repository, so the primary-checkout check answers unresolvable, and the rule fails open, as it does for any target it cannot resolve.
  • The same applies to a leading cd /c/..., to --work-tree and --git-dir, and to a GIT_WORK_TREE= or GIT_DIR= prefix.
  • A rooted path with no drive, such as /primary, is converted by MSYS to a path under the Git install root. The guard reads it on the base's drive instead.

This is older than #2458, and the fix for #2458 leaves the rule unchanged. It is reasoned from MSYS's argument conversion and has not been reproduced on a native host. The form of the cwd the hook receives on Windows is also unverified, and it decides whether relative spellings are affected too.

Done means

  • On Windows, the rule resolves /<letter>/... as <LETTER>:/..., the way MSYS does.
  • A self-test case covers each spelling, and a native Windows run confirms that the drive-prefixed form is denied in a primary checkout.

Activity

  1. added
    bug
    agents
    pre-existing
    on Oct 7, 2026
  2. added a commit that references this issue on Oct 7, 2026
    ac50fd1
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

    agentsbugpre-existing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions