5 #include <sys/socket.h>
9 #define COMMAND_SIZE 4096
11 int setup_connection(int *fd_in, int *fd_out, const char *remote_prog,
12 char *url, int rmt_argc, char **rmt_argv)
17 char command[COMMAND_SIZE];
21 if (!strcmp(url, "-")) {
27 host = strstr(url, "//");
30 path = strchr(host, '/');
33 path = strchr(host, ':');
36 return error("Bad URL: %s", url);
39 /* ssh <host> 'cd /<path>; stdio-pull <arg...> <commit-id>' */
40 snprintf(command, COMMAND_SIZE,
42 GIT_DIR_ENVIRONMENT, path, remote_prog);
43 posn = command + strlen(command);
44 for (i = 0; i < rmt_argc; i++) {
46 strncpy(posn, rmt_argv[i], COMMAND_SIZE - (posn - command));
47 posn += strlen(rmt_argv[i]);
48 if (posn - command + 4 >= COMMAND_SIZE) {
49 return error("Command line too long");
53 if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv)) {
54 return error("Couldn't create socket");
60 execlp("ssh", "ssh", host, command, NULL);