Skip to content

Conversation

ethomson
Copy link
Member

As a consumer, you often just want to print git_error_last()->message on an error. This would be irresponsible since git_error_last() can return NULL. Instead, always return no error when there's no error. Fixes #6618

@ethomson ethomson force-pushed the ethomson/error_updates branch 6 times, most recently from d33c958 to 4361960 Compare August 20, 2023 13:57
@ethomson ethomson force-pushed the ethomson/error_updates branch 3 times, most recently from 84c5af5 to 268f9d7 Compare September 2, 2023 19:26
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.
@ethomson ethomson force-pushed the ethomson/error_updates branch from 268f9d7 to 5a63b43 Compare September 3, 2023 13:00
@ethomson ethomson merged commit 4939fa7 into main Sep 5, 2023
@ethomson ethomson deleted the ethomson/error_updates branch October 9, 2023 19:56
@ethomson ethomson added the bug label Dec 14, 2023
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

git_error_last() should never return NULL
1 participant