summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0f503d7)
raw | patch | inline | side by side (parent: 0f503d7)
author | Franck Bui-Huu <vagabon.xyz@gmail.com> | |
Tue, 12 Sep 2006 09:00:13 +0000 (11:00 +0200) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 13 Sep 2006 05:30:32 +0000 (22:30 -0700) |
git_connect() can return 0 if we use git protocol for example.
Users of this function don't know and don't care if a process
had been created or not, and to avoid them to check it before
calling finish_connect() this patch allows finish_connect() to
take a null pid. And in that case return 0.
[jc: updated function signature of git_connect() with a comment on
its return value. ]
Signed-off-by: Franck Bui-Huu <vagabon.xyz@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Users of this function don't know and don't care if a process
had been created or not, and to avoid them to check it before
calling finish_connect() this patch allows finish_connect() to
take a null pid. And in that case return 0.
[jc: updated function signature of git_connect() with a comment on
its return value. ]
Signed-off-by: Franck Bui-Huu <vagabon.xyz@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
cache.h | patch | blob | history | |
connect.c | patch | blob | history |
index a53204f6d695cfe7fef3afdde296564dbcf37423..8d099979d9a04231d73307c786d25bf412a3f22c 100644 (file)
--- a/cache.h
+++ b/cache.h
#define REF_HEADS (1u << 1)
#define REF_TAGS (1u << 2)
-extern int git_connect(int fd[2], char *url, const char *prog);
+extern pid_t git_connect(int fd[2], char *url, const char *prog);
extern int finish_connect(pid_t pid);
extern int path_match(const char *path, int nr, char **match);
extern int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
diff --git a/connect.c b/connect.c
index 49251f9437183e74565c4965fa3d4451d6f29a0d..c55a20a4aa31e7cf1bbf0dcec6b4ebccb655d850 100644 (file)
--- a/connect.c
+++ b/connect.c
#define MAX_CMD_LEN 1024
/*
- * Yeah, yeah, fixme. Need to pass in the heads etc.
+ * This returns 0 if the transport protocol does not need fork(2),
+ * or a process id if it does. Once done, finish the connection
+ * with finish_connect() with the value returned from this function
+ * (it is safe to call finish_connect() with 0 to support the former
+ * case).
+ *
+ * Does not return a negative value on error; it just dies.
*/
-int git_connect(int fd[2], char *url, const char *prog)
+pid_t git_connect(int fd[2], char *url, const char *prog)
{
char *host, *path = url;
char *end;
int finish_connect(pid_t pid)
{
+ if (pid == 0)
+ return 0;
+
while (waitpid(pid, NULL, 0) < 0) {
if (errno != EINTR)
return -1;