Skip to content

Commit 7d5edeb

Browse files
committed
git-wrapper: append $HOME/bin to the PATH
`$HOME/bin/` is quite convenient a place to put user-specific Git helpers, such as credential or remote helpers. When run in Git Bash, it is therefore already appended to the PATH; Let's do the equivalent when run in Git CMD: when `git.exe` is called, Git is told to look also for scripts and programs in `$HOME/bin` (this does not modify Git CMD's `PATH`, of course). This fixes git-for-windows#429 Signed-off-by: Johannes Schindelin <[email protected]>
1 parent e1b8ef8 commit 7d5edeb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

compat/win32/git-wrapper.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static void setup_environment(LPWSTR top_level_path, int full_path)
8888

8989
/* extend the PATH */
9090
len = GetEnvironmentVariable(L"PATH", NULL, 0);
91-
len = sizeof(WCHAR) * (len + 2 * MAX_PATH);
91+
len = sizeof(WCHAR) * (len + 3 * MAX_PATH);
9292
path2 = (LPWSTR)malloc(len);
9393
wcscpy(path2, top_level_path);
9494
if (!full_path)
@@ -97,9 +97,16 @@ static void setup_environment(LPWSTR top_level_path, int full_path)
9797
PathAppend(path2, msystem_bin);
9898
if (_waccess(path2, 0) != -1) {
9999
/* We are in an MSys2-based setup */
100+
int len2 = GetEnvironmentVariable(L"HOME", NULL, 0);
101+
100102
wcscat(path2, L";");
101103
wcscat(path2, top_level_path);
102104
PathAppend(path2, L"usr\\bin;");
105+
if (len2 + 6 < MAX_PATH) {
106+
GetEnvironmentVariable(L"HOME",
107+
path2 + wcslen(path2), len2);
108+
PathAppend(path2, L"bin;");
109+
}
103110
}
104111
else {
105112
/* Fall back to MSys1 paths */

0 commit comments

Comments
 (0)