From ea476195ab8c45e123302ec5481274f59d11d38c Mon Sep 17 00:00:00 2001 From: Steve Haslam Date: Wed, 30 Jul 2008 12:27:18 +0100 Subject: [PATCH] Glean libexec path from argv[0] for git-upload-pack and git-receive-pack. If the user specified the full path to git-upload-pack as the -u option to "git clone" when cloning a remote repository, and git was not on the default PATH on the remote machine, git-upload-pack was failing to exec git-pack-objects. By making the argv[0] path (if any) available to setup_path(), this will allow finding the "git" executable in the same directory as "git-upload-pack". The default built in to exec_cmd.c is to look for "git" in the ".../libexec/git-core" directory, but it is not installed there (any longer). Much the same applies to invoking git-receive-pack from a non-PATH location using the "--exec" argument to "git push". [ spr: split Steve's original commit into two commits. ] Signed-off-by: Steve Haslam Signed-off-by: Steffen Prohaska --- builtin-receive-pack.c | 3 +++ upload-pack.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/builtin-receive-pack.c b/builtin-receive-pack.c index db67c3162c..bbedcfe5e4 100644 --- a/builtin-receive-pack.c +++ b/builtin-receive-pack.c @@ -579,6 +579,9 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix) int i; char *dir = NULL; + if (argv[0] && *argv[0]) + git_extract_argv0_path(argv[0]); + argv++; for (i = 1; i < argc; i++) { const char *arg = *argv++; diff --git a/upload-pack.c b/upload-pack.c index e5adbc011e..c469a60d79 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -616,6 +616,9 @@ int main(int argc, char **argv) int i; int strict = 0; + if (argv[0] && *argv[0]) + git_extract_argv0_path(argv[0]); + for (i = 1; i < argc; i++) { char *arg = argv[i];