Skip to content

fix: git branch creation silently swallowed by list mode#194

Merged
pszymkowiak merged 1 commit intortk-ai:masterfrom
guillaumedeslandes:fix/git-branch-creation-swallowed
Feb 18, 2026
Merged

fix: git branch creation silently swallowed by list mode#194
pszymkowiak merged 1 commit intortk-ai:masterfrom
guillaumedeslandes:fix/git-branch-creation-swallowed

Conversation

@guillaumedeslandes
Copy link
Contributor

Summary

  • Bug: rtk git branch <name> silently succeeded but never created the branch. The command fell into the listing code path which injected -a --no-color, turning creation into a pattern-filtered listing (empty output, exit 0).
  • Fix: Detect positional args (branch names) without list-mode flags and route to direct passthrough, so git branch <name> and git branch <name> <start-point> work correctly.
  • Scope: Only src/git.rs — the run_branch() function logic and two new regression integration tests.

Test plan

  • cargo fmt --all --check passes
  • cargo test --all — 378 tests pass
  • Integration tests (--ignored): test_branch_creation_not_swallowed and test_branch_creation_from_commit both pass
  • Manual verification: rtk git branch test-branch creates the branch, git branch --list test-branch confirms it exists
  • Manual verification: duplicate branch creation properly fails with exit 128
  • Listing mode (rtk git branch, rtk git branch -a) still works as before

🤖 Generated with Claude Code

`rtk git branch <name>` fell into the listing code path which injected
`-a --no-color`, turning the creation into a pattern-filtered listing
(silent no-op with exit 0). Detect positional args without list-mode
flags and route them to direct passthrough so branch creation, including
`git branch <name> <start-point>`, works correctly.

Adds regression integration tests for both cases.

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

Thank you! This was a nasty silent bug — rtk git branch feature-x doing nothing and returning exit 0 is really bad for users and agents.

The detection logic looks correct: positional args without list flags → creation passthrough, list flags → compact listing. I checked the edge case of --contains main and it's handled
correctly since --contains is in has_list_flag.

Good bonus adding std::process::exit() on failure and the two integration regression tests. LGTM, merging.

@pszymkowiak pszymkowiak merged commit 88dc752 into rtk-ai:master Feb 18, 2026
2 of 3 checks passed
heAdz0r added a commit to heAdz0r/rtk that referenced this pull request Feb 28, 2026
Upstream 0.22.2 sync (all previously missing fixes verified applied):
- fix(lint): propagate linter exit code (rtk-ai#207) — CI false-green fix
- feat: add rtk wc command for compact word/line/byte counts (rtk-ai#175)
- fix(playwright): JSON parser (specs layer) + binary resolution (rtk-ai#215)
- fix(grep): propagate rg exit codes 1/2 (rtk-ai#227)
- fix(git): branch creation not swallowed by list mode (rtk-ai#194)
- fix(git): support multiple -m flags in git commit (rtk-ai#202)
- fix(grep): BRE \| translation + strip -r flag (rtk-ai#206)
- fix(gh): smart markdown body filter for issue/pr view (rtk-ai#214)
- fix(gh): gh run view --log-failed flag passthrough (rtk-ai#159)
- feat(docker): docker compose support (rtk-ai#110)
- feat: hook audit mode (rtk-ai#151)
- feat: tee raw output to file (rtk-ai#134)

Version bump: 0.21.1-fork.19 → 0.22.2-fork.1

Co-Authored-By: Claude Sonnet 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.

2 participants