Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2011-10-29 06:34:31 +0400
committerCarlos Martín Nieto <carlos@cmartin.tk>2011-10-29 06:34:31 +0400
commit9606858c9936d928d4f654f5bc4d3c31048f833d (patch)
treea895393db3d9938066801bebcfb575ebb20a02c4
parent298d82e3f8c2c3d9c6a621c949f214f5d96c9f63 (diff)
error: make git_errno more useful
Don't make git_errno static and add an argument to git_error_print_stack. If this argument is NULL, it will print the default stack; otherwise it will print the given stack. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
-rw-r--r--include/git2/errors.h2
-rw-r--r--src/errors.c9
2 files changed, 7 insertions, 4 deletions
diff --git a/include/git2/errors.h b/include/git2/errors.h
index 3b306dcc8..db71fc2ef 100644
--- a/include/git2/errors.h
+++ b/include/git2/errors.h
@@ -148,7 +148,7 @@ GIT_EXTERN(void) git_error_free(git_error *err);
* A bog standard stack trace. You can use it if you don't want to do
* anything more complex in your UI.
*/
-GIT_EXTERN(void) git_error_print_stack(void);
+GIT_EXTERN(void) git_error_print_stack(git_error *error_in);
/** @} */
GIT_END_DECL
diff --git a/src/errors.c b/src/errors.c
index 34664ef55..923cb3507 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -13,7 +13,7 @@
#include <stdarg.h>
-static GIT_TLS git_error *git_errno;
+GIT_TLS git_error *git_errno;
static struct {
int num;
@@ -158,10 +158,13 @@ const char *git_lasterror(void)
return git_errno == NULL ? NULL : git_errno->msg;
}
-void git_error_print_stack(void)
+void git_error_print_stack(git_error *error_in)
{
git_error *error;
- for (error = git_errno; error; error = error->child)
+ if (error_in == NULL)
+ error_in = git_errno;
+
+ for (error = error_in; error; error = error->child)
fprintf(stderr, "%s:%u %s\n", error->file, error->line, error->msg);
}