Skip to content

Commit b29e630

Browse files
bmueller84Git for Windows Build Agent
authored andcommitted
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 git-for-windows#2480 Signed-off-by: Bjoern Mueller <bjoernm@gmx.de>
1 parent 898c579 commit b29e630

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

compat/mingw.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,8 +1560,13 @@ char *mingw_getcwd(char *pointer, int len)
15601560
if (hnd != INVALID_HANDLE_VALUE) {
15611561
ret = GetFinalPathNameByHandleW(hnd, wpointer, ARRAY_SIZE(wpointer), 0);
15621562
CloseHandle(hnd);
1563-
if (!ret || ret >= ARRAY_SIZE(wpointer))
1564-
return NULL;
1563+
if (!ret || ret >= ARRAY_SIZE(wpointer)) {
1564+
ret = GetLongPathNameW(cwd, wpointer, ARRAY_SIZE(wpointer));
1565+
if (!ret || ret >= ARRAY_SIZE(wpointer)) {
1566+
errno = ret ? ENAMETOOLONG : err_win_to_posix(GetLastError());
1567+
return NULL;
1568+
}
1569+
}
15651570
if (xwcstoutf(pointer, normalize_ntpath(wpointer), len) < 0)
15661571
return NULL;
15671572
return pointer;

0 commit comments

Comments
 (0)