Skip to content

Commit

Permalink
mingw: fix fatal error working on mapped network drives on Windows
Browse files Browse the repository at this point in the history
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 <bjoernm@gmx.de>
  • Loading branch information
bmueller84 authored and dscho committed Sep 16, 2022
1 parent 5020b08 commit 8214a5c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions compat/mingw.c
Expand Up @@ -1133,8 +1133,13 @@ char *mingw_getcwd(char *pointer, int len)
return NULL;
ret = GetFinalPathNameByHandleW(hnd, wpointer, ARRAY_SIZE(wpointer), 0);
CloseHandle(hnd);
if (!ret || ret >= ARRAY_SIZE(wpointer))
return NULL;
if (!ret || ret >= ARRAY_SIZE(wpointer)) {
ret = GetLongPathNameW(cwd, wpointer, ARRAY_SIZE(wpointer));
if (!ret || ret >= ARRAY_SIZE(wpointer)) {
errno = ret ? ENAMETOOLONG : err_win_to_posix(GetLastError());
return NULL;
}
}
if (xwcstoutf(pointer, normalize_ntpath(wpointer), len) < 0)
return NULL;
return pointer;
Expand Down

0 comments on commit 8214a5c

Please sign in to comment.