6 int get_ack(int fd
, unsigned char *result_sha1
)
8 static char line
[1000];
9 int len
= packet_read_line(fd
, line
, sizeof(line
));
12 die("git-fetch-pack: expected ACK/NAK, got EOF");
13 if (line
[len
-1] == '\n')
15 if (!strcmp(line
, "NAK"))
17 if (!strncmp(line
, "ACK ", 3)) {
18 if (!get_sha1_hex(line
+4, result_sha1
))
21 die("git-fetch_pack: expected ACK/NAK, got '%s'", line
);
24 int path_match(const char *path
, int nr
, char **match
)
27 int pathlen
= strlen(path
);
29 for (i
= 0; i
< nr
; i
++) {
33 if (!len
|| len
> pathlen
)
35 if (memcmp(path
+ pathlen
- len
, s
, len
))
37 if (pathlen
> len
&& path
[pathlen
- len
- 1] != '/')
46 * Yeah, yeah, fixme. Need to pass in the heads etc.
48 int git_connect(int fd
[2], char *url
, const char *prog
)
51 const char *host
, *path
;
58 colon
= strchr(url
, ':');
64 if (pipe(pipefd
[0]) < 0 || pipe(pipefd
[1]) < 0)
65 die("unable to create pipe pair for communication");
68 snprintf(command
, sizeof(command
), "%s %s", prog
,
70 dup2(pipefd
[1][0], 0);
71 dup2(pipefd
[0][1], 1);
77 execlp("ssh", "ssh", host
, command
, NULL
);
79 execlp("sh", "sh", "-c", command
, NULL
);
89 int finish_connect(pid_t pid
)
94 ret
= waitpid(pid
, NULL
, 0);