aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Faye-Lund <kusmabite@gmail.com>2010-11-23 20:53:08 +0100
committerJunio C Hamano <gitster@pobox.com>2010-11-23 16:08:01 -0800
commite93368d26ebcf69698b8454afb85c9c84bd54363 (patch)
tree5d49188551adc03bf69e0053cb4883d6afee3050
parent1c7d402b3e1e9d7e50abfbfb18c88bc79be468ea (diff)
downloadgit-e93368d26ebcf69698b8454afb85c9c84bd54363.tar.gz
git-e93368d26ebcf69698b8454afb85c9c84bd54363.tar.xz
mingw: do not set errno to 0 on success
Currently do_lstat always sets errno to 0 on success. This incorrectly overwrites previous errors. Fetch the error-code into a temporary variable instead, and assign that to errno on failure. Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--compat/mingw.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/compat/mingw.c b/compat/mingw.c
index f2d9e1fd9..b98e60000 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -195,9 +195,10 @@ static inline time_t filetime_to_time_t(const FILETIME *ft)
*/
static int do_lstat(const char *file_name, struct stat *buf)
{
+ int err;
WIN32_FILE_ATTRIBUTE_DATA fdata;
- if (!(errno = get_file_attr(file_name, &fdata))) {
+ if (!(err = get_file_attr(file_name, &fdata))) {
buf->st_ino = 0;
buf->st_gid = 0;
buf->st_uid = 0;
@@ -211,6 +212,7 @@ static int do_lstat(const char *file_name, struct stat *buf)
buf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime));
return 0;
}
+ errno = err;
return -1;
}