fix(but): improve error message when branch collides by path prefix#14153
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Improves the but branch new UX when a requested branch name collides with an existing branch due to a path-prefix conflict (e.g. A exists and user attempts to create A/new), turning a previously obtuse low-level error into a clear, user-facing message and adding regression coverage.
Changes:
- Detect
NotADirectoryfromgixreference lookup and convert it into a targeted “collides with existing branch” error. - Add a helper to identify the colliding prefix branch for display purposes.
- Add a CLI test asserting the improved error message for path-prefix collisions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/but/src/args/atoms/branch_arg.rs | Adds NotADirectory handling for prefix collisions and computes a display name for the colliding prefix branch. |
| crates/but/tests/but/command/branch/new.rs | Adds a regression test verifying the new collision error message. |
slarse
force-pushed
the
GB-1591/better-error-on-prefix-path-collision
branch
from
June 10, 2026 08:20
ea6d870 to
d5436ef
Compare
slarse
force-pushed
the
GB-1591/better-error-on-prefix-path-collision
branch
from
June 10, 2026 08:35
d5436ef to
71654af
Compare
slarse
force-pushed
the
GB-1591/better-error-on-prefix-path-collision
branch
from
June 10, 2026 11:19
71654af to
86b05d0
Compare
slarse
force-pushed
the
GB-1591/better-error-on-prefix-path-collision
branch
from
June 11, 2026 06:10
86b05d0 to
2f19334
Compare
slarse
force-pushed
the
GB-1591/better-error-on-prefix-path-collision
branch
from
June 12, 2026 09:04
2f19334 to
ab6cecd
Compare
If a branch exists at `<path>`, and you create a new branch `<path>/name`, then that collides with the existing branch at `<path>` due to the need to now create a directory at `<path>`. The error message generated in that situation used to be very obtuse, and this commit improves upon it to be more clear.
slarse
force-pushed
the
GB-1591/better-error-on-prefix-path-collision
branch
from
June 12, 2026 09:09
ab6cecd to
7ec7a4a
Compare
slarse
enabled auto-merge
June 12, 2026 09:09
Collaborator
|
Thanks for the ping! Indeed, this issue should be fixed in |
This was referenced Jun 15, 2026
Merged
Byron
added a commit
to Byron/gitbutler
that referenced
this pull request
Jun 16, 2026
This is also the bases for reverting most of gitbutlerapp#14153
Byron
added a commit
to Byron/gitbutler
that referenced
this pull request
Jun 16, 2026
The fix now comes from `gix`. It's clearly a worse error message as it's not tuned in any way, which makes me wish the `gix-error` crate was already used everywhere which would have made that easy.
Byron
added a commit
to Byron/gitbutler
that referenced
this pull request
Jun 16, 2026
The fix now comes from `gix`. To keep the error message, additional work is needed, but it's also working on Windows. In future, `gix` should provide such an error message, it already saw the conflicting ref and thus could avoid duplicate work (and reduce complexity here).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If a branch exists at
<path>, and you create a new branch<path>/name, then that collides with the existing branch at<path>due to the need to now create a directory at<path>. The error message generated in that situation used to be very obtuse, and this commit improves upon it to be more clear.There is an underlying issue in
gixwhere if you dorepo.try_find_reference("<path>/name")in that same situation, an error is returned with aNotADirectorykind. This is explicitly asserted inside gix so need to sync with @Byron if this should be changed ingixor if we just work around it here.We want this nice error message regardless so the code here will probably change minimally regardless.