From e1464ca7bb0d705210ba7198f004b2fb2b807e12 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Mon, 21 Jul 2008 21:19:52 +0200 Subject: Record the command invocation path early We will need the command invocation path in system_path(). This path was passed to setup_path(), but system_path() can be called earlier, for example via: main commit_pager_choice setup_pager git_config git_etc_gitconfig system_path Therefore, we introduce git_set_argv0_path() and call it as soon as possible. Signed-off-by: Johannes Sixt Signed-off-by: Junio C Hamano --- exec_cmd.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'exec_cmd.c') diff --git a/exec_cmd.c b/exec_cmd.c index 8899e31b3b..dedb01da6f 100644 --- a/exec_cmd.c +++ b/exec_cmd.c @@ -5,6 +5,7 @@ extern char **environ; static const char *argv_exec_path; +static const char *argv0_path; static const char *builtin_exec_path(void) { @@ -50,6 +51,11 @@ const char *system_path(const char *path) return path; } +void git_set_argv0_path(const char *path) +{ + argv0_path = path; +} + void git_set_argv_exec_path(const char *exec_path) { argv_exec_path = exec_path; @@ -84,7 +90,7 @@ static void add_path(struct strbuf *out, const char *path) } } -void setup_path(const char *cmd_path) +void setup_path(void) { const char *old_path = getenv("PATH"); struct strbuf new_path; @@ -94,7 +100,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, cmd_path); + add_path(&new_path, argv0_path); if (old_path) strbuf_addstr(&new_path, old_path); -- cgit v1.2.3