Skip to content

Return Result values rather than converting errors to None#1241

Merged
weihanglo merged 23 commits into
rust-lang:mainfrom
DanielEScherzer:return-results
May 16, 2026
Merged

Return Result values rather than converting errors to None#1241
weihanglo merged 23 commits into
rust-lang:mainfrom
DanielEScherzer:return-results

Conversation

@DanielEScherzer
Copy link
Copy Markdown
Contributor

Fixes #857

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

Now that #1239 has been merged, we should probably return git2::Error on failure rather than directly return Utf8Error

@rustbot

This comment has been minimized.

Comment thread examples/cat-file.rs
Copy link
Copy Markdown
Member

@weihanglo weihanglo May 15, 2026

Choose a reason for hiding this comment

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

This is nice, though also non-utf8 path is rare. I guess we might want to bundle this with libgit2 v2 change, as that would be a larger release having more API changes. What do you think?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think that there is a benefit to doing this now, so that callers can know what the error was instead of just getting back an opaque None, but ultimately it isn't my call. I just want to say that without a timeline for libgit2 v2 I wouldn't want to delay this indefinitely

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.

Yeah reasonable. Fine making some breaking changes now than later. Though still want to point how non-utf8 is not that common.

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 May 16, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 16, 2026
@weihanglo
Copy link
Copy Markdown
Member

This may need a rebase onto main branch

* `Commit::message()`
* `Commit::message_encoding()`
* `Commit::message_raw()`
* `Commit::raw_header()`
* `Commit::summary()`
* `Commit::body()`
* `ConfigEntry::name()`
* `ConfigEntry::value()`
* `PushUpdate::src_refname()`
* `PushUpdate::dst_refname()`
* `Reference::name()`
* `Reference::shorthand()`
* `Reference::symbolic_target()`
* `Refspec::dst()`
* `Refspec::src()`
* `Refspec::str()`
* `Remote::name()`
* `Remote::url()`
* `Remote::pushurl()`
* `Signature::name()`
* `Signature::email()`
@DanielEScherzer
Copy link
Copy Markdown
Contributor Author

Did a rebase with cargo test after each commit, rebase applied cleanly but needed to update the new tests that I added in #1254, #1244, and #1251

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 16, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@weihanglo weihanglo added this pull request to the merge queue May 16, 2026
Merged via the queue into rust-lang:main with commit e9854c6 May 16, 2026
7 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Waiting on review label May 16, 2026
@DanielEScherzer DanielEScherzer deleted the return-results branch May 16, 2026 22:11
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.

Return Result<&str, Utf8Error> instead of Option<&str>

3 participants