From 80ba074f4163dc8ee4232d64e73a8521edcadc1d Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Mon, 3 Dec 2007 21:55:57 +0100 Subject: Windows: Use the Windows style PATH separator ';'. Signed-off-by: Johannes Sixt --- exec_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'exec_cmd.c') diff --git a/exec_cmd.c b/exec_cmd.c index e189caca62..a1bc4e04bf 100644 --- a/exec_cmd.c +++ b/exec_cmd.c @@ -37,7 +37,7 @@ static void add_path(struct strbuf *out, const char *path) else strbuf_addstr(out, make_absolute_path(path)); - strbuf_addch(out, ':'); + strbuf_addch(out, PATH_SEP); } } -- cgit v1.2.3 From 4ec22a48c0575c8a303cd00b5ef4b3d703fbf8b3 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Wed, 11 Apr 2007 15:26:08 +0200 Subject: Turn builtin_exec_path into a function. builtin_exec_path returns the hard-coded installation path, which is used as the ultimate fallback to look for git commands. Making it into a function enables us in a follow-up patch to return a computed value instead of just a constant string. Signed-off-by: Johannes Sixt --- exec_cmd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'exec_cmd.c') diff --git a/exec_cmd.c b/exec_cmd.c index a1bc4e04bf..6618aad7ab 100644 --- a/exec_cmd.c +++ b/exec_cmd.c @@ -4,9 +4,13 @@ #define MAX_ARGS 32 extern char **environ; -static const char *builtin_exec_path = GIT_EXEC_PATH; static const char *argv_exec_path; +static const char *builtin_exec_path(void) +{ + return GIT_EXEC_PATH; +} + void git_set_argv_exec_path(const char *exec_path) { argv_exec_path = exec_path; @@ -26,7 +30,7 @@ const char *git_exec_path(void) return env; } - return builtin_exec_path; + return builtin_exec_path(); } static void add_path(struct strbuf *out, const char *path) @@ -50,7 +54,7 @@ void setup_path(const char *cmd_path) add_path(&new_path, argv_exec_path); add_path(&new_path, getenv(EXEC_PATH_ENVIRONMENT)); - add_path(&new_path, builtin_exec_path); + add_path(&new_path, builtin_exec_path()); add_path(&new_path, cmd_path); if (old_path) -- cgit v1.2.3 From 6fad004a37432e4378b6cce53eebe8a079104e93 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Wed, 11 Apr 2007 16:02:45 +0200 Subject: Windows: Compute the 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. Signed-off-by: Johannes Sixt --- exec_cmd.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'exec_cmd.c') diff --git a/exec_cmd.c b/exec_cmd.c index 6618aad7ab..84db7ee664 100644 --- a/exec_cmd.c +++ b/exec_cmd.c @@ -8,7 +8,36 @@ static const char *argv_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_argv_exec_path(const char *exec_path) -- cgit v1.2.3