Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 6679ea9

Browse files
committed
Merge pull request #190 from kasal/kb-long-paths-v3
Support long paths v3
2 parents 0516023 + a15723c commit 6679ea9

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

compat/win32/dirent.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ DIR *dirent_opendir(const char *name)
7070
dirent_DIR *dir;
7171

7272
/* convert name to UTF-16 and check length */
73-
if ((len = xutftowcs_long_path(pattern, name)) < 0)
73+
if ((len = xutftowcs_path_ex(pattern, name, MAX_LONG_PATH, -1,
74+
MAX_PATH - 2, core_long_paths)) < 0)
7475
return NULL;
7576

7677
/*

t/t2025-checkout-long-paths.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,45 @@ test_expect_success cleanup '
5555
test ! -z "$debug" || rm -rf longpa~1
5656
'
5757

58+
# check that the template used in the test won't be too long:
59+
abspath="$(pwd -W)"/testdir
60+
test ${#abspath} -gt 230 ||
61+
test_set_prereq SHORTABSPATH
62+
63+
test_expect_success SHORTABSPATH 'clean up path close to MAX_PATH' '
64+
p=/123456789abcdef/123456789abcdef/123456789abcdef/123456789abc/ef &&
65+
p=y$p$p$p$p &&
66+
subdir="x$(echo "$p" | tail -c $((253 - ${#abspath})))" &&
67+
# Now, $abspath/$subdir has exactly 254 characters, and is inside CWD
68+
p2="$abspath/$subdir" &&
69+
test 254 = ${#p2} &&
70+
71+
# Be careful to overcome path limitations of the MSys tools and split
72+
# the $subdir into two parts. ($subdir2 has to contain 16 chars and a
73+
# slash somewhere following; that is why we asked for abspath <= 230 and
74+
# why we placed a slash near the end of the $subdir template.)
75+
subdir2=${subdir#????????????????*/} &&
76+
subdir1=testdir/${subdir%/$subdir2} &&
77+
mkdir -p "$subdir1" &&
78+
i=0 &&
79+
# The most important case is when absolute path is 258 characters long,
80+
# and that will be when i == 4.
81+
while test $i -le 7
82+
do
83+
mkdir -p $subdir2 &&
84+
touch $subdir2/one-file &&
85+
mv ${subdir2%%/*} "$subdir1/" &&
86+
subdir2=z${subdir2} &&
87+
i=$(($i+1)) ||
88+
exit 1
89+
done &&
90+
91+
# now check that git is able to clear the tree:
92+
(cd testdir &&
93+
git init &&
94+
git config core.longpaths yes &&
95+
git clean -fdx) &&
96+
test ! -d "$subdir1"
97+
'
98+
5899
test_done

0 commit comments

Comments
 (0)