git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: What's cooking in git.git (Mar 2009, #06; Sat, 21)

From
Johannes Sixt <j6t@kdbg.org>
Date
Mar 21, 2009, 22:21 UTC
Message-ID
<200903212321.18283.j6t@kdbg.org>
In-Reply-To
<7vk56jfgt2.fsf@gitster.siamese.dyndns.org>
On Samstag, 21. März 2009, Junio C Hamano wrote:
> * js/maint-1.6.0-exec-path-env (Wed Mar 18 08:42:53 2009 +0100) 1 commit
>  - export GIT_EXEC_PATH when git is run with --exec-path
Here is the patch again with a commit message that explains what's going on.

But notice that this is probably not a complete solution: As you can see (below) from the analysis, a git-repack that was taken from $prefix would invoke a git that is not from $prefix, but from the initial command's --exec-path. I think this can be solved by installing the git executable in $prefix/libexec/git-core as well.

-- Hannes
-- 8< --
Subject: [PATCH] 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>
---
 exec_cmd.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/exec_cmd.c b/exec_cmd.c
index 217c125..408e4e5 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -61,6 +61,10 @@ const char *git_extract_argv0_path(const char *argv0)
 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);
 }
 
 
-- 
1.6.2.1.224.g2225f
Previous: Wincent ColaiutaNext: Finn Arne Gangstad
Message 7 of 13 in “What's cooking in git.git (Mar 2009, #06; Sat, 21)”
  1. Junio C HamanoMar 21, 2009
  2. Wincent ColaiutaMar 21, 2009
  3. David AguilarMar 21, 2009
  4. Wincent ColaiutaMar 22, 2009
  5. Junio C HamanoMar 21, 2009
  6. Wincent ColaiutaMar 22, 2009
  7. Johannes SixtMar 21, 2009
  8. Finn Arne GangstadMar 23, 2009
  9. Junio C HamanoMar 23, 2009
  10. Junio C HamanoMar 24, 2009
  11. Junio C HamanoMar 24, 2009
  12. Finn Arne GangstadMar 24, 2009
  13. Junio C HamanoMar 25, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.