Skip to content

Commit 482d952

Browse files
committed
Treat mount point as symlink-like in finddata2dirent
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 <[email protected]>
1 parent 9e6cd4b commit 482d952

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

compat/win32/dirent.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static inline void finddata2dirent(struct dirent *ent, WIN32_FIND_DATAW *fdata)
1919

2020
/* Set file type, based on WIN32_FIND_DATA */
2121
if ((fdata->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
22-
&& fdata->dwReserved0 == IO_REPARSE_TAG_SYMLINK)
22+
&& (fdata->dwReserved0 == IO_REPARSE_TAG_SYMLINK || fdata->dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT))
2323
ent->d_type = DT_LNK;
2424
else if (fdata->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
2525
ent->d_type = DT_DIR;

t/t7300-clean.sh

+22
Original file line numberDiff line numberDiff line change
@@ -799,4 +799,26 @@ test_expect_success MINGW 'clean does not traverse mount points' '
799799
test_path_is_file target/dont-clean-me
800800
'
801801

802+
test_expect_success MINGW 'clean handles recursive symlink' '
803+
rm -fr repo &&
804+
mkdir repo &&
805+
(
806+
cd repo &&
807+
git init &&
808+
mkdir -p packages/some-package/node_modules &&
809+
cd packages/some-package &&
810+
touch package.json &&
811+
git add package.json &&
812+
git commit -m setup &&
813+
cd node_modules &&
814+
cmd //c "mklink /D /J some-package .." &&
815+
cd ../../.. &&
816+
test_path_is_file packages/some-package/package.json &&
817+
git clean -fdx packages 2>err &&
818+
test_path_is_file packages/some-package/package.json &&
819+
test_path_is_missing packages/some-package/node_modules &&
820+
! test_i18ngrep "warning" err
821+
)
822+
'
823+
802824
test_done

0 commit comments

Comments
 (0)