Skip to content

Commit

Permalink
Treat mount point as symlink-like in finddata2dirent
Browse files Browse the repository at this point in the history
Testing on a pnpm monorepo containing recursive symlinks, it turns out
that dwReserved0 is actually IO_REPARSE_TAG_MOUNT_POINT.

Checking FILE_ATTRIBUTE_REPARSE_POINT and IO_REPARSE_TAG_MOUNT_POINT
appears to match similar code in mingw.c's mingw_is_mount_point.

The new test fails without this change, but I am unsure whether or not
it needs some sort of conditional that checks that symlinks are
available in Windows. "SYMLINK" used in the test file appears to be
false even though I have developer mode enabled, allowing them.

Signed-off-by: Jake Bailey <jabaile@microsoft.com>
  • Loading branch information
jakebailey committed Apr 14, 2023
1 parent 9e6cd4b commit 482d952
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compat/win32/dirent.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static inline void finddata2dirent(struct dirent *ent, WIN32_FIND_DATAW *fdata)

/* Set file type, based on WIN32_FIND_DATA */
if ((fdata->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
&& fdata->dwReserved0 == IO_REPARSE_TAG_SYMLINK)
&& (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
22 changes: 22 additions & 0 deletions t/t7300-clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -799,4 +799,26 @@ test_expect_success MINGW 'clean does not traverse mount points' '
test_path_is_file target/dont-clean-me
'

test_expect_success MINGW 'clean handles recursive symlink' '
rm -fr repo &&
mkdir repo &&
(
cd repo &&
git init &&
mkdir -p packages/some-package/node_modules &&
cd packages/some-package &&
touch package.json &&
git add package.json &&
git commit -m setup &&
cd node_modules &&
cmd //c "mklink /D /J some-package .." &&
cd ../../.. &&
test_path_is_file packages/some-package/package.json &&
git clean -fdx packages 2>err &&
test_path_is_file packages/some-package/package.json &&
test_path_is_missing packages/some-package/node_modules &&
! test_i18ngrep "warning" err
)
'

test_done

0 comments on commit 482d952

Please sign in to comment.