Repository navigation
Pass everything after ktools git -- to git verbatim [patch] - #339
Open
matt-edmondson wants to merge 1 commit into
Open
matt-edmondson wants to merge 1 commit into
matt-edmondson wants to merge 1 commit into
Conversation
Spectre.Console.Cli still tokenizes the arguments after a '--', so `ktools git -- log -1` ran `git log -`, `-- clean -fdx` was rejected as three ktools options, and `-- grep -C2 foo` failed with "Short option does not have a valid name". Program now splits a `git` command line at its first '--' before Spectre parses it, and hands the tail to GitCommand through a GitPassThrough service, so git gets exactly the typed tokens. Flags written without the separator are still caught by the existing forgotten-separator check. Fixes #332 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW6DQQw6JpYVSCPgTzR
Contributor
Author
|
The The same checks are red on I don't know of a fix I could bring into this PR. #270, the bump to 3.2.0, is red as well because 3.2.0 needs a Six Labors license in CI (see ktsu-dev/IconHelper#155). Locally, with Generated by Claude Code |
This was referenced Oct 29, 2026
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.
Fixes #332
What was wrong
GitCommandbuilt git's argv fromcontext.Remaining.Rawon the assumption that a literal--keeps flags verbatim. It doesn't: Spectre.Console.Cli still tokenizes what follows the separator.-- log -1becamegit log -. That's the dangerous case, sincecheckout -andmerge -act on the previous branch.-- clean -fdx,-- branch -vvand-- commit -mwipwere rejected with "put it after--", even though the user already had.-- grep -C2 fooand-- diff -U5failed with "Short option does not have a valid name" (exit 255).The fix
GitPassThrough(KtsuTools/Commands/GitPassThrough.cs).Splittakes a command line whose first token isgitand cuts it at the first--. Spectre gets everything before the separator, and the tail is kept asArguments. Any other command line comes back unchanged, along withGitPassThrough.None. Any later--stays in the tail, because that one belongs to git's own pathspec syntax.Program.Mainnow calls a newProgram.Run(args, services). That method does the split, registers theGitPassThroughas a singleton, and runs theCommandAppon the shortened arguments. It is separate fromMainso tests can take exactly the shipped path.GitCommandtakes theGitPassThroughin its constructor and appends itsArgumentsaftersettings.ArgsandRemaining.Raw. The forgotten-separator check is unchanged, soktools git status --shortis still rejected instead of silently dropping--short.This follows the issue's suggestion to read the real argv after the first
--. Splitting beforeCommandApp.Runis necessary rather than optional: Spectre rejects-C2at parse time, before the command ever runs.Tests
All new tests are in
GitCommandTests:TheRealAppPassesEverythingAfterTheSeparatorToGitVerbatimruns throughProgram.Runwith a realCommandApp, as the issue's acceptance criteria ask. The cases arelog -1,log -3 -p,clean -fdx,branch -vv,grep -C2 foo,diff -U5andlog '--format=%an %s' -1, and each checks the exact argument string git receives.TheRealAppKeepsPositionalArgumentsBeforeTheSeparatorcoversgit log --path … -- -1, which should givelog -1.TheRealAppStillRejectsAFlagWrittenWithoutTheSeparatorcoversgit status --short, which should exit 1 and run nothing.Splitunit tests cover a later--staying in the tail, a non-git command being left alone, and a git command line with no separator being left alone.With
Splitturned into a no-op, so that Spectre sees the whole command line as it does onmain, all 8 separator cases fail. The rejection test passes either way. The full suite passes: 397/397.CI note
On
main, restore currently fails withNU1903: SixLabors.ImageSharp 3.1.12 has a known high-severity advisory. That failure is unrelated to this change, and it is the same one #334, #337 and #338 report. To run the build and tests above locally, I passed-p:WarningsNotAsErrors=NU1903.Generated by Claude Code