- Notifications
You must be signed in to change notification settings - Fork2.5k
errors: refactoring - never returnNULL
ingit_error_last()
#6625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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
d33c958
to4361960
Compare84c5af5
to268f9d7
CompareThe error handling in the ssh certificate callback is straightforward.There's no error messages from an external library that need to besaved, we populate the error message ourselves. Since there's nothingcustom here, it does not need to use the error saving mechanism.
Callers want to be able to simply call `git_error_last()->message`,not have to worry about whether `git_error_last()` returns NULL or not.
Most callers only need to _get_ error messages. Only callers implementedmore complicated functions (like a custom ODB for example) need to setthem.(Callback users should likely ferry their own error information in theircallback payload.)
Instead of having a separate type for saving state, we can re-use the`git_error` structure. In practice, saving the error code along with the`git_error` information has not proven necessary or useful, so it can beremoved to simplify down to re-using a single structure.
Now that thread-local error data is handled in error, move the threadlocal data out of the `threadstate` object, since it has now becomeuseless indirection.
We now have no "big single object" that contains thread state.
268f9d7
to5a63b43
Compare This was referencedMar 21, 2024
klayoutmatthias pushed a commit to KLayout/klayout that referenced this pull requestMar 23, 2024
`git_error_set_str` was moved into the `sys` subdirectory in libgit21.8.0. See [this pullrequest](libgit2/libgit2#6625) for details and[this issue](libgit2/libgit2#6776) for morecontext.
Sign up for freeto 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.
As a consumer, you often just want to print
git_error_last()->message
on an error. This would be irresponsible sincegit_error_last()
can returnNULL
. Instead, always returnno error
when there's no error.Fixes#6618