Repository navigation
Description
rtk git branch -vv drops commit hashes, the [origin/...] upstream tracking marker, and commit subjects — the very information -vv exists to show. filter_branch_output is designed around bare git branch -a output and has no handling for the verbose format, so metadata the user explicitly requested is silently discarded.
Reproduction
$ RTK_DISABLED=1 git branch -vv
feature-a abc12345 Some commit subject
feature-b def67890 Another commit subject
* main 12345678 [origin/main] Latest commit on main
$ rtk git branch -vv
* main
feature-a
feature-b
remote-only (3):
topic-x
agent/topic-y-abc123
topic-z
The upstream marker [origin/main], the commit hashes, and the subjects are gone. From the agent's point of view, git branch -vv is indistinguishable from git branch -a — the flag had no effect.
Cause
-vv isn't in the list-flag set at run_branch, so the command falls through to List mode:
Lines 1144 to 1164 in 80a6fe6
| // Detect list-mode flags | |
| let has_list_flag = args.iter().any(|a| { | |
| a == "-a" | |
| || a == "--all" | |
| || a == "-r" | |
| || a == "--remotes" | |
| || a == "--list" | |
| || a == "--merged" | |
| || a == "--no-merged" | |
| || a == "--contains" | |
| || a == "--no-contains" | |
| || a == "--format" | |
| || a.starts_with("--format=") | |
| || a == "--sort" | |
| || a.starts_with("--sort=") | |
| || a == "--points-at" | |
| || a.starts_with("--points-at=") | |
| }); | |
| // Detect positional arguments (not flags) — indicates branch creation | |
| let has_positional_arg = args.iter().any(|a| !a.starts_with('-')); |
List mode adds -a --no-color, passes -vv through to git, then pipes the result through filter_branch_output:
Lines 1234 to 1261 in 80a6fe6
| // List mode: show compact branch list | |
| let mut cmd = git_cmd(global_args); | |
| cmd.arg("branch"); | |
| if !has_list_flag { | |
| cmd.arg("-a"); | |
| } | |
| cmd.arg("--no-color"); | |
| for arg in args { | |
| cmd.arg(arg); | |
| } | |
| let result = exec_capture(&mut cmd).context("Failed to run git branch")?; | |
| if !result.success() { | |
| if !result.stderr.trim().is_empty() { | |
| eprint!("{}", result.stderr); | |
| } | |
| timer.track( | |
| &format!("git branch {}", args.join(" ")), | |
| &format!("rtk git branch {}", args.join(" ")), | |
| &result.stdout, | |
| &result.stdout, | |
| ); | |
| return Ok(result.exit_code); | |
| } | |
| let filtered = filter_branch_output(&result.stdout); | |
| println!("{}", filtered); |
filter_branch_output was designed for bare git branch -a output (see the test fixtures at lines 1885-1925 — none use -vv format) and reshapes everything into the compact * current + locals + remote-only block shown above. There's no code path that preserves [origin/...] markers or hash + subject when -vv is present:
Lines 1273 to 1328 in 80a6fe6
| fn filter_branch_output(output: &str) -> String { | |
| let mut current = String::new(); | |
| let mut local: Vec<String> = Vec::new(); | |
| let mut remote: Vec<String> = Vec::new(); | |
| let mut seen_remote: std::collections::HashSet<String> = std::collections::HashSet::new(); | |
| for line in output.lines() { | |
| let line = line.trim(); | |
| if line.is_empty() { | |
| continue; | |
| } | |
| if let Some(branch) = line.strip_prefix("* ") { | |
| current = branch.to_string(); | |
| } else if let Some(rest) = line.strip_prefix("remotes/") { | |
| if let Some(slash_pos) = rest.find('/') { | |
| let branch = &rest[slash_pos + 1..]; | |
| if branch.starts_with("HEAD ") { | |
| continue; | |
| } | |
| if seen_remote.insert(branch.to_string()) { | |
| remote.push(branch.to_string()); | |
| } | |
| } | |
| } else { | |
| local.push(line.to_string()); | |
| } | |
| } | |
| let mut result = Vec::new(); | |
| result.push(format!("* {}", current)); | |
| if !local.is_empty() { | |
| for b in &local { | |
| result.push(format!(" {}", b)); | |
| } | |
| } | |
| if !remote.is_empty() { | |
| let remote_only: Vec<&String> = remote | |
| .iter() | |
| .filter(|r| *r != ¤t && !local.contains(r)) | |
| .collect(); | |
| if !remote_only.is_empty() { | |
| result.push(format!(" remote-only ({}):", remote_only.len())); | |
| for b in remote_only.iter().take(10) { | |
| result.push(format!(" {}", b)); | |
| } | |
| if remote_only.len() > 10 { | |
| result.push(format!(" ... +{} more", remote_only.len() - 10)); | |
| } | |
| } | |
| } | |
| result.join("\n") | |
| } |
Impact
-vv is the canonical way to check upstream tracking state — "does my local branch have an upstream? is it ahead/behind?". When RTK answers the agent's git branch -vv with bare names, the agent has no way to see tracking configuration and may conclude branches have no upstream when they do. RTK_DISABLED=1 git branch -vv works as a workaround, but as with #1474 and #730, the agent only reaches for it once something else tips it off that the output is incomplete.
Suggestion
The project's own design philosophy covers this case:
When a user or LLM explicitly requests detailed output via flags (e.g.,
git log --comments,cargo test -- --nocapture,ls -la), respect that intent. Compressing explicitly-requested detail defeats the purpose.
-v / -vv / --verbose fit that rule exactly. One option is to detect those flags in run_branch and passthrough raw. Another is to make filter_branch_output aware of the verbose format and preserve the hash + tracking marker + subject per line. Passthrough is simpler and matches the principle more literally.
Broader Pattern
Same class of bug as #1474, #730, #720 — a filter that isn't flag-aware silently strips content the user asked for, and the hook makes the loss invisible to the agent.
Related
- rtk gh pr comment --help outputs
ok commented— filter discards stdout unconditionally #1474 —gh pr comment --helpoutputs cannedok commented(same class: flag ignored) - rtk gh pr diff --name-only returns empty output — diff filter applied to non-diff data #730 —
gh pr diff --name-onlyreturns empty (same class: filter applied to non-matching data) - rtk gh issue view --comments silently drops comments, misleading AI agents #720 —
--commentssilently dropped ongh issue/pr view(same class: flag ignored)
Environment
- rtk 0.37.2
- Windows 11 (Git Bash)
Activity
pszymkowiak commentedon Apr 24, 2026
🔍 Automated Triage
bugmediumSummary
git branch -vv output is stripped of commit hashes, tracking markers, and subjects by filter_branch_output; fix in PR #1502.
📁 Relevant files
src/cmds/git/git.rsTriaged automatically by wshm · This is an automated analysis, not a human review.
cardila-appgate commentedon May 22, 2026
Additional real-world impact:
[gone]branch detection brokenAdding a concrete scenario where this bug causes a silent, hard-to-diagnose failure: automated stale branch cleanup.
What happened
During a repository cleanup session, the agent ran the standard pattern to delete local branches whose remotes have been deleted:
Step 1 returned no output. The agent (Claude Code) concluded there were no stale branches and skipped cleanup — even though 10 local branches were actually tracking deleted remotes.
The real output (
RTK_DISABLED=1 git branch -vv) showed every one of them with[origin/...: gone].Why it's worse in agentic contexts
Two compounding factors:
grep '\[gone\]'on RTK's compacted output exits 0 with no matches. The agent sees "no output = no stale branches" and moves on. There's no error, no warning, no hint that the upstream markers were stripped.while readpattern is a common shell idiom for this task. With the filter in place,grepproduces nothing, the loop body never runs, and the agent never reachesgit branch -D. No deletion, no error — just silent no-op.The workaround (
/usr/bin/git branch -vvto bypass the hook entirely) only became apparent after the agent tried the standard pattern multiple times and noticed the branch count didn't change.Suggested priority signal
This is a good candidate for the "passthrough when
-v/-vvis present" fix mentioned in the issue description. The[gone]marker is specifically a-v/-vvfeature — baregit branchnever shows it — so any filter that strips it while passing-vvthrough to git is directly breaking a core use case of that flag.Environment