diff options
Diffstat (limited to 'src/errors.c')
-rw-r--r-- | src/errors.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/errors.c b/src/errors.c index d4da50da8..95a720b9a 100644 --- a/src/errors.c +++ b/src/errors.c @@ -10,6 +10,7 @@ #include "threadstate.h" #include "posix.h" #include "buffer.h" +#include "libgit2.h" /******************************************** * New error handling @@ -20,6 +21,11 @@ static git_error g_git_oom_error = { GIT_ERROR_NOMEMORY }; +static git_error g_git_uninitialized_error = { + "libgit2 has not been initialized; you must call git_libgit2_init", + GIT_ERROR_INVALID +}; + static void set_error_from_buffer(int error_class) { git_error *error = &GIT_THREADSTATE->error_t; @@ -131,6 +137,10 @@ void git_error_clear(void) const git_error *git_error_last(void) { + /* If the library is not initialized, return a static error. */ + if (!git_libgit2_init_count()) + return &g_git_uninitialized_error; + return GIT_THREADSTATE->last_error; } |