Skip to content

Commit 7d6c171

Browse files
committed
mingw_realpath(): do follow symbolic links
If the path we're trying to resolve points to a symbolic link, the `GetFinalPathW()` function won't resolve that link, so let's fall back to the slower-but-accurate method in such cases. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 1dec7f7 commit 7d6c171

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

compat/mingw.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1546,8 +1546,15 @@ char *mingw_strbuf_realpath(struct strbuf *resolved, const char *path)
15461546
*/
15471547
if (h == INVALID_HANDLE_VALUE &&
15481548
GetLastError() == ERROR_FILE_NOT_FOUND) {
1549+
WIN32_FILE_ATTRIBUTE_DATA fdata;
1550+
wchar_t *p;
1551+
1552+
if (GetFileAttributesExW(wpath, GetFileExInfoStandard, &fdata) &&
1553+
fdata.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
1554+
return NULL; /* must follow symlink */
1555+
15491556
/* cut last component off of `wpath` */
1550-
wchar_t *p = wpath + wcslen(wpath);
1557+
p = wpath + wcslen(wpath);
15511558

15521559
while (p != wpath)
15531560
if (*(--p) == L'/' || *p == L'\\')

0 commit comments

Comments
 (0)