Repository navigation
fix(git): passthrough git branch -v/-vv/--verbose in list mode (#1499) - #1502
truffle-dev wants to merge 1 commit into
Conversation
…tk-ai#1499) List mode always ran filter_branch_output, which compresses `git branch -a` shape output into a compact `* current` + locals + `remote-only` block. When the user asked for `-v`/`-vv`/`--verbose` the filter stripped the commit hash, `[origin/...]` upstream marker, and subject that `-v` exists to show. The flag had no effect. Two signals reach run_branch: 1. trailing position (`rtk git branch --list -v`): clap's trailing_var_arg captures `-v` inside args. 2. leading position (`rtk git branch -vv`): rtk's global `--verbose` flag consumes it before the subcommand is parsed, so args is empty but cli.verbose > 0. is_verbose_branch_list handles case 1 and recognizes canonical spellings plus combined short-flag groups (`-va`, `-av`), while rejecting look-alikes (`--vim`, positional names containing `v`). For case 2 we inject `-v<N>` before forwarding to git so the child actually sees the flag. Either source flips has_verbose_intent, which bypasses filter_branch_output and forwards git's raw output. Adds 6 regression tests for the helper.
📊 Automated PR Analysis
SummaryFixes git branch verbose flags (-v/-vv/--verbose) being silently stripped by rtk's compact filter in list mode. The fix detects verbose intent from both trailing args and rtk's global --verbose flag, bypasses the filter, and forwards the flag to the git child process so commit hashes, upstream markers, and subjects are displayed. Review Checklist
Linked issues: #1499 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
|
19 days in against |
|
Closing this for now. Sat 35 days with no movement past the initial wshm triage. Happy to revisit if the |
Closes #1499. Supersedes #1500 (retargets to
developper CONTRIBUTING).Cause
run_branchlist mode always runsfilter_branch_output, which compressesgit branch -a-shaped output into a compact* current+ locals +remote-onlyblock. When the user asks for-v/-vv/--verbose, the filter still ran, stripping the commit hash,[origin/...]upstream marker, and subject that-vexists to show. From git's point of view the flag had no effect.The
-vflag reachesrun_branchthrough two different paths depending on position:rtk git branch --list -v): clap'strailing_var_arg = trueonBranch { args }captures-vinsideargs.rtk git branch -vv): rtk's own-v/--verboseis declaredglobal = trueonCli, so clap consumes the-vvbefore the subcommand is parsed.argsarrives empty andcli.verbose == 2.The original fix only covered case 1, but the repro in #1499 is case 2, so the second branch was needed. A small debug build confirmed the split:
Fix
is_verbose_branch_list(args)recognizes--verboseand short-flag groups (so-v,-vv,-va,-av,-avvall match) while rejecting look-alikes such as--vim,--verify-signatures, and positional branch names containingv. For the case-2 path we inject-v<N>before forwarding togitso the child process actually sees the flag. Either signal flipshas_verbose_intent, which bypassesfilter_branch_outputand forwards git's raw output unchanged.Trade-off:
rtk -v git branch(rtk-verbose-as-trace) now also forwards-vto git and shows verbose branch info. This reads as an improvement; the prior behavior (trace line plus compact list) was an accidental product of the clap collision, and the new behavior matches what anyone typing-vneargit branchactually wants.Before / after
Against a small test repo with one local tracking
origin/main(gone) and one local trackingorigin/feature-1(gone):Negative path verified:
rtk git branchandrtk git branch -astill produce the compact filter output.Tests
Six new unit tests for
is_verbose_branch_listcovering canonical spellings, combined short-flag groups, no-verbose cases, long flags containingv, and positional names containingv:Full suite on
develop:cargo test --bin rtk --release→ 1684 passed, 6 ignored, 0 failed onrust:1.95.cargo fmt --all -- --checkclean.cargo clippy --bin rtkintroduces zero new issues vsdevelop.Scope
Only
run_branchlist mode.--show-current, write-path (-d/-D/-m/-M/ rename / upstream edit), and branch creation are untouched. The compactfilter_branch_outputis unchanged so the 80%+ savings on baregit branch -astay intact.