Skip to content

git_ui: Trim surrounding whitespace from new branch names - #58151

Merged
dinocosta merged 4 commits into
zed-industries:mainfrom
toddlerer:fix/56602
Jun 2, 2026
Merged

git_ui: Trim surrounding whitespace from new branch names#58151
dinocosta merged 4 commits into
zed-industries:mainfrom
toddlerer:fix/56602

Conversation

@toddlerer

Copy link
Copy Markdown
Contributor

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Closes #56602.

Creating a branch from the branch picker normalizes the typed name with replace(' ', "-"), so leading or trailing spaces became leading or trailing hyphens (e.g. fix-leak -> -fix-leak-). git rejects such names, so branch creation failed.

Trimming the query before replacing spaces yields a valid name.

Release Notes:

  • git_ui: Fixed branch creation failing when a branch name had leading or trailing whitespace

Closes zed-industries#56602.

Creating a branch from the branch picker normalizes the typed name with
`replace(' ', "-")`, so leading or trailing spaces became leading or trailing
hyphens (e.g. ` fix-leak ` -> `-fix-leak-`). git rejects such names, so branch
creation failed.

Trimming the query before replacing spaces yields a valid name.

Release Notes:

- git_ui: Fixed branch creation failing when a branch name had leading or trailing whitespace
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 30, 2026
@dinocosta dinocosta self-assigned this Jun 2, 2026
@dinocosta dinocosta added the area:integrations/git Git integration feedback label Jun 2, 2026

@dinocosta dinocosta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you @toddlerer ! ✌️

@dinocosta
dinocosta enabled auto-merge June 2, 2026 09:10
@dinocosta
dinocosta added this pull request to the merge queue Jun 2, 2026
Merged via the queue into zed-industries:main with commit 4ef7e16 Jun 2, 2026
32 checks passed
@toddlerer

Copy link
Copy Markdown
Contributor Author

Thanks for the review and the cleanup, @dinocosta! 🙏

This was referenced Jun 18, 2026
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
…ries#58151)

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes zed-industries#56602.

Creating a branch from the branch picker normalizes the typed name with
`replace(' ', "-")`, so leading or trailing spaces became leading or
trailing hyphens (e.g. ` fix-leak ` -> `-fix-leak-`). git rejects such
names, so branch creation failed.

Trimming the query before replacing spaces yields a valid name.

Release Notes:

- git_ui: Fixed branch creation failing when a branch name had leading
or trailing whitespace

---------

Co-authored-by: dino <dinojoaocosta@gmail.com>
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…ries#58151)

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes zed-industries#56602.

Creating a branch from the branch picker normalizes the typed name with
`replace(' ', "-")`, so leading or trailing spaces became leading or
trailing hyphens (e.g. ` fix-leak ` -> `-fix-leak-`). git rejects such
names, so branch creation failed.

Trimming the query before replacing spaces yields a valid name.

Release Notes:

- git_ui: Fixed branch creation failing when a branch name had leading
or trailing whitespace

---------

Co-authored-by: dino <dinojoaocosta@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:integrations/git Git integration feedback cla-signed The user has signed the Contributor License Agreement

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

branch creation whitespace to - conversion doesn't trim leading whitespace leading to git error

2 participants