Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ static int read_reparse_point(const WCHAR *wpath, BOOL fail_on_unknown_tag,
}

if ((*plen =
xwcstoutf(tmpbuf, normalize_ntpath(wbuf), MAX_PATH)) < 0)
xwcstoutf(tmpbuf, normalize_ntpath(wbuf), MAX_LONG_PATH)) < 0)
return -1;
return 0;
}
Expand Down
42 changes: 42 additions & 0 deletions t/t2031-checkout-long-paths.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,46 @@ test_expect_success SYMLINKS_WINDOWS 'leave drive-less, short paths intact' '
test_grep "<SYMLINKD\\?> *PF *\\[\\\\Program Files\\]" actual
'

test_expect_success SYMLINKS_WINDOWS 'set up long symlink targets' '
ascii_target=$(printf "%0128d" 0) &&
ascii_target=$ascii_target/$ascii_target &&
utf8_char=$(printf "\344\270\255") &&
utf8_target=$(test_seq 1 85 | sed "s/.*/$utf8_char/" | tr -d "\n") &&
utf8_target=$utf8_target/a
'

for encoding in ascii utf8
do
for suffix in aa aaa aaaa
do
# Both prefixes are 257 UTF-8 bytes: test 259, 260 and 261.
bytes=$((257 + ${#suffix}))
test_expect_success SYMLINKS_WINDOWS \
"read $encoding symlink target of $bytes bytes" '
test_config core.symlinks true &&
test_config core.longpaths false &&
test_config core.fscache false &&
test_when_finished "rm -f long-link" &&
test_when_finished \
"git update-index --force-remove long-link" &&
case $encoding in
ascii) target=$ascii_target$suffix ;;
utf8) target=$utf8_target$suffix ;;
esac &&
oid=$(printf "%s" "$target" |
git hash-object -w --stdin) &&
git update-index --add \
--cacheinfo 120000,$oid,long-link &&
win_target=$(printf "%s" "$target" | tr / "\\\\") &&
cmd //c "mklink long-link $win_target" &&
printf "%s\n" "$target" >expect &&
test-tool path-utils readlink long-link >actual &&
test_cmp expect actual &&
git diff --exit-code -- long-link >actual 2>err &&
test_must_be_empty actual &&
test_must_be_empty err
'
done
done

test_done