Skip to content

fix: support git global options (-C, -c, --git-dir, --work-tree)#192

Open
guillaumedeslandes wants to merge 1 commit intortk-ai:masterfrom
guillaumedeslandes:fix/git-global-options
Open

fix: support git global options (-C, -c, --git-dir, --work-tree)#192
guillaumedeslandes wants to merge 1 commit intortk-ai:masterfrom
guillaumedeslandes:fix/git-global-options

Conversation

@guillaumedeslandes
Copy link
Contributor

Summary

  • rtk git -C <path> status (and all other subcommands) was failing because Clap expected a subcommand immediately after git, rejecting global git flags like -C
  • Added -C, -c, --git-dir, --work-tree as Clap options on the Git command variant
  • Created a git_cmd() helper in git.rs that prepends global args before the subcommand, replacing all 27 Command::new("git") calls

Test plan

  • cargo fmt --all --check passes
  • cargo clippy --all-targets — no new warnings
  • cargo test — 381 tests pass (3 new unit tests for git_cmd() helper)
  • Manual: rtk git -C <path> status returns correct output
  • Manual: rtk git -C <path> log works
  • Manual: rtk git -C <path> tag --list (passthrough) works
  • Regression: rtk git status (no -C) still works

🤖 Generated with Claude Code

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>
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>
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.

1 participant

Comments