5 #define COMMAND_SIZE 4096
7 int setup_connection(int *fd_in, int *fd_out, const char *remote_prog,
8 char *url, int rmt_argc, char **rmt_argv)
13 char command[COMMAND_SIZE];
20 if (!strcmp(url, "-")) {
26 host = strstr(url, "//");
29 path = strchr(host, '/');
32 path = strchr(host, ':');
37 return error("Bad URL: %s", url);
39 /* $GIT_RSH <host> "env GIT_DIR=<path> <remote_prog> <args...>" */
43 of |= add_to_string(&posn, &sizen, "env ", 0);
44 of |= add_to_string(&posn, &sizen, GIT_DIR_ENVIRONMENT "=", 0);
45 of |= add_to_string(&posn, &sizen, path, 1);
46 of |= add_to_string(&posn, &sizen, " ", 0);
47 of |= add_to_string(&posn, &sizen, remote_prog, 1);
49 for ( i = 0 ; i < rmt_argc ; i++ ) {
50 of |= add_to_string(&posn, &sizen, " ", 0);
51 of |= add_to_string(&posn, &sizen, rmt_argv[i], 1);
54 of |= add_to_string(&posn, &sizen, " -", 0);
57 return error("Command line too long");
59 if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv))
60 return error("Couldn't create socket");
64 return error("Couldn't fork");
66 const char *ssh, *ssh_basename;
67 ssh = getenv("GIT_SSH");
68 if (!ssh) ssh = "ssh";
69 ssh_basename = strrchr(ssh, '/');
77 execlp(ssh, ssh_basename, host, command, NULL);