From: Junio C Hamano Date: Wed, 24 Nov 2010 21:24:49 +0000 (-0800) Subject: Merge branch 'maint' X-Git-Tag: v1.7.4-rc0~124 X-Git-Url: https://repo.or.cz/w/git/jnareb-git.git/commitdiff_plain/c6caede7fd6bc428b4d2e53f6bb5c1e1a9bcb24c Merge branch 'maint' * maint: imap-send: link against libcrypto for HMAC and others git-send-email.perl: Deduplicate "to:" and "cc:" entries with names mingw: do not set errno to 0 on success --- c6caede7fd6bc428b4d2e53f6bb5c1e1a9bcb24c diff --cc compat/mingw.c index 29f403649f,b98e600006..fdbf093f6e --- a/compat/mingw.c +++ b/compat/mingw.c @@@ -192,15 -192,13 +192,16 @@@ static inline time_t filetime_to_time_t /* We keep the do_lstat code in a separate function to avoid recursion. * When a path ends with a slash, the stat will fail with ENOENT. In * this case, we strip the trailing slashes and stat again. + * + * If follow is true then act like stat() and report on the link + * target. Otherwise report on the link itself. */ -static int do_lstat(const char *file_name, struct stat *buf) +static int do_lstat(int follow, 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; @@@ -212,27 -210,9 +213,28 @@@ buf->st_atime = filetime_to_time_t(&(fdata.ftLastAccessTime)); buf->st_mtime = filetime_to_time_t(&(fdata.ftLastWriteTime)); buf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime)); + if (fdata.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { + WIN32_FIND_DATAA findbuf; + HANDLE handle = FindFirstFileA(file_name, &findbuf); + if (handle != INVALID_HANDLE_VALUE) { + if ((findbuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) && + (findbuf.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) { + if (follow) { + char buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; + buf->st_size = readlink(file_name, buffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE); + } else { + buf->st_mode = S_IFLNK; + } + buf->st_mode |= S_IREAD; + if (!(findbuf.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) + buf->st_mode |= S_IWRITE; + } + FindClose(handle); + } + } return 0; } + errno = err; return -1; }