Skip to content

Commit 136f062

Browse files
kbleesdscho
authored andcommitted
Win32: lstat(): return adequate stat.st_size for symlinks
Git typically doesn't trust the stat.st_size member of symlinks (e.g. see strbuf_readlink()). However, some functions take shortcuts if st_size is 0 (e.g. diff_populate_filespec()). In mingw_lstat() and fscache_lstat(), make sure to return an adequate size. The extra overhead of opening and reading the reparse point to calculate the exact size is not necessary, as git doesn't rely on the value anyway. Signed-off-by: Karsten Blees <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent e9d30b7 commit 136f062

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compat/mingw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -962,8 +962,8 @@ int mingw_lstat(const char *file_name, struct stat *buf)
962962
buf->st_nlink = 1;
963963
buf->st_mode = file_attr_to_st_mode(fdata.dwFileAttributes,
964964
findbuf.dwReserved0);
965-
buf->st_size = fdata.nFileSizeLow |
966-
(((off_t)fdata.nFileSizeHigh)<<32);
965+
buf->st_size = S_ISLNK(buf->st_mode) ? MAX_LONG_PATH :
966+
fdata.nFileSizeLow | (((off_t) fdata.nFileSizeHigh) << 32);
967967
buf->st_dev = buf->st_rdev = 0; /* not used by Git */
968968
filetime_to_timespec(&(fdata.ftLastAccessTime), &(buf->st_atim));
969969
filetime_to_timespec(&(fdata.ftLastWriteTime), &(buf->st_mtim));

0 commit comments

Comments
 (0)