Skip to content

Commit 07582b1

Browse files
bmueller84Git for Windows Build Agent
authored and
Git for Windows Build Agent
committed
mingw: fix fatal error working on mapped network drives on Windows
In 1e64d18 (mingw: do resolve symlinks in `getcwd()`) a problem was introduced that causes git for Windows to stop working with certain mapped network drives (in particular, drives that are mapped to locations with long path names). Error message was "fatal: Unable to read current working directory: No such file or directory". Present change fixes this issue as discussed in #2480 Signed-off-by: Bjoern Mueller <[email protected]>
1 parent 38dde25 commit 07582b1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

compat/mingw.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,8 +1248,13 @@ char *mingw_getcwd(char *pointer, int len)
12481248
return NULL;
12491249
ret = GetFinalPathNameByHandleW(hnd, wpointer, ARRAY_SIZE(wpointer), 0);
12501250
CloseHandle(hnd);
1251-
if (!ret || ret >= ARRAY_SIZE(wpointer))
1252-
return NULL;
1251+
if (!ret || ret >= ARRAY_SIZE(wpointer)) {
1252+
ret = GetLongPathNameW(cwd, wpointer, ARRAY_SIZE(wpointer));
1253+
if (!ret || ret >= ARRAY_SIZE(wpointer)) {
1254+
errno = ret ? ENAMETOOLONG : err_win_to_posix(GetLastError());
1255+
return NULL;
1256+
}
1257+
}
12531258
if (xwcstoutf(pointer, normalize_ntpath(wpointer), len) < 0)
12541259
return NULL;
12551260
return pointer;

0 commit comments

Comments
 (0)