Skip to content

Commit 53527ea

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 479bd07 + 8341f5f commit 53527ea

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
@@ -921,8 +921,13 @@ struct tm *localtime_r(const time_t *timep, struct tm *result)
921921
char *mingw_getcwd(char *pointer, int len)
922922
{
923923
int i;
924-
wchar_t wpointer[MAX_PATH];
925-
if (!_wgetcwd(wpointer, ARRAY_SIZE(wpointer)))
924+
wchar_t cwd[MAX_PATH], wpointer[MAX_PATH];
925+
DWORD ret = GetCurrentDirectoryW(ARRAY_SIZE(cwd), cwd);
926+
927+
if (ret < 0 || ret >= ARRAY_SIZE(cwd))
928+
return NULL;
929+
ret = GetLongPathNameW(cwd, wpointer, ARRAY_SIZE(wpointer));
930+
if (!ret || ret >= ARRAY_SIZE(wpointer))
926931
return NULL;
927932
if (xwcstoutf(pointer, wpointer, len) < 0)
928933
return NULL;

0 commit comments

Comments
 (0)