aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Sixt <j6t@kdbg.org>2009-03-21 23:21:18 +0100
committerJunio C Hamano <gitster@pobox.com>2009-03-21 21:45:14 -0700
commitc90d565a46a664663467557d381417a3153fe26e (patch)
tree13695bb8fc92744f295ad08150106f8627c7b426
parent688ba09cad80b0821886ad78fec039092306cead (diff)
downloadgit-c90d565a46a664663467557d381417a3153fe26e.tar.gz
git-c90d565a46a664663467557d381417a3153fe26e.tar.xz
Propagate --exec-path setting to external commands via GIT_EXEC_PATH
Let PATH0=$PATH that was set before the invocation. Let /foo be a build directory. Let /pfx be the installation prefix. Let pfxexecpath=/pfx/libexec/git-core. The following is going on when 'git --exec-path=/foo gc' is invoked: 1. git sets PATH=/foo:$PATH0 using the path from --exec-path 2. gc execs 'git repack' (note: no dash). 3. Since there is a git in /foo (it's a build directory), /foo/git is taken. 4. No explicit exec-path is set this time, hence, this secondary git sets PATH=$pfxexecpath:/foo:$PATH 5. Since 'repack' is not a built-in, execv_dashed_external execs 'git-repack' (note: dash). 6. There is a $pfxexecpath/git-repack, and it is taken. 7. This git-repack runs 'git pack-objects' (note: no dash). 8. There is no git in $pfxexecpath, but there is one in /foo. Hence, /foo/git is run. 9. pack-objects is a builtin, hence, in effect /foo/git-pack-objects is run. As you can see, the way in which we previously set the PATH allowed to mix gits of different vintage. By setting GIT_EXEC_PATH when --exec-path was given on the command line, we reduce the confusion. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--exec_cmd.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/exec_cmd.c b/exec_cmd.c
index ce6741eb6..589059f02 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -25,6 +25,10 @@ void git_set_argv0_path(const char *path)
void git_set_argv_exec_path(const char *exec_path)
{
argv_exec_path = exec_path;
+ /*
+ * Propagate this setting to external programs.
+ */
+ setenv(EXEC_PATH_ENVIRONMENT, exec_path, 1);
}