* Unable to clone an ssh repository (with ugly installation-specific workaround) @ 2008-02-12 2:22 Elijah Newren 2008-02-12 7:04 ` David Symonds 2008-02-12 8:16 ` Jakub Narebski 0 siblings, 2 replies; 11+ messages in thread From: Elijah Newren @ 2008-02-12 2:22 UTC (permalink / raw) To: git [-- Attachment #1: Type: text/plain, Size: 977 bytes --] Hi, I'm pretty sure this worked before, but with git-1.5.4, when trying to clone a repository via ssh from a machine that does not have git installed in a standard system path, I get the following: $ git clone -u /home/enewren/software/install/linux/git/bin/git-upload-pack ssh://enewren@remote/var/scratch/enewren/votd Initialized empty Git repository in /home/newren/devel/votd/.git/ remote: fatal: exec pack-objects failed. remote: aborting due to possible repository corruption on the remote side. fatal: early EOF fatal: index-pack failed fetch-pack from 'ssh://enewren@remote/var/scratch/enewren/votd' failed. I tried doing a local clone of the same repository (worked fine), a 'git fsck -full' on the relevant repository (reported no errors), and a few other things. After a bit of digging, I found a really ugly hack that works around my problem. After recompiling git on the remote machine with the attached patch, the clone operation succeeded. Thanks, Elijah [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: ugly-hack.patch --] [-- Type: text/x-patch; name=ugly-hack.patch, Size: 375 bytes --] --- git-1.5.4/exec_cmd.c~ 2008-02-01 21:09:01.000000000 -0700 +++ git-1.5.4/exec_cmd.c 2008-02-11 17:35:11.092796000 -0700 @@ -69,7 +69,7 @@ const char *tmp; strbuf_init(&cmd, 0); - strbuf_addf(&cmd, "git-%s", argv[0]); + strbuf_addf(&cmd, "/home/enewren/software/install/linux/git/bin/git-%s", argv[0]); /* * argv[0] must be the git command, but the argv array ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Unable to clone an ssh repository (with ugly installation-specific workaround) 2008-02-12 2:22 Unable to clone an ssh repository (with ugly installation-specific workaround) Elijah Newren @ 2008-02-12 7:04 ` David Symonds 2008-02-12 8:16 ` Jakub Narebski 1 sibling, 0 replies; 11+ messages in thread From: David Symonds @ 2008-02-12 7:04 UTC (permalink / raw) To: Elijah Newren; +Cc: Git Mailing List On Feb 11, 2008 6:22 PM, Elijah Newren <newren@gmail.com> wrote: > Hi, > > I'm pretty sure this worked before, but with git-1.5.4, when trying to > clone a repository via ssh from a machine that does not have git > installed in a standard system path, I get the following: Please post patches inline, not attached. The problem you've encountered is to do with the PATH setup on the remote end. See a previous thread (http://thread.gmane.org/gmane.comp.version-control.git/72673/focus=72805) for some solutions. Dave. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Unable to clone an ssh repository (with ugly installation-specific workaround) 2008-02-12 2:22 Unable to clone an ssh repository (with ugly installation-specific workaround) Elijah Newren 2008-02-12 7:04 ` David Symonds @ 2008-02-12 8:16 ` Jakub Narebski 2008-02-12 8:37 ` Johannes Sixt 1 sibling, 1 reply; 11+ messages in thread From: Jakub Narebski @ 2008-02-12 8:16 UTC (permalink / raw) To: Elijah Newren; +Cc: git "Elijah Newren" <newren@gmail.com> writes: > I'm pretty sure this worked before, but with git-1.5.4, when trying to > clone a repository via ssh from a machine that does not have git > installed in a standard system path, I get the following: > > $ git clone -u /home/enewren/software/install/linux/git/bin/git-upload-pack > ssh://enewren@remote/var/scratch/enewren/votd > Initialized empty Git repository in /home/newren/devel/votd/.git/ > remote: fatal: exec pack-objects failed. git-pull(1) [...] --upload-pack <upload-pack> When given, and the repository to fetch from is handled by git-fetch-pack, --exec=<upload-pack> is passed to the command to specify non-default path for the command run on the other end. -- Jakub Narebski Poland ShadeHawk on #git ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Unable to clone an ssh repository (with ugly installation-specific workaround) 2008-02-12 8:16 ` Jakub Narebski @ 2008-02-12 8:37 ` Johannes Sixt 2008-02-12 10:30 ` Johannes Schindelin 0 siblings, 1 reply; 11+ messages in thread From: Johannes Sixt @ 2008-02-12 8:37 UTC (permalink / raw) To: Jakub Narebski; +Cc: Elijah Newren, git Jakub Narebski schrieb: > "Elijah Newren" <newren@gmail.com> writes: > >> I'm pretty sure this worked before, but with git-1.5.4, when trying to >> clone a repository via ssh from a machine that does not have git >> installed in a standard system path, I get the following: >> >> $ git clone -u /home/enewren/software/install/linux/git/bin/git-upload-pack >> ssh://enewren@remote/var/scratch/enewren/votd >> Initialized empty Git repository in /home/newren/devel/votd/.git/ >> remote: fatal: exec pack-objects failed. > > git-pull(1) > [...] > --upload-pack <upload-pack> > When given, and the repository to fetch from is handled by > git-fetch-pack, --exec=<upload-pack> is passed to the command to > specify non-default path for the command run on the other end. > The OP *did* use this option (rather, its short form, -u), see above. The problem is that git-upload-pack (which is not a built-in) does not call setup_path() and so does not extend PATH to contain the special installation location. Now, when git-upload-pack tries to exec git-pack-objects, it fails since this is not in PATH. A quick work-around for Elijah is to add GIT_EXEC_PATH=/home/enewren/software/install/linux/git/bin to .profile on the remote host. -- Hannes ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Unable to clone an ssh repository (with ugly installation-specific workaround) 2008-02-12 8:37 ` Johannes Sixt @ 2008-02-12 10:30 ` Johannes Schindelin 2008-02-12 11:28 ` [PATCH] upload-pack: Initialize the exec-path Johannes Sixt 2008-02-13 12:57 ` Unable to clone an ssh repository (with ugly installation-specific workaround) Elijah Newren 0 siblings, 2 replies; 11+ messages in thread From: Johannes Schindelin @ 2008-02-12 10:30 UTC (permalink / raw) To: Johannes Sixt; +Cc: Jakub Narebski, Elijah Newren, git Hi, On Tue, 12 Feb 2008, Johannes Sixt wrote: > Jakub Narebski schrieb: > > "Elijah Newren" <newren@gmail.com> writes: > > > >> I'm pretty sure this worked before, but with git-1.5.4, when trying > >> to clone a repository via ssh from a machine that does not have git > >> installed in a standard system path, I get the following: > >> > >> $ git clone -u /home/enewren/software/install/linux/git/bin/git-upload-pack > >> ssh://enewren@remote/var/scratch/enewren/votd > >> Initialized empty Git repository in /home/newren/devel/votd/.git/ > >> remote: fatal: exec pack-objects failed. > > > > git-pull(1) > > [...] > > --upload-pack <upload-pack> > > When given, and the repository to fetch from is handled by > > git-fetch-pack, --exec=<upload-pack> is passed to the command to > > specify non-default path for the command run on the other end. > > > > The OP *did* use this option (rather, its short form, -u), see above. > > The problem is that git-upload-pack (which is not a built-in) does not > call setup_path() and so does not extend PATH to contain the special > installation location. Now, when git-upload-pack tries to exec > git-pack-objects, it fails since this is not in PATH. So, let's make git-upload-pack a builtin, no? > A quick work-around for Elijah is to add > > GIT_EXEC_PATH=/home/enewren/software/install/linux/git/bin > > to .profile on the remote host. I guess you meant .bashrc, as .profile is not sourced when using ssh transport (it does not spawn a shell) AFAIR. Ciao, Dscho ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] upload-pack: Initialize the exec-path. 2008-02-12 10:30 ` Johannes Schindelin @ 2008-02-12 11:28 ` Johannes Sixt 2008-02-12 11:49 ` Johannes Schindelin 2008-02-13 12:57 ` Unable to clone an ssh repository (with ugly installation-specific workaround) Elijah Newren 1 sibling, 1 reply; 11+ messages in thread From: Johannes Sixt @ 2008-02-12 11:28 UTC (permalink / raw) To: Johannes Schindelin; +Cc: Jakub Narebski, Elijah Newren, git From: Johannes Sixt <johannes.sixt@telecom.at> Since git-upload-pack has to spawn git-pack-objects, it has to make sure that the latter can be found in the PATH. Without this patch an attempt to clone or pull via ssh from a server fails if the git tools are not in the standard PATH on the server even though git clone or git pull were invoked with --upload-pack=/path/to/git-upload-pack. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> --- Johannes Schindelin schrieb: > Hi, > > On Tue, 12 Feb 2008, Johannes Sixt wrote: >> The problem is that git-upload-pack (which is not a built-in) does not >> call setup_path() and so does not extend PATH to contain the special >> installation location. Now, when git-upload-pack tries to exec >> git-pack-objects, it fails since this is not in PATH. > > So, let's make git-upload-pack a builtin, no? How about this (almost) one-liner instead? -- Hannes upload-pack.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 7e04311..51e3ec4 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -620,6 +620,9 @@ int main(int argc, char **argv) if (i != argc-1) usage(upload_pack_usage); + + setup_path(NULL); + dir = argv[i]; if (!enter_repo(dir, strict)) -- 1.5.4.rc3.24.g25a9a ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] upload-pack: Initialize the exec-path. 2008-02-12 11:28 ` [PATCH] upload-pack: Initialize the exec-path Johannes Sixt @ 2008-02-12 11:49 ` Johannes Schindelin 2008-02-12 12:45 ` Johannes Schindelin 0 siblings, 1 reply; 11+ messages in thread From: Johannes Schindelin @ 2008-02-12 11:49 UTC (permalink / raw) To: Johannes Sixt; +Cc: Jakub Narebski, Elijah Newren, git Hi, On Tue, 12 Feb 2008, Johannes Sixt wrote: > Johannes Schindelin schrieb: > > Hi, > > > > On Tue, 12 Feb 2008, Johannes Sixt wrote: > >> The problem is that git-upload-pack (which is not a built-in) does not > >> call setup_path() and so does not extend PATH to contain the special > >> installation location. Now, when git-upload-pack tries to exec > >> git-pack-objects, it fails since this is not in PATH. > > > > So, let's make git-upload-pack a builtin, no? > > How about this (almost) one-liner instead? I'm fine with it. Ciao, Dscho ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] upload-pack: Initialize the exec-path. 2008-02-12 11:49 ` Johannes Schindelin @ 2008-02-12 12:45 ` Johannes Schindelin 2008-02-13 13:00 ` Elijah Newren 0 siblings, 1 reply; 11+ messages in thread From: Johannes Schindelin @ 2008-02-12 12:45 UTC (permalink / raw) To: Johannes Sixt; +Cc: Jakub Narebski, Elijah Newren, git Hi, On Tue, 12 Feb 2008, Johannes Schindelin wrote: > On Tue, 12 Feb 2008, Johannes Sixt wrote: > > > Johannes Schindelin schrieb: > > > > > So, let's make git-upload-pack a builtin, no? > > > > How about this (almost) one-liner instead? > > I'm fine with it. But I also made this: -- snipsnap -- [PATCH] Make upload-pack a builtin Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- Makefile | 2 +- upload-pack.c => builtin-upload-pack.c | 8 +++++--- builtin.h | 1 + git.c | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) rename upload-pack.c => builtin-upload-pack.c (98%) diff --git a/Makefile b/Makefile index 83c359a..1792039 100644 --- a/Makefile +++ b/Makefile @@ -259,7 +259,6 @@ PROGRAMS = \ git-show-index$X \ git-unpack-file$X \ git-update-server-info$X \ - git-upload-pack$X \ git-pack-redundant$X git-var$X \ git-merge-tree$X git-imap-send$X \ git-merge-recursive$X \ @@ -392,6 +391,7 @@ BUILTIN_OBJS = \ builtin-update-index.o \ builtin-update-ref.o \ builtin-upload-archive.o \ + builtin-upload-pack.o \ builtin-verify-pack.o \ builtin-verify-tag.o \ builtin-write-tree.o \ diff --git a/upload-pack.c b/builtin-upload-pack.c similarity index 98% rename from upload-pack.c rename to builtin-upload-pack.c index 7e04311..207754c 100644 --- a/upload-pack.c +++ b/builtin-upload-pack.c @@ -10,6 +10,7 @@ #include "revision.h" #include "list-objects.h" #include "run-command.h" +#include "builtin.h" static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=nn] <dir>"; @@ -593,14 +594,14 @@ static void upload_pack(void) } } -int main(int argc, char **argv) +int cmd_upload_pack(int argc, const char **argv, const char *prefix) { char *dir; int i; int strict = 0; for (i = 1; i < argc; i++) { - char *arg = argv[i]; + const char *arg = argv[i]; if (arg[0] != '-') break; @@ -620,12 +621,13 @@ int main(int argc, char **argv) if (i != argc-1) usage(upload_pack_usage); - dir = argv[i]; + dir = xstrdup(argv[i]); if (!enter_repo(dir, strict)) die("'%s': unable to chdir or not a git archive", dir); if (is_repository_shallow()) die("attempt to fetch/clone from a shallow repository"); upload_pack(); + free(dir); return 0; } diff --git a/builtin.h b/builtin.h index 3d1628c..5e7d661 100644 --- a/builtin.h +++ b/builtin.h @@ -85,6 +85,7 @@ extern int cmd_unpack_objects(int argc, const char **argv, const char *prefix); extern int cmd_update_index(int argc, const char **argv, const char *prefix); extern int cmd_update_ref(int argc, const char **argv, const char *prefix); extern int cmd_upload_archive(int argc, const char **argv, const char *prefix); +extern int cmd_upload_pack(int argc, const char **argv, const char *prefix); extern int cmd_upload_tar(int argc, const char **argv, const char *prefix); extern int cmd_verify_tag(int argc, const char **argv, const char *prefix); extern int cmd_version(int argc, const char **argv, const char *prefix); diff --git a/git.c b/git.c index 0cb8688..f0d831c 100644 --- a/git.c +++ b/git.c @@ -362,6 +362,7 @@ static void handle_internal_command(int argc, const char **argv) { "update-index", cmd_update_index, RUN_SETUP }, { "update-ref", cmd_update_ref, RUN_SETUP }, { "upload-archive", cmd_upload_archive }, + { "upload-pack", cmd_upload_pack }, { "verify-tag", cmd_verify_tag, RUN_SETUP }, { "version", cmd_version }, { "whatchanged", cmd_whatchanged, RUN_SETUP | USE_PAGER }, -- 1.5.4.1.1276.g92036 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] upload-pack: Initialize the exec-path. 2008-02-12 12:45 ` Johannes Schindelin @ 2008-02-13 13:00 ` Elijah Newren 0 siblings, 0 replies; 11+ messages in thread From: Elijah Newren @ 2008-02-13 13:00 UTC (permalink / raw) To: Johannes Schindelin; +Cc: Johannes Sixt, Jakub Narebski, git On Feb 12, 2008 5:45 AM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote: > On Tue, 12 Feb 2008, Johannes Schindelin wrote: > > On Tue, 12 Feb 2008, Johannes Sixt wrote: > > > Johannes Schindelin schrieb: > > > > So, let's make git-upload-pack a builtin, no? > > > > > > How about this (almost) one-liner instead? > > > > I'm fine with it. > > But I also made this: > > -- snipsnap -- > [PATCH] Make upload-pack a builtin > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> <snip> I tried this patch yesterday, but it seems to suffer from the same problem? I had to manually apply the patch from Johannes Sixt on top of this ("manually" since there was a trivial conflict) in order for it to solve the problem. Anyway, it works for me now. Thanks for the quick fixes! Elijah ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Unable to clone an ssh repository (with ugly installation-specific workaround) 2008-02-12 10:30 ` Johannes Schindelin 2008-02-12 11:28 ` [PATCH] upload-pack: Initialize the exec-path Johannes Sixt @ 2008-02-13 12:57 ` Elijah Newren 2008-02-13 14:17 ` Stephen Sinclair 1 sibling, 1 reply; 11+ messages in thread From: Elijah Newren @ 2008-02-13 12:57 UTC (permalink / raw) To: Johannes Schindelin; +Cc: Johannes Sixt, Jakub Narebski, git On Feb 12, 2008 3:30 AM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote: > > A quick work-around for Elijah is to add > > > > GIT_EXEC_PATH=/home/enewren/software/install/linux/git/bin > > > > to .profile on the remote host. > > I guess you meant .bashrc, as .profile is not sourced when using ssh > transport (it does not spawn a shell) AFAIR. As far as I can tell, setting paths in .bashrc doesn't really work (or else I'm just doing it wrong). If it did, I would have never hit this bug. Observe the difference between (feel free to replace PATH with GIT_EXEC_PATH; same general result occurs): $ ssh localhost # Wait for connection to be made, then run $ echo $PATH AND $ ssh localhost 'echo $PATH' AND $ ssh localhost 'source .bashrc echo $PATH' The first and the third give the same result, but the second gives something different. It is the second form that git uses, meaning that my paths never get set up. In my little git wrapper script, I put in some code to work around this little issue and find git-upload-pack for the user if it can (by ssh'ing to the machine and sourcing their .bashrc in the ssh command if necessary; might be a hack, but it makes things nicer for me than always specifying the -u flag). Cheers, Elijah ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Unable to clone an ssh repository (with ugly installation-specific workaround) 2008-02-13 12:57 ` Unable to clone an ssh repository (with ugly installation-specific workaround) Elijah Newren @ 2008-02-13 14:17 ` Stephen Sinclair 0 siblings, 0 replies; 11+ messages in thread From: Stephen Sinclair @ 2008-02-13 14:17 UTC (permalink / raw) To: Elijah Newren; +Cc: Johannes Schindelin, Johannes Sixt, Jakub Narebski, git On Feb 13, 2008 7:57 AM, Elijah Newren <newren@gmail.com> wrote: > On Feb 12, 2008 3:30 AM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote: > > > A quick work-around for Elijah is to add > > > > > > GIT_EXEC_PATH=/home/enewren/software/install/linux/git/bin > > > > > > to .profile on the remote host. > > > > I guess you meant .bashrc, as .profile is not sourced when using ssh > > transport (it does not spawn a shell) AFAIR. > > As far as I can tell, setting paths in .bashrc doesn't really work (or > else I'm just doing it wrong). If it did, I would have never hit this > bug. Observe the difference between (feel free to replace PATH with > GIT_EXEC_PATH; same general result occurs): > > $ ssh localhost > # Wait for connection to be made, then run > $ echo $PATH > > AND > > $ ssh localhost 'echo $PATH' > > AND > > $ ssh localhost 'source .bashrc > echo $PATH' > > The first and the third give the same result, but the second gives > something different. It is the second form that git uses, meaning > that my paths never get set up. I had this problem as well, and the only solution I found was setting up my .ssh/environment file. I guess when you specify a command for ssh, it executes this command by itself, not within a shell environment. Usually it is bash that sources .bashrc and .profile, so you don't get your paths set up. Unfortunately .ssh/environment is not a scripting environment, so you have to just specify your full path there, based on what you get when you echo $PATH from the shell. Also, this requires putting the following in sshd_config: PermitUserEnvironment yes Which, and this is the biter, is not usually a default on most systems, as far as I can see.. so it could mean bugging the sysadmin if it's not your machine, which is not always convenient. Can't see any alternative though. Steve ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-02-13 14:18 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-02-12 2:22 Unable to clone an ssh repository (with ugly installation-specific workaround) Elijah Newren 2008-02-12 7:04 ` David Symonds 2008-02-12 8:16 ` Jakub Narebski 2008-02-12 8:37 ` Johannes Sixt 2008-02-12 10:30 ` Johannes Schindelin 2008-02-12 11:28 ` [PATCH] upload-pack: Initialize the exec-path Johannes Sixt 2008-02-12 11:49 ` Johannes Schindelin 2008-02-12 12:45 ` Johannes Schindelin 2008-02-13 13:00 ` Elijah Newren 2008-02-13 12:57 ` Unable to clone an ssh repository (with ugly installation-specific workaround) Elijah Newren 2008-02-13 14:17 ` Stephen Sinclair
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).