errors: refactoring - never return NULL in git_error_last()#6625
Merged
errors: refactoring - never return NULL in git_error_last()#6625
NULL in git_error_last()#6625Conversation
d33c958 to
4361960
Compare
84c5af5 to
268f9d7
Compare
The error handling in the ssh certificate callback is straightforward. There's no error messages from an external library that need to be saved, we populate the error message ourselves. Since there's nothing custom 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 implemented more complicated functions (like a custom ODB for example) need to set them. (Callback users should likely ferry their own error information in their callback 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 be removed to simplify down to re-using a single structure.
Now that thread-local error data is handled in error, move the thread local data out of the `threadstate` object, since it has now become useless indirection.
We now have no "big single object" that contains thread state.
268f9d7 to
5a63b43
Compare
This was referenced Mar 21, 2024
klayoutmatthias
pushed a commit
to KLayout/klayout
that referenced
this pull request
Mar 23, 2024
`git_error_set_str` was moved into the `sys` subdirectory in libgit2 1.8.0. See [this pull request](libgit2/libgit2#6625) for details and [this issue](libgit2/libgit2#6776) for more context.
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.
As a consumer, you often just want to print
git_error_last()->messageon an error. This would be irresponsible sincegit_error_last()can returnNULL. Instead, always returnno errorwhen there's no error. Fixes #6618