Skip to content

Commit

Permalink
Merge branch 'fix-v4-fsmonitor-long-paths' into try-v4-fsmonitor
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffhostetler authored and dscho committed Oct 2, 2021
2 parents d0c878a + f715125 commit e8f91a1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions compat/fsmonitor/fsm-health-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct fsm_health_data

struct wt_moved
{
wchar_t wpath[MAX_PATH + 1];
wchar_t wpath[MAX_LONG_PATH + 1];
BY_HANDLE_FILE_INFORMATION bhfi;
} wt_moved;
};
Expand Down Expand Up @@ -178,8 +178,8 @@ static int has_worktree_moved(struct fsmonitor_daemon_state *state,
return 0;

case CTX_INIT:
if (xutftowcs_path(data->wt_moved.wpath,
state->path_worktree_watch.buf) < 0) {
if (xutftowcs_long_path(data->wt_moved.wpath,
state->path_worktree_watch.buf) < 0) {
error(_("could not convert to wide characters: '%s'"),
state->path_worktree_watch.buf);
return -1;
Expand Down
24 changes: 12 additions & 12 deletions compat/fsmonitor/fsm-listen-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct one_watch
DWORD count;

struct strbuf path;
wchar_t wpath_longname[MAX_PATH + 1];
wchar_t wpath_longname[MAX_LONG_PATH + 1];
DWORD wpath_longname_len;

HANDLE hDir;
Expand Down Expand Up @@ -128,8 +128,8 @@ static int normalize_path_in_utf8(wchar_t *wpath, DWORD wpath_len,
*/
static void check_for_shortnames(struct one_watch *watch)
{
wchar_t buf_in[MAX_PATH + 1];
wchar_t buf_out[MAX_PATH + 1];
wchar_t buf_in[MAX_LONG_PATH + 1];
wchar_t buf_out[MAX_LONG_PATH + 1];
wchar_t *last_slash = NULL;
wchar_t *last_bslash = NULL;
wchar_t *last;
Expand All @@ -138,7 +138,7 @@ static void check_for_shortnames(struct one_watch *watch)
wcscpy(buf_in, watch->wpath_longname);
wcscpy(buf_in + watch->wpath_longname_len, L".git");

if (!GetShortPathNameW(buf_in, buf_out, MAX_PATH))
if (!GetShortPathNameW(buf_in, buf_out, MAX_LONG_PATH))
return;

last_slash = wcsrchr(buf_out, L'/');
Expand Down Expand Up @@ -196,8 +196,8 @@ static enum get_relative_result get_relative_longname(
const wchar_t *wpath, DWORD wpath_len,
wchar_t *wpath_longname)
{
wchar_t buf_in[2 * MAX_PATH + 1];
wchar_t buf_out[MAX_PATH + 1];
wchar_t buf_in[2 * MAX_LONG_PATH + 1];
wchar_t buf_out[MAX_LONG_PATH + 1];
DWORD root_len;

/* Build L"<wt-root-path>/<event-rel-path>" */
Expand All @@ -211,7 +211,7 @@ static enum get_relative_result get_relative_longname(
* shortname or a longname. This routine allows either to be
* given as input.
*/
if (!GetLongPathNameW(buf_in, buf_out, MAX_PATH)) {
if (!GetLongPathNameW(buf_in, buf_out, MAX_LONG_PATH)) {
/*
* The shortname to longname conversion can fail for
* various reasons, for example if the file has been
Expand Down Expand Up @@ -271,10 +271,10 @@ static struct one_watch *create_watch(struct fsmonitor_daemon_state *state,
FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE;
HANDLE hDir;
DWORD len_longname;
wchar_t wpath[MAX_PATH + 1];
wchar_t wpath_longname[MAX_PATH + 1];
wchar_t wpath[MAX_LONG_PATH + 1];
wchar_t wpath_longname[MAX_LONG_PATH + 1];

if (xutftowcs_path(wpath, path) < 0) {
if (xutftowcs_long_path(wpath, path) < 0) {
error(_("could not convert to wide characters: '%s'"), path);
return NULL;
}
Expand All @@ -289,7 +289,7 @@ static struct one_watch *create_watch(struct fsmonitor_daemon_state *state,
return NULL;
}

if (!GetLongPathNameW(wpath, wpath_longname, MAX_PATH)) {
if (!GetLongPathNameW(wpath, wpath_longname, MAX_LONG_PATH)) {
error(_("[GLE %ld] could not get longname of '%s'"),
GetLastError(), path);
CloseHandle(hDir);
Expand Down Expand Up @@ -518,7 +518,7 @@ static int process_worktree_events(struct fsmonitor_daemon_state *state)
struct string_list cookie_list = STRING_LIST_INIT_DUP;
struct fsmonitor_batch *batch = NULL;
const char *p = watch->buffer;
wchar_t wpath_longname[MAX_PATH + 1];
wchar_t wpath_longname[MAX_LONG_PATH + 1];

/*
* If the kernel gets more events than will fit in the kernel
Expand Down
8 changes: 4 additions & 4 deletions compat/fsmonitor/fsm-settings-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ static enum fsmonitor_reason is_virtual(struct repository *r)
*/
static enum fsmonitor_reason is_remote(struct repository *r)
{
wchar_t wpath[MAX_PATH];
wchar_t wfullpath[MAX_PATH];
wchar_t wpath[MAX_LONG_PATH];
wchar_t wfullpath[MAX_LONG_PATH];
size_t wlen;
UINT driveType;

/*
* Do everything in wide chars because the drive letter might be
* a multi-byte sequence. See win32_has_dos_drive_prefix().
*/
if (xutftowcs_path(wpath, r->worktree) < 0)
if (xutftowcs_long_path(wpath, r->worktree) < 0)
return FSMONITOR_REASON_ZERO;

/*
Expand All @@ -103,7 +103,7 @@ static enum fsmonitor_reason is_remote(struct repository *r)
* slashes to backslashes. This is essential to get GetDriveTypeW()
* correctly handle some UNC "\\server\share\..." paths.
*/
if (!GetFullPathNameW(wpath, MAX_PATH, wfullpath, NULL))
if (!GetFullPathNameW(wpath, MAX_LONG_PATH, wfullpath, NULL))
return FSMONITOR_REASON_ZERO;

driveType = GetDriveTypeW(wfullpath);
Expand Down

0 comments on commit e8f91a1

Please sign in to comment.