summaryrefslogtreecommitdiff
path: root/src/errors.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-08-27 15:09:07 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2014-08-27 15:09:07 +0200
commit6a0d2b43ee4a32b2894d3c2b7c798c4eb4853534 (patch)
treea7fedcd3bffe2d021e31491b4f1f020c1bea8f88 /src/errors.c
parent8733993599d9d9a8fe1b042a1e18d6ecb9b0a0b2 (diff)
parentcb92467bc284b87c38cdf32f8803a528846d094b (diff)
downloadlibgit2-6a0d2b43ee4a32b2894d3c2b7c798c4eb4853534.tar.gz
Merge remote-tracking branch 'upstream/master' into cmn/ssh-retry
Diffstat (limited to 'src/errors.c')
-rw-r--r--src/errors.c16
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;