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

[PATCH] help git-upload-pack find git

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Sep 15, 2008, 16:24 UTC
Message-ID
<1221495891-12600-1-git-send-email-git@drmicha.warpmail.net>
In-Reply-To
<d3a045300809150130w6f78edd8xf599d1c7f639b77d@mail.gmail.com>

The --upload-pack option to clone raises the expectation that finding git-upload-pack on the server side is enough. But git-upload-pack needs to find git (for forking "git pack-objects") which fails if git is not in $PATH.

This patch makes git-upload-pack use git_set_argv0_path() so that an explicitely specified path for git-upload-pack is added to the path which is used when fork()ing.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 upload-pack.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

The corresponding bug was reported by Paul Johnston who wondered why "git clone" failed when specifying --upload-pack for an out-of-$PATH installation of git. I'm not sure whether we should encourage this, but the --upload-pack option clearly gives the impression that git-upload-pack is all that is needed.

I haven't looked at other server side programmes yet regarding this issue, but "git clone" works fine with this patch in the situation where it would not without.

diff --git a/upload-pack.c b/upload-pack.c
index e5adbc0..1fb59de 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -615,6 +615,21 @@ int main(int argc, char **argv)
 	char *dir;
 	int i;
 	int strict = 0;
+	const char *cmd = argv[0] && *argv[0] ? argv[0] : "git-upload-pack";
+	char *slash = (char *)cmd + strlen(cmd);
+
+	/*
+	 * Take the basename of argv[0] as the command
+	 * name, and the dirname as the default exec_path
+	 * if we don't have anything better.
+	 */
+	do
+		--slash;
+	while (cmd <= slash && !is_dir_sep(*slash));
+	if (cmd <= slash) {
+		*slash++ = 0;
+		git_set_argv0_path(cmd);
+	}
 
 	for (i = 1; i < argc; i++) {
 		char *arg = argv[i];
-- 
1.6.0.1.308.gede4c
Previous: Paul JohnstonNext: Junio C Hamano
Message 3 of 11 in “git-clone: path or ssh problem with git-upload-pack in 1.6.0?”
  1. Paul JohnstonSep 10, 2008
  2. Paul JohnstonSep 15, 2008
  3. help git-upload-pack find gitMichael J Gruber, Sep 15, 2008
  4. Junio C HamanoSep 15, 2008
  5. Michael J GruberSep 15, 2008
  6. Johannes SixtSep 16, 2008
  7. Michael J GruberSep 16, 2008
  8. Johannes SixtSep 16, 2008
  9. Michael J GruberSep 16, 2008
  10. Michael J GruberSep 15, 2008
  11. Michael WookeySep 15, 2008

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.