Skip to content

Commit

Permalink
git: fix launching the Git wrapper from network drives
Browse files Browse the repository at this point in the history
Since 521a655 (git: fix 'cmd/git.exe' cannot launcher symlink,
2018-12-08), we always try to resolve the Git wrapper's executable path
if it is a symbolic link. We do that by calling GetFinalPathNByHandle(),
but that introduced a regression where we would not handle UNC paths
correctly.

This fixes git-for-windows/git#2036

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Jan 29, 2019
1 parent f3e8a3a commit 67fdd49
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions mingw-w64-git/git-wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,19 @@ static void find_exe_realpath(LPWSTR exepath, int count) {
if (dwlen >= MAX_PATH) {
wcscpy(exepath, mdexe);
} else {
size_t offset = wcsncmp(L"\\\\?\\", realexe, 4) ? 0 : 4;
size_t length = dwlen - offset;
size_t offset = 0;
size_t length = dwlen;

if (!wcsncmp(realexe, L"\\\\?\\", 4)) {
if (wcsncmp(realexe + 4, L"UNC\\", 4))
offset = 4;
else {
offset = 7;
*(exepath++) = L'\\';
}
length -= offset;
}

wcsncpy(exepath, realexe + offset, length);
exepath[length] = L'\0';
}
Expand Down

0 comments on commit 67fdd49

Please sign in to comment.