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:
authorRussell Belfer <arrbee@arrbee.com>2012-03-13 09:55:40 +0400
committerRussell Belfer <arrbee@arrbee.com>2012-03-13 09:55:40 +0400
commite1de726c15937a8dbf81d12ef0c872cf6576ebd0 (patch)
tree84b437dd23e8250b0a4f983875fb3849569ad63a /src/errors.c
parentdda708e78f3c3f43d814d46c29ab9f2b9d47ed5c (diff)
Migrate ODB files to new error handling
This migrates odb.c, odb_loose.c, odb_pack.c and pack.c to the new style of error handling. Also got the unix and win32 versions of map.c. There are some minor changes to other files but no others were completely converted. This also contains an update to filebuf so that a zeroed out filebuf will not think that the fd (== 0) is actually open (and inadvertently call close() on fd 0 if cleaned up). Lastly, this was built and tested on win32 and contains a bunch of fixes for the win32 build which was pretty broken.
Diffstat (limited to 'src/errors.c')
-rw-r--r--src/errors.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/errors.c b/src/errors.c
index 6fb7777f0..19bc7b77b 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -40,7 +40,7 @@ static struct {
{GIT_EEXISTS, "A reference with this name already exists"},
{GIT_EOVERFLOW, "The given integer literal is too large to be parsed"},
{GIT_ENOTNUM, "The given literal is not a valid number"},
- {GIT_EAMBIGUOUSOIDPREFIX, "The given oid prefix is ambiguous"},
+ {GIT_EAMBIGUOUS, "The given oid prefix is ambiguous"},
};
const char *git_strerror(int num)
@@ -129,9 +129,29 @@ void giterr_set(int error_class, const char *string, ...)
/* automatically suffix strerror(errno) for GITERR_OS errors */
if (error_class == GITERR_OS) {
- strncat(error_str, ": ", sizeof(error_str));
- strncat(error_str, strerror(errno), sizeof(error_str));
- errno = 0;
+ if (errno != 0) {
+ strncat(error_str, ": ", sizeof(error_str));
+ strncat(error_str, strerror(errno), sizeof(error_str));
+ errno = 0;
+ }
+#ifdef GIT_WIN32
+ else {
+ LPVOID lpMsgBuf;
+ DWORD dw = GetLastError();
+
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, dw, 0, (LPTSTR) &lpMsgBuf, 0, NULL);
+
+ if (lpMsgBuf) {
+ strncat(error_str, ": ", sizeof(error_str));
+ strncat(error_str, (const char *)lpMsgBuf, sizeof(error_str));
+ LocalFree(lpMsgBuf);
+ }
+ }
+#endif
}
giterr_set_str(error_class, error_str);