Change git_connect() to return a struct child_process instead of a pid_t.

This prepares the API of git_connect() and finish_connect() to operate on
a struct child_process. Currently, we just use that object as a placeholder
for the pid that we used to return. A follow-up patch will change the
implementation of git_connect() and finish_connect() to make full use
of the object.

Old code had early-return-on-error checks at the calling sites of
git_connect(), but since git_connect() dies on errors anyway, these checks
were removed.

[sp: Corrected style nit of "conn == NULL" to "!conn"]

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
Johannes Sixt
2007-10-19 21:47:53 +02:00
committed by Shawn O. Pearce
parent ca5bb5d539
commit 98158e9cfd
7 changed files with 33 additions and 43 deletions

View File

@ -25,7 +25,7 @@ int main(int argc, char **argv)
int i, ret;
char *dest = NULL;
int fd[2];
pid_t pid;
struct child_process *conn;
int nongit = 0;
unsigned flags = 0;
@ -64,12 +64,10 @@ int main(int argc, char **argv)
if (!dest || i != argc - 1)
usage(peek_remote_usage);
pid = git_connect(fd, dest, uploadpack, 0);
if (pid < 0)
return 1;
conn = git_connect(fd, dest, uploadpack, 0);
ret = peek_remote(fd, flags);
close(fd[0]);
close(fd[1]);
ret |= finish_connect(pid);
ret |= finish_connect(conn);
return !!ret;
}