Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix] fix wsl mode bits error in subdir #4660

Merged
merged 1 commit into from
Aug 7, 2024
Merged
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
17 changes: 14 additions & 3 deletions compat/win32/fscache.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,20 @@ static struct fsentry *fseentry_create_entry(struct fscache *cache,
&(fse->u.s.st_mtim));
filetime_to_timespec((FILETIME *)&(fdata->CreationTime),
&(fse->u.s.st_ctim));
if (fdata->EaSize > 0 && are_wsl_compatible_mode_bits_enabled()) {
copy_wsl_mode_bits_from_disk(fdata->FileName,
fdata->FileNameLength / sizeof(wchar_t), &fse->st_mode);
if (fdata->EaSize > 0 &&
sizeof(buf) >= (list ? list->len+1 : 0) + fse->len+1 &&
are_wsl_compatible_mode_bits_enabled()) {
size_t off = 0;
wchar_t wpath[MAX_LONG_PATH];
if (list && list->len) {
memcpy(buf, list->dirent.d_name, list->len);
buf[list->len] = '/';
off = list->len + 1;
}
memcpy(buf + off, fse->dirent.d_name, fse->len);
buf[off + fse->len] = '\0';
if (xutftowcs_long_path(wpath, buf) >= 0)
copy_wsl_mode_bits_from_disk(wpath, -1, &fse->st_mode);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
fscache did not contain paths.

This commit fixes the issue.

I am sorry, but this commit message does nothing at all to help me to understand while the previous fdata->FileName would not be enough.

Please review https://github.blog/2022-06-30-write-better-commits-build-better-projects/ and improve the commit message accordingly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, now commit updated.

Ex: fdata->FileName is only foo.sh while we need path/to/foo.sh to open the file.

}

return fse;
Expand Down
Loading