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>
4ef7e164b5toddlerer committed on 6/2/2026, 9:18:17 AM· committed by GitHubparent3c8fc25
1 file changedLine totals unavailable