diff options
author | Vicent Marti <vicent@github.com> | 2014-08-13 21:23:23 +0200 |
---|---|---|
committer | Vicent Marti <vicent@github.com> | 2014-08-13 21:23:23 +0200 |
commit | 0707feee37df7e8cdb007bcd57fb48c5b2e8a814 (patch) | |
tree | 02b6743ee51307812405d9e138c5087cfb5cc247 | |
parent | 59403f1ff55346c64bfaa0744ea7f3375da71725 (diff) | |
parent | e62f96dea5a46098cbca5a287f29ca811003bd68 (diff) | |
download | libgit2-0707feee37df7e8cdb007bcd57fb48c5b2e8a814.tar.gz |
Merge pull request #2513 from ethomson/giterr_null_msg
Allow NULL error message prefix when class=GITERR_OS
-rw-r--r-- | src/errors.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/errors.c b/src/errors.c index 393a7875f..7a2600586 100644 --- a/src/errors.c +++ b/src/errors.c @@ -45,15 +45,19 @@ void giterr_set(int error_class, const char *string, ...) #endif int error_code = (error_class == GITERR_OS) ? errno : 0; - va_start(arglist, string); - git_buf_vprintf(&buf, string, arglist); - va_end(arglist); + if (string) { + va_start(arglist, string); + git_buf_vprintf(&buf, string, arglist); + va_end(arglist); + + if (error_class == GITERR_OS) + git_buf_PUTS(&buf, ": "); + } if (error_class == GITERR_OS) { #ifdef GIT_WIN32 char * win32_error = git_win32_get_error_message(win32_error_code); if (win32_error) { - git_buf_PUTS(&buf, ": "); git_buf_puts(&buf, win32_error); git__free(win32_error); @@ -61,10 +65,8 @@ void giterr_set(int error_class, const char *string, ...) } else #endif - if (error_code) { - git_buf_PUTS(&buf, ": "); + if (error_code) git_buf_puts(&buf, strerror(error_code)); - } if (error_code) errno = 0; |