Skip to content

Commit

Permalink
Fix for issue git-for-windows#607 [git clean removes content of symli…
Browse files Browse the repository at this point in the history
…nks]

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.
  • Loading branch information
halldorfannar committed Dec 29, 2017
1 parent 512e5d6 commit bcbe608
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion compat/win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions compat/win32/dirent.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bcbe608

Please sign in to comment.