Skip to content

Commit 15bcde9

Browse files
swiggerdscho
authored andcommitted
fixup! mingw: optionally enable wsl compability file mode bits
fix wsl mode bits bug in subdir Support for wsl mode bits was previously added to git, but there was a bug because the filenames provided by fdata did not contain paths. Ex: fdata->FileName is only foo.sh while we need path/to/foo.sh to open the file. This commit fixes the issue. Signed-off-by: lixungeng <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 2e6a859 commit 15bcde9

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

compat/win32/fscache.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,20 @@ static struct fsentry *fseentry_create_entry(struct fscache *cache,
238238
&(fse->u.s.st_mtim));
239239
filetime_to_timespec((FILETIME *)&(fdata->CreationTime),
240240
&(fse->u.s.st_ctim));
241-
if (fdata->EaSize > 0 && are_wsl_compatible_mode_bits_enabled()) {
242-
copy_wsl_mode_bits_from_disk(fdata->FileName,
243-
fdata->FileNameLength / sizeof(wchar_t), &fse->st_mode);
241+
if (fdata->EaSize > 0 &&
242+
sizeof(buf) >= (list ? list->len+1 : 0) + fse->len+1 &&
243+
are_wsl_compatible_mode_bits_enabled()) {
244+
size_t off = 0;
245+
wchar_t wpath[MAX_LONG_PATH];
246+
if (list && list->len) {
247+
memcpy(buf, list->dirent.d_name, list->len);
248+
buf[list->len] = '/';
249+
off = list->len + 1;
250+
}
251+
memcpy(buf + off, fse->dirent.d_name, fse->len);
252+
buf[off + fse->len] = '\0';
253+
if (xutftowcs_long_path(wpath, buf) >= 0)
254+
copy_wsl_mode_bits_from_disk(wpath, -1, &fse->st_mode);
244255
}
245256

246257
return fse;

0 commit comments

Comments
 (0)