mirror of
https://github.com/git/git.git
synced 2026-03-13 18:33:25 +01:00
Compute the ultimate fallback for exec_path from the program invocation.
Since on Windows the user is fairly free where to install programs, we cannot rely on a hard-coded path. We use the program name to derive the installation directory and use that as exec_path. The possiblity to have just the git wrapper in the PATH and let it invoke the toolset is sacrificed.
This commit is contained in:
29
exec_cmd.c
29
exec_cmd.c
@@ -9,7 +9,36 @@ static const char *current_exec_path;
|
||||
|
||||
static const char *builtin_exec_path(void)
|
||||
{
|
||||
#ifndef __MINGW32__
|
||||
return GIT_EXEC_PATH;
|
||||
#else
|
||||
int len;
|
||||
char *p, *q, *sl;
|
||||
static char *ep;
|
||||
if (ep)
|
||||
return ep;
|
||||
|
||||
len = strlen(_pgmptr);
|
||||
if (len < 2)
|
||||
return ep = ".";
|
||||
|
||||
p = ep = xmalloc(len+1);
|
||||
q = _pgmptr;
|
||||
sl = NULL;
|
||||
/* copy program name, turn '\\' into '/', skip last part */
|
||||
while ((*p = *q)) {
|
||||
if (*q == '\\' || *q == '/') {
|
||||
*p = '/';
|
||||
sl = p;
|
||||
}
|
||||
p++, q++;
|
||||
}
|
||||
if (sl)
|
||||
*sl = '\0';
|
||||
else
|
||||
ep[0] = '.', ep[1] = '\0';
|
||||
return ep;
|
||||
#endif
|
||||
}
|
||||
|
||||
void git_set_exec_path(const char *exec_path)
|
||||
|
||||
Reference in New Issue
Block a user