# git_ui: Trim surrounding whitespace from new branch names \(\#58151\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/4ef7e164b574cdd8a38ece63ebb21353c435f507)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 4ef7e164b574cdd8a38ece63ebb21353c435f507

Requested commit: 4ef7e164b574cdd8a38ece63ebb21353c435f507

Commit: 4ef7e164b574cdd8a38ece63ebb21353c435f507

Tree: eecfe1a3a12bdc29effe898f821c0ecc63eddeb1

Author: toddlerer

Committer: GitHub

## Message

```
git_ui: Trim surrounding whitespace from new branch names (#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 #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>
```

## Parents

- [3c8fc259fdd147eb59cbe7494e9d5c93f705f7bb](https://git.cafe/gitcafe/zed/commit/3c8fc259fdd147eb59cbe7494e9d5c93f705f7bb?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/4ef7e164b574cdd8a38ece63ebb21353c435f507?format=markdown)
