From bcbe608bc020bcc47845e3cdf81f1fe8883eebf0 Mon Sep 17 00:00:00 2001 From: Halldor Fannar Date: Fri, 29 Dec 2017 12:11:33 +0000 Subject: [PATCH] Fix for issue #607 [git clean removes content of symlinks] There was already code in the readlink function of mingw.c that correctly handled mount points (AKA 'junctions') so it was rather straight-forward to replicate that code into the two other locations where links are handled. I tested before and after these changes and git clean now handles junctions like other soft links. --- compat/win32.h | 3 ++- compat/win32/dirent.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/compat/win32.h b/compat/win32.h index 671bcc81f93351..ae5a507b11e74f 100644 --- a/compat/win32.h +++ b/compat/win32.h @@ -9,7 +9,8 @@ static inline int file_attr_to_st_mode (DWORD attr, DWORD tag) { int fMode = S_IREAD; - if ((attr & FILE_ATTRIBUTE_REPARSE_POINT) && tag == IO_REPARSE_TAG_SYMLINK) + if ((attr & FILE_ATTRIBUTE_REPARSE_POINT) && + (tag == IO_REPARSE_TAG_SYMLINK || tag == IO_REPARSE_TAG_MOUNT_POINT)) fMode |= S_IFLNK; else if (attr & FILE_ATTRIBUTE_DIRECTORY) fMode |= S_IFDIR; diff --git a/compat/win32/dirent.c b/compat/win32/dirent.c index 8c654d722bb0df..568e18d5ef5f88 100644 --- a/compat/win32/dirent.c +++ b/compat/win32/dirent.c @@ -16,8 +16,9 @@ static inline void finddata2dirent(struct dirent *ent, WIN32_FIND_DATAW *fdata) xwcstoutf(ent->d_name, fdata->cFileName, MAX_PATH * 3); /* Set file type, based on WIN32_FIND_DATA */ - if ((fdata->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) - && fdata->dwReserved0 == IO_REPARSE_TAG_SYMLINK) + if ((fdata->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) && + (fdata->dwReserved0 == IO_REPARSE_TAG_SYMLINK || + fdata->dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT)) ent->d_type = DT_LNK; else if (fdata->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ent->d_type = DT_DIR;