Skip to content

fix: strip linked-worktree '+' marker from git branch chip output#9264

Open
JasonLovesDoggo wants to merge 4 commits intowarpdotdev:masterfrom
JasonLovesDoggo:jason/fix-9170-branch-picker-worktree-marker
Open

fix: strip linked-worktree '+' marker from git branch chip output#9264
JasonLovesDoggo wants to merge 4 commits intowarpdotdev:masterfrom
JasonLovesDoggo:jason/fix-9170-branch-picker-worktree-marker

Conversation

@JasonLovesDoggo
Copy link
Copy Markdown

Description

Fixes #9170.

When a branch is checked out in another linked git 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 in filter_git_branch_on_click_values only stripped *, so clicking a +-marked entry inserted git checkout + branchname and failed with:

error: pathspec '+' did not match any file(s) known to git
error: pathspec '273-improvement-suggestion-agent' did not match any file(s) known to git

Changes

  • app/src/context_chips/current_prompt.rsfilter_git_branch_on_click_values now strips both * and + markers via trim_start_matches(['*', '+']). Also dropped the unused &self so the helper is testable as an associated fn.
  • app/src/terminal/model/session.rsgit_branches_for_command_corrections had 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 realistic git branch --no-color --sort=-committerdate output, plus None/empty edge cases.

The BranchPicker itself (app/src/tab_configs/branch_picker.rs) was not affected — it goes through git 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 original pathspec '+' failure.

Testing

  • cargo fmt clean.
  • New unit tests verify both the happy path (mixed *, +, and unmarked entries) and edge cases (None input, empty/whitespace-only lines).
  • Manual verification of the reproduction conditions described in the issue is gated on a running build; the git branch --no-color output 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

  • Warp Agent Mode - This PR was created via Warp's AI 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.

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.
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 28, 2026

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.

@JasonLovesDoggo JasonLovesDoggo marked this pull request as ready for review April 28, 2026 17:54
@cla-bot cla-bot Bot added the cla-signed label Apr 28, 2026
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented Apr 28, 2026

@JasonLovesDoggo

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 /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

oz-for-oss[bot]
oz-for-oss Bot previously requested changes Apr 28, 2026
Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 +feature and marked + +feature lines would be converted to feature, 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

Comment thread app/src/context_chips/current_prompt.rs Outdated
Comment thread app/src/terminal/model/session.rs Outdated
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 `*`/`+`.
@JasonLovesDoggo
Copy link
Copy Markdown
Author

/oz-review

1 similar comment
@JasonLovesDoggo
Copy link
Copy Markdown
Author

/oz-review

@JasonLovesDoggo
Copy link
Copy Markdown
Author

@oz-agent /oz-review

@JasonLovesDoggo JasonLovesDoggo changed the title Strip linked-worktree '+' marker from git branch chip output fix: strip linked-worktree '+' marker from git branch chip output Apr 28, 2026
@JasonLovesDoggo
Copy link
Copy Markdown
Author

Yeah i'm stuck on this one. Retriggering oz does not seem to be working :(

(due to Claude being down?)

@JasonLovesDoggo
Copy link
Copy Markdown
Author

/oz-review

1 similar comment
@JasonLovesDoggo
Copy link
Copy Markdown
Author

/oz-review

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@oz-for-oss oz-for-oss Bot requested a review from alokedesai April 29, 2026 17:40
@JasonLovesDoggo
Copy link
Copy Markdown
Author

JasonLovesDoggo commented Apr 29, 2026

THANK YOU WARP TEAM FOR FIXING OZ, MUCH APPRECIATED

@captainsafia captainsafia dismissed oz-for-oss[bot]’s stale review April 29, 2026 20:43

Review overridden by previous instance.

@captainsafia captainsafia added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label Apr 30, 2026 — with Warp Dev Github Integration
@JasonLovesDoggo
Copy link
Copy Markdown
Author

@captainsafia Just checking in here ;D

@unrevised6419
Copy link
Copy Markdown

Heads up: this PR strips the + marker but the underlying checkout will still fail because the branch is already used by a linked worktree (fatal: '<branch>' is already checked out at ...). See #9170 (comment) for details and suggested fixes.

@moirahuang moirahuang requested review from moirahuang and removed request for alokedesai May 5, 2026 18:10
@moirahuang
Copy link
Copy Markdown
Contributor

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Branch picker includes linked-worktree '+' marker in git checkout

4 participants