Skip to content

ReferenceNames: Support non-UTF8 branch names#1239

Merged
weihanglo merged 1 commit intorust-lang:masterfrom
DanielEScherzer:non-utf-branch
Apr 28, 2026
Merged

ReferenceNames: Support non-UTF8 branch names#1239
weihanglo merged 1 commit intorust-lang:masterfrom
DanielEScherzer:non-utf-branch

Conversation

@DanielEScherzer
Copy link
Copy Markdown
Contributor

Rather than using Result::unwrap() on the result of str::from_utf8(), handle failures by converting the Utf8Error into a git2::Error; the iterator for reference names already returns Results that could be failures, so the signature is unchanged.

Add some end-to-end tests to confirm the results.

Fixes #1175

@rustbot rustbot added the S-waiting-on-review Status: Waiting on review label Apr 22, 2026
@DanielEScherzer
Copy link
Copy Markdown
Contributor Author

DanielEScherzer commented Apr 22, 2026

Looks like git won't let you create such a branch on windows or macos (though on Windows I could run git branch -m $'\300', the resulting branch name had unicode replacement characters)

Anyway, if this looks good I'll rebase and squash it, we don't need all of these commits in the history

Copy link
Copy Markdown
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

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

This is reasonable. Could you clean up the commit history? No need to strictly follow but this commit structure style is useful: https://epage.github.io/dev/pr-style/#c-atomic

View changes since this review

Rather than using `Result::unwrap()` on the result of `str::from_utf8()`,
handle failures by converting the `Utf8Error` into a `git2::Error`; the
iterator for reference names already returns `Result`s that could be failures,
so the signature is unchanged.

Add some end-to-end tests to confirm the results.

Fixes rust-lang#1175
@DanielEScherzer
Copy link
Copy Markdown
Contributor Author

This is reasonable. Could you clean up the commit history? No need to strictly follow but this commit structure style is useful: https://epage.github.io/dev/pr-style/#c-atomic

View changes since this review

Squashed it

Copy link
Copy Markdown
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

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

@weihanglo weihanglo added this pull request to the merge queue Apr 28, 2026
Merged via the queue into rust-lang:master with commit 9257016 Apr 28, 2026
7 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Waiting on review label Apr 28, 2026
@DanielEScherzer DanielEScherzer deleted the non-utf-branch branch April 28, 2026 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ReferenceNames panics if there is a non-UTF-8 reference

3 participants