fix: strip linked-worktree '+' marker from git branch chip output#9264
fix: strip linked-worktree '+' marker from git branch chip output#9264JasonLovesDoggo wants to merge 4 commits intowarpdotdev:masterfrom
Conversation
Fixes warpdotdev#9170. When a branch is checked out in another linked worktree, `git branch --no-color` prefixes its line with `+ ` (instead of `* ` for the current branch, or ` ` for regular branches). The branch-chip on-click parser only stripped `*`, so clicking a `+`-marked entry inserted `git checkout + branchname` and failed with `pathspec '+' did not match any file(s) known to git`. - `filter_git_branch_on_click_values` now strips both `*` and `+`. - `git_branches_for_command_corrections` had the same bug for typo correction suggestions; fixed alongside. - Added unit tests covering the marker-stripping and sort behavior.
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @JasonLovesDoggo on file. In order for us to review and merge your code, each contributor must visit https://cla.warp.dev to read and agree to our CLA. |
|
I ran into an unexpected error while working on this. I'm re-reviewing this pull request in response to a review request. You can view the conversation on Warp. I reviewed this pull request and requested human review from: @alokedesai. I left feedback as a comment so a maintainer can approve. Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR updates branch-chip and command-correction parsing to strip git's linked-worktree + marker and adds unit coverage for the common marker cases.
Concerns
- The new parsing strips leading
+characters from actual branch names. Git accepts branch names such as+feature, so unmarked+featureand marked+ +featurelines would be converted tofeature, reintroducing incorrect checkout/correction targets for those valid branches.
Verdict
Found: 0 critical, 2 important, 0 suggestions
Request changes
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
Followup to the previous commit. Reverts the change that stripped the `+` worktree marker from picker entries: keeping it visible is a useful signal that a branch is checked out elsewhere, matching how `git branch` itself displays it. The strip now happens only in `format_git_branch_command`, and only for the exact `"+ "` prefix that git emits. Bare `+` is left alone because it is a legal character inside a ref name (e.g. a branch literally named `+feature` would previously have been mangled). Same precision applied to `git_branches_for_command_corrections`: it now strips `"* "` or `"+ "` prefixes only, never bare `*`/`+`.
|
/oz-review |
1 similar comment
|
/oz-review |
|
@oz-agent /oz-review |
|
Yeah i'm stuck on this one. Retriggering oz does not seem to be working :( (due to Claude being down?) |
|
/oz-review |
1 similar comment
|
/oz-review |
There was a problem hiding this comment.
Overview
This PR fixes git branch chip and command-correction parsing for git branch --no-color entries marked with + because the branch is checked out in another linked worktree. The display path preserves the marker for visibility and strips it before constructing git checkout; the command-correction path strips exact git markers and filters empty lines.
Concerns
- No blocking concerns found. The supplemental security pass did not identify a new security issue in the changed lines.
Verdict
Found: 0 critical, 0 important, 0 suggestions
Approve
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
|
THANK YOU WARP TEAM FOR FIXING OZ, MUCH APPRECIATED |
Review overridden by previous instance.
|
@captainsafia Just checking in here ;D |
|
Heads up: this PR strips the |
|
@JasonLovesDoggo FYI the PR #9905 (review) is a more complete solution (thanks @unrevised6419 for #9264 (comment)). I've asked them to give you attribution in the CHANGELOG |
Description
Fixes #9170.
When a branch is checked out in another linked git worktree,
git branch --no-colorprefixes its line with+(instead of*for the current branch, orfor regular branches). The branch-chip on-click parser infilter_git_branch_on_click_valuesonly stripped*, so clicking a+-marked entry insertedgit checkout + branchnameand failed with:Changes
app/src/context_chips/current_prompt.rs—filter_git_branch_on_click_valuesnow strips both*and+markers viatrim_start_matches(['*', '+']). Also dropped the unused&selfso the helper is testable as an associated fn.app/src/terminal/model/session.rs—git_branches_for_command_correctionshad the same bug class for typo-correction suggestions; fixed alongside.app/src/context_chips/current_prompt_test.rs— added two unit tests covering marker stripping with realisticgit branch --no-color --sort=-committerdateoutput, plus None/empty edge cases.The
BranchPickeritself (app/src/tab_configs/branch_picker.rs) was not affected — it goes throughgit for-each-ref --format=%(refname:short), which never includes the marker.Approach note
Per the issue's first suggested resolution, the marker is stripped rather than blocking checkout. If the branch is in fact checked out in another worktree, git's own error (
fatal: '<branch>' is already used by worktree at '<path>') is much clearer than the originalpathspec '+'failure.Testing
cargo fmtclean.*,+, and unmarked entries) and edge cases (None input, empty/whitespace-only lines).git branch --no-coloroutput format used in the tests is taken verbatim from real git output for a repo with linked worktrees.Server API dependencies
No server API changes.
Agent Mode
Changelog Entries for Stable
CHANGELOG-BUG-FIX: Fixed git branch chip click failing with "pathspec '+' did not match" when selecting a branch that is checked out in another linked git worktree.