Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
2c087f81
Commit
2c087f81
authored
Nov 02, 2012
by
Philip Kelley
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1041 from pwkelley/transports
Prefer GetLastError() for GITERR_OS on Win32
parents
e30c052c
8f624a47
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
30 deletions
+19
-30
src/errors.c
+19
-30
No files found.
src/errors.c
View file @
2c087f81
...
@@ -41,51 +41,40 @@ void giterr_set(int error_class, const char *string, ...)
...
@@ -41,51 +41,40 @@ void giterr_set(int error_class, const char *string, ...)
git_buf
buf
=
GIT_BUF_INIT
;
git_buf
buf
=
GIT_BUF_INIT
;
va_list
arglist
;
va_list
arglist
;
int
unix_error_code
=
0
;
#ifdef GIT_WIN32
DWORD
win32_error_code
=
0
;
#endif
if
(
error_class
==
GITERR_OS
)
{
unix_error_code
=
errno
;
errno
=
0
;
#ifdef GIT_WIN32
win32_error_code
=
GetLastError
();
SetLastError
(
0
);
#endif
}
va_start
(
arglist
,
string
);
va_start
(
arglist
,
string
);
git_buf_vprintf
(
&
buf
,
string
,
arglist
);
git_buf_vprintf
(
&
buf
,
string
,
arglist
);
va_end
(
arglist
);
va_end
(
arglist
);
/* automatically suffix strerror(errno) for GITERR_OS errors */
if
(
error_class
==
GITERR_OS
)
{
if
(
error_class
==
GITERR_OS
)
{
int
error_code
=
errno
;
if
(
unix_error_code
!=
0
)
{
git_buf_PUTS
(
&
buf
,
": "
);
git_buf_puts
(
&
buf
,
strerror
(
unix_error_code
));
}
#ifdef GIT_WIN32
#ifdef GIT_WIN32
else
if
(
win32_error_code
!=
0
)
{
DWORD
win32_error_code
=
GetLastError
();
LPVOID
lpMsgBuf
=
NULL
;
FormatMessage
(
if
(
win32_error_code
)
{
FORMAT_MESSAGE_ALLOCATE_BUFFER
|
char
*
lpMsgBuf
;
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
NULL
,
win32_error_code
,
0
,
(
LPTSTR
)
&
lpMsgBuf
,
0
,
NULL
);
if
(
lpMsgBuf
)
{
if
(
FormatMessageA
(
FORMAT_MESSAGE_ALLOCATE_BUFFER
|
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
NULL
,
win32_error_code
,
0
,
(
LPSTR
)
&
lpMsgBuf
,
0
,
NULL
))
{
git_buf_PUTS
(
&
buf
,
": "
);
git_buf_PUTS
(
&
buf
,
": "
);
git_buf_puts
(
&
buf
,
lpMsgBuf
);
git_buf_puts
(
&
buf
,
lpMsgBuf
);
LocalFree
(
lpMsgBuf
);
LocalFree
(
lpMsgBuf
);
}
}
SetLastError
(
0
);
}
}
else
#endif
#endif
if
(
error_code
)
{
git_buf_PUTS
(
&
buf
,
": "
);
git_buf_puts
(
&
buf
,
strerror
(
error_code
));
}
if
(
error_code
)
errno
=
0
;
}
}
if
(
!
git_buf_oom
(
&
buf
))
if
(
!
git_buf_oom
(
&
buf
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment