Skip to content

fix: support git global options (-C, -c, --git-dir, --work-tree, --no-pager, --no-optional-locks, --bare, --literal-pathspecs)#192

Merged
aeppling merged 3 commits intortk-ai:masterfrom
guillaumedeslandes:fix/git-global-options
Mar 3, 2026
Merged

fix: support git global options (-C, -c, --git-dir, --work-tree, --no-pager, --no-optional-locks, --bare, --literal-pathspecs)#192
aeppling merged 3 commits intortk-ai:masterfrom
guillaumedeslandes:fix/git-global-options

Conversation

@guillaumedeslandes
Copy link
Contributor

@guillaumedeslandes guillaumedeslandes commented Feb 18, 2026

Summary

  • Add support for git global options that were previously rejected by Clap CLI parsing
  • First commit: -C, -c, --git-dir, --work-tree (value-taking options)
  • Second commit: --no-pager, --no-optional-locks, --bare, --literal-pathspecs (boolean flags)
  • The hook (rtk-rewrite.sh) already strips these flags for subcommand matching, but RTK's Clap definition was rejecting them at parse time

Test plan

  • Clap parsing test: rtk git --no-pager --no-optional-locks status parses correctly
  • git_cmd() test: boolean flags are prepended before subcommand args
  • All 419 tests pass (cargo test)
  • cargo fmt --all --check passes
  • cargo clippy --all-targets passes (no new warnings)

🤖 Generated with Claude Code

edsai added a commit to edsai/rtk that referenced this pull request Feb 19, 2026
The hook rewrites `grep -rn` to `rtk grep -rn`, but Clap rejected
`-r` as an unknown flag. This caused "unexpected argument" errors
that prevented rtk from filtering grep output.

- Add `-r`/`--recursive` as a no-op flag (rg is recursive by default)
- Add `-i`/`--ignore-case` as a proper flag that passes through to rg
- Fix test compilation: add empty global_args to run_branch and
  build_commit_command calls, add `..` to ignore new Git fields
- Update git -C test to expect success (PR rtk-ai#192 added -C support)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
edsai added a commit to edsai/rtk that referenced this pull request Feb 19, 2026
The hook rewrites `grep -rn` to `rtk grep -rn`, but Clap rejected
`-r` as an unknown flag. This caused "unexpected argument" errors
that prevented rtk from filtering grep output.

- Add `-r`/`--recursive` as a no-op flag (rg is recursive by default)
- Add `-i`/`--ignore-case` as a proper flag that passes through to rg
- Fix test compilation: add empty global_args to run_branch and
  build_commit_command calls, add `..` to ignore new Git fields
- Update git -C test to expect success (PR rtk-ai#192 added -C support)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
edsai added a commit to edsai/rtk that referenced this pull request Feb 19, 2026
The hook rewrites `grep -rn` to `rtk grep -rn`, but Clap rejected
`-r` as an unknown flag. This caused "unexpected argument" errors
that prevented rtk from filtering grep output.

- Add `-r`/`--recursive` as a no-op flag (rg is recursive by default)
- Add `-i`/`--ignore-case` as a proper flag that passes through to rg
- Fix test compilation: add empty global_args to run_branch and
  build_commit_command calls, add `..` to ignore new Git fields
- Update git -C test to expect success (PR rtk-ai#192 added -C support)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pszymkowiak pszymkowiak linked an issue Feb 20, 2026 that may be closed by this pull request
@pszymkowiak
Copy link
Collaborator

This PR should also cover --no-pager, --no-optional-locks, --bare, and --literal-pathspecs to close #228.

@samhavens
Copy link

👀

Why does rtk error instead of doing a raw passthrough for valid but unhandled options / subcommands?

@guillaumedeslandes guillaumedeslandes changed the title fix: support git global options (-C, -c, --git-dir, --work-tree) fix: support git global options (-C, -c, --git-dir, --work-tree, --no-pager, --no-optional-locks, --bare, --literal-pathspecs) Feb 23, 2026
@guillaumedeslandes
Copy link
Contributor Author

This PR should also cover --no-pager, --no-optional-locks, --bare, and --literal-pathspecs to close #228.

@pszymkowiak Rebased and added support for these options.

heAdz0r added a commit to heAdz0r/rtk that referenced this pull request Feb 28, 2026
…tk-ai#217, rtk-ai#196, rtk-ai#248, rtk-ai#211, rtk-ai#200, rtk-ai#192, rtk-ai#268)

Wave 1 (critical bugs):
- fix(registry): fi/done moved to IGNORED_EXACT — find no longer shadowed (rtk-ai#246)
- fix(playwright): f64 duration, specs[] structure, --reporter=json after subcmd (rtk-ai#193)
- fix(gh): should_passthrough_gh_view for --json/--jq/--template/--web in view_pr/issue/run (rtk-ai#217+196)

Wave 2 (reliability):
- fix(git): is_blob_show_arg — blob show passthrough without trailing-newline trim (rtk-ai#248)
- fix(find): parse_find_args with native -name/-type/-maxdepth/-iname support (rtk-ai#211)
- fix(main): graceful Clap fallback + parse_failures SQLite table + rtk gain --failures (rtk-ai#200)

Wave 3 (UX):
- feat(git): global options -C/-c/--git-dir/--work-tree/--no-pager/--no-optional-locks/--bare/--literal-pathspecs (rtk-ai#192)
- feat(proxy): streaming output via spawn()+threads instead of buffered output() (rtk-ai#268)

Tests: 1091 → 1117 (+26), 0 regressions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pszymkowiak
Copy link
Collaborator

Please rebase on master before we can merge — there are conflicts in src/git.rs and src/main.rs.

guillaumedeslandes and others added 3 commits March 1, 2026 12:54
git -C <path> and other global options were rejected because Clap
expected a subcommand immediately after `git`. Add these options to
the Git command variant and thread them through all git subcommand
handlers via a git_cmd() helper that prepends global args before
the subcommand.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…-locks, --bare, --literal-pathspecs)

Extends the existing git global options support to accept boolean flags
that the hook already strips for subcommand matching but Clap was rejecting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@guillaumedeslandes
Copy link
Contributor Author

Please rebase on master before we can merge — there are conflicts in src/git.rs and src/main.rs.

@pszymkowiak Done.

@pszymkowiak
Copy link
Collaborator

Hi, this PR has conflicts with master in src/git.rs and src/main.rs. Could you rebase on current master? Thanks!

@aeppling aeppling merged commit a6ccefe into rtk-ai:master Mar 3, 2026
3 checks passed
@aeppling
Copy link
Contributor

aeppling commented Mar 3, 2026

merged will be available in next release

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

git global options (like --no-pager) before subcommands don't work

4 participants