Skip to content

Commit d50f290

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 5f4dea1 commit d50f290

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
@@ -421,4 +421,15 @@ test_expect_success CASE_INSENSITIVE_FS 'path is case-insensitive' '
421421
git add "$downcased"
422422
'
423423

424+
test_expect_failure MINGW 'can add files via NTFS junctions' '
425+
test_when_finished "cmd //c rmdir junction && rm -rf target" &&
426+
test_create_repo target &&
427+
cmd //c "mklink /j junction target" &&
428+
>target/via-junction &&
429+
git -C junction add "$(pwd)/junction/via-junction" &&
430+
echo via-junction >expect &&
431+
git -C target diff --cached --name-only >actual &&
432+
test_cmp expect actual
433+
'
434+
424435
test_done

0 commit comments

Comments
 (0)