Skip to content

Commit 2f10b45

Browse files
committed
Merge branch 'getcwd-fix-case'
This makes sure that Git's idea of the current working directory matches what is recorded on disk (which should be the same as Git's idea). This helps in particular PowerShell users where the current working directory can differ in case from what's stored on disk. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents f1df646 + 723b463 commit 2f10b45

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
@@ -938,8 +938,13 @@ struct tm *localtime_r(const time_t *timep, struct tm *result)
938938
char *mingw_getcwd(char *pointer, int len)
939939
{
940940
int i;
941-
wchar_t wpointer[MAX_PATH];
942-
if (!_wgetcwd(wpointer, ARRAY_SIZE(wpointer)))
941+
wchar_t cwd[MAX_PATH], wpointer[MAX_PATH];
942+
DWORD ret = GetCurrentDirectoryW(ARRAY_SIZE(cwd), cwd);
943+
944+
if (ret < 0 || ret >= ARRAY_SIZE(cwd))
945+
return NULL;
946+
ret = GetLongPathNameW(cwd, wpointer, ARRAY_SIZE(wpointer));
947+
if (!ret || ret >= ARRAY_SIZE(wpointer))
943948
return NULL;
944949
if (xwcstoutf(pointer, wpointer, len) < 0)
945950
return NULL;

0 commit comments

Comments
 (0)