Skip to content

Commit

Permalink
git-wrapper: append $HOME/bin to the PATH
Browse files Browse the repository at this point in the history
`$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 #429

Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho authored and Git for Windows Build Agent committed Aug 26, 2016
1 parent e7f25bf commit 4ba9bd3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion compat/win32/git-wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static void setup_environment(LPWSTR top_level_path, int full_path)

/* extend the PATH */
len = GetEnvironmentVariable(L"PATH", NULL, 0);
len = sizeof(WCHAR) * (len + 2 * MAX_PATH);
len = sizeof(WCHAR) * (len + 3 * MAX_PATH);
path2 = (LPWSTR)malloc(len);
wcscpy(path2, top_level_path);
if (!full_path)
Expand All @@ -97,9 +97,16 @@ static void setup_environment(LPWSTR top_level_path, int full_path)
PathAppend(path2, msystem_bin);
if (_waccess(path2, 0) != -1) {
/* We are in an MSys2-based setup */
int len2 = GetEnvironmentVariable(L"HOME", NULL, 0);

wcscat(path2, L";");
wcscat(path2, top_level_path);
PathAppend(path2, L"usr\\bin;");
if (len2 + 6 < MAX_PATH) {
GetEnvironmentVariable(L"HOME",
path2 + wcslen(path2), len2);
PathAppend(path2, L"bin;");
}
}
else {
/* Fall back to MSys1 paths */
Expand Down

0 comments on commit 4ba9bd3

Please sign in to comment.