git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: git@vger.kernel.org
Cc: Michael J Gruber <git@drmicha.warpmail.net>
Subject: [PATCH] help git-upload-pack find git
Date: Mon, 15 Sep 2008 18:24:51 +0200	[thread overview]
Message-ID: <1221495891-12600-1-git-send-email-git@drmicha.warpmail.net> (raw)
In-Reply-To: <d3a045300809150130w6f78edd8xf599d1c7f639b77d@mail.gmail.com>
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

  reply	other threads:[~2008-09-15 16:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-10  2:29 git-clone: path or ssh problem with git-upload-pack in 1.6.0? Paul Johnston
2008-09-15  8:30 ` Paul Johnston
2008-09-15 16:24   ` Michael J Gruber [this message]
2008-09-15 19:34     ` [PATCH] help git-upload-pack find git Junio C Hamano
2008-09-15 20:22       ` Michael J Gruber
2008-09-16  6:17         ` Johannes Sixt
2008-09-16 13:15           ` Michael J Gruber
2008-09-16 13:43             ` Johannes Sixt
2008-09-16 15:38               ` Michael J Gruber
2008-09-15 16:25   ` git-clone: path or ssh problem with git-upload-pack in 1.6.0? Michael J Gruber
2008-09-15 22:39 ` Michael Wookey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1221495891-12600-1-git-send-email-git@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).