Skip to content

Commit 78d0bec

Browse files
committed
mingw: demonstrate a git add issue with NTFS junctions
NTFS junctions are somewhat similar in spirit to Unix bind mounts: they point to a different directory and are resolved by the filesystem driver. As such, they appear to `lstat()` as if they are directories, not as if they are symbolic links. _Any_ user can create junctions, while symbolic links can only be created by non-administrators in Developer Mode on Windows 10. Hence NTFS junctions are much more common "in the wild" than NTFS symbolic links. It was reported in #2481 that adding files via an absolute path that traverses an NTFS junction: since 1e64d18 (mingw: do resolve symlinks in `getcwd()`), we resolve not only symbolic links but also NTFS junctions when determining the absolute path of the current directory. The same is not true for `git add <file>`, where symbolic links are resolved in `<file>`, but not NTFS junctions. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent c6ca5c1 commit 78d0bec

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

t/t3700-add.sh

+11
Original file line numberDiff line numberDiff line change
@@ -548,4 +548,15 @@ test_expect_success CASE_INSENSITIVE_FS 'path is case-insensitive' '
548548
git add "$downcased"
549549
'
550550

551+
test_expect_failure MINGW 'can add files via NTFS junctions' '
552+
test_when_finished "cmd //c rmdir junction && rm -rf target" &&
553+
test_create_repo target &&
554+
cmd //c "mklink /j junction target" &&
555+
>target/via-junction &&
556+
git -C junction add "$(pwd)/junction/via-junction" &&
557+
echo via-junction >expect &&
558+
git -C target diff --cached --name-only >actual &&
559+
test_cmp expect actual
560+
'
561+
551562
test_done

0 commit comments

Comments
 (0)