Skip to content

fix: support git commit -am, --amend and other flags (#327)#360

Merged
pszymkowiak merged 1 commit intomasterfrom
fix/git-commit-flags
Mar 6, 2026
Merged

fix: support git commit -am, --amend and other flags (#327)#360
pszymkowiak merged 1 commit intomasterfrom
fix/git-commit-flags

Conversation

@pszymkowiak
Copy link
Collaborator

Summary

  • rtk git commit -am "msg" crashed with error: unexpected argument '-a' found
  • Root cause: Clap only declared -m/--message, rejecting all other git commit flags
  • Fix: switch to trailing_var_arg + allow_hyphen_values (same pattern as Add, Push, Pull)

What changed

  • GitCommands::Commit now takes raw args: Vec<String> instead of message: Vec<String>
  • build_commit_command passes args directly to git instead of wrapping with -m
  • All git commit flags now work: -a, -am, --amend, --allow-empty, --no-edit, etc.

Tests

  • 4 new tests: -am, --amend, single message, multiple messages (updated)
  • 644 tests pass, 0 failures
  • Manual verification: -am, -m, --amend --no-edit all produce correct output

Fixes #327

🤖 Generated with Claude Code

Clap was rejecting -a, --amend, --allow-empty etc. because Commit only
declared -m/--message. Switch to trailing_var_arg like other git
subcommands so all flags pass through to git directly.

Fixes #327
@pszymkowiak pszymkowiak merged commit 409aed6 into master Mar 6, 2026
2 of 3 checks passed
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.

rtk git commit -am message fails

1 participant