fix: support git global options (-C, -c, --git-dir, --work-tree)#192
Open
guillaumedeslandes wants to merge 1 commit intortk-ai:masterfrom
Open
fix: support git global options (-C, -c, --git-dir, --work-tree)#192guillaumedeslandes wants to merge 1 commit intortk-ai:masterfrom
guillaumedeslandes wants to merge 1 commit intortk-ai:masterfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rtk git -C <path> status(and all other subcommands) was failing because Clap expected a subcommand immediately aftergit, rejecting global git flags like-C-C,-c,--git-dir,--work-treeas Clap options on theGitcommand variantgit_cmd()helper ingit.rsthat prepends global args before the subcommand, replacing all 27Command::new("git")callsTest plan
cargo fmt --all --checkpassescargo clippy --all-targets— no new warningscargo test— 381 tests pass (3 new unit tests forgit_cmd()helper)rtk git -C <path> statusreturns correct outputrtk git -C <path> logworksrtk git -C <path> tag --list(passthrough) worksrtk git status(no-C) still works🤖 Generated with Claude Code