From: Linus Torvalds Date: Tue, 7 Jun 2005 21:23:46 +0000 (-0700) Subject: git-ssh-push/pull: usability improvements X-Git-Tag: v0.99~325 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=001d4a27dbfaaa59c25dc35dafc69bd9b9bc21d3;p=git.git git-ssh-push/pull: usability improvements Allow traditional ssh path specifiers (host:path), and let the user override the command name on the other end. With this, I can push to kernel.org with this script export GIT_SSH_PULL=/home/torvalds/bin/git-ssh-pull git-ssh-push -a -v -w heads/master heads/master master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6.git which while not pretty is at least workable. --- diff --git a/rsh.c b/rsh.c index 3eb9d9160..8eea1d023 100644 --- a/rsh.c +++ b/rsh.c @@ -8,7 +8,7 @@ #define COMMAND_SIZE 4096 -int setup_connection(int *fd_in, int *fd_out, char *remote_prog, +int setup_connection(int *fd_in, int *fd_out, const char *remote_prog, char *url, int rmt_argc, char **rmt_argv) { char *host; @@ -25,11 +25,13 @@ int setup_connection(int *fd_in, int *fd_out, char *remote_prog, } host = strstr(url, "//"); - if (!host) { - return error("Bad URL: %s", url); + if (host) { + host += 2; + path = strchr(host, '/'); + } else { + host = url; + path = strchr(host, ':'); } - host += 2; - path = strchr(host, '/'); if (!path) { return error("Bad URL: %s", url); } diff --git a/rsh.h b/rsh.h index 97e4f20b2..3b4194239 100644 --- a/rsh.h +++ b/rsh.h @@ -1,7 +1,7 @@ #ifndef RSH_H #define RSH_H -int setup_connection(int *fd_in, int *fd_out, char *remote_prog, +int setup_connection(int *fd_in, int *fd_out, const char *remote_prog, char *url, int rmt_argc, char **rmt_argv); #endif diff --git a/ssh-pull.c b/ssh-pull.c index c2cb59a65..27484126d 100644 --- a/ssh-pull.c +++ b/ssh-pull.c @@ -58,6 +58,7 @@ int main(int argc, char **argv) char *commit_id; char *url; int arg = 1; + const char *prog = getenv("GIT_SSH_PUSH") ? : "git-ssh-push"; while (arg < argc && argv[arg][0] == '-') { if (argv[arg][1] == 't') { @@ -87,7 +88,7 @@ int main(int argc, char **argv) commit_id = argv[arg]; url = argv[arg + 1]; - if (setup_connection(&fd_in, &fd_out, "git-ssh-push", url, arg, argv + 1)) + if (setup_connection(&fd_in, &fd_out, prog, url, arg, argv + 1)) return 1; if (get_version()) diff --git a/ssh-push.c b/ssh-push.c index b67a95b9a..18c0b65d5 100644 --- a/ssh-push.c +++ b/ssh-push.c @@ -109,6 +109,8 @@ int main(int argc, char **argv) char *commit_id; char *url; int fd_in, fd_out; + const char *prog = getenv("GIT_SSH_PULL") ? : "git-ssh-pull"; + while (arg < argc && argv[arg][0] == '-') { if (argv[arg][1] == 'w') arg++; @@ -120,7 +122,7 @@ int main(int argc, char **argv) } commit_id = argv[arg]; url = argv[arg + 1]; - if (setup_connection(&fd_in, &fd_out, "git-ssh-pull", url, arg, argv + 1)) + if (setup_connection(&fd_in, &fd_out, prog, url, arg, argv + 1)) return 1; service(fd_in, fd_out);