Skip to content

fix: find the git sub-command after global options in read-only mode - #3357

Merged
zhayujie merged 1 commit into
zhayujie:masterfrom
drakeo338:claude/3355-fix
Oct 1, 2026
Merged

zhayujie merged 1 commit into
zhayujie:masterfrom
drakeo338:claude/3355-fix

Conversation

@drakeo338

Copy link
Copy Markdown
Contributor

Fixes #3355.

In read-only mode, _check_git_read_only() took the first non-dash argument as the git sub-command, so git -C <dir> status or git -c k=v log was refused with a message naming the path or value. It now skips git's leading global options, including the ones that take a value, before finding the sub-command. -c and -C were also in the shared write-flag list, which would have denied git -c ... log, so they are now treated as write flags only for git branch.

What does this PR do?

See above.

Type of change

  • Bug fix
  • New feature
  • Docs
  • Refactor / chore

Checklist

In read-only mode, `git -C dir status` and `git -c k=v log` were refused
because the value of the global option was taken as the sub-command. Skip
git's leading global options first, and stop treating -c/-C as write flags
of every sub-command (only `git branch` uses them to copy a branch).
@zhayujie
zhayujie merged commit faf8d5f into zhayujie:master Oct 1, 2026
@zhayujie

zhayujie commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Merged — thanks for your first contribution!

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.

[Bug] read-only mode refuses valid git reads that use a global option (\git -C <dir> status\), blaming a path

2 participants