Skip to content

Commit ad53187

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 <[email protected]>
1 parent 5501b4a commit ad53187

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
@@ -498,4 +498,15 @@ test_expect_success CASE_INSENSITIVE_FS 'path is case-insensitive' '
498498
git add "$downcased"
499499
'
500500

501+
test_expect_failure MINGW 'can add files via NTFS junctions' '
502+
test_when_finished "cmd //c rmdir junction && rm -rf target" &&
503+
test_create_repo target &&
504+
cmd //c "mklink /j junction target" &&
505+
>target/via-junction &&
506+
git -C junction add "$(pwd)/junction/via-junction" &&
507+
echo via-junction >expect &&
508+
git -C target diff --cached --name-only >actual &&
509+
test_cmp expect actual
510+
'
511+
501512
test_done

0 commit comments

Comments
 (0)