connect: let callers know if connection is a socket

They might care because they want to do a half-duplex close. With pipes, that means simply closing the output descriptor; with a socket, you must actually call shutdown. Instead of exposing the magic no_fork child_process struct, let's encapsulate the test in a function. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed May 16, 2011 at 02:52 UTC 7ffe853b106680720ddec999e1daf5c186997a1f
2 files changed +7 -1
cache.h
+1
@@ -865,6 +865,7 @@ extern struct ref *find_ref_by_name(const struct ref *list, const char *name);
865 #define CONNECT_VERBOSE (1u << 0)
866 extern struct child_process *git_connect(int fd[2], const char *url, const char *prog, int flags);
867 extern int finish_connect(struct child_process *conn);
868 +extern int git_connection_is_socket(struct child_process *conn);
869 extern int path_match(const char *path, int nr, char **match);
870 struct extra_have_objects {
871 int nr, alloc;
connect.c
+6 -1
@@ -633,10 +633,15 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
633 return conn;
634 }
635
636 +int git_connection_is_socket(struct child_process *conn)
637 +{
638 + return conn == &no_fork;
639 +}
640 +
641 int finish_connect(struct child_process *conn)
642 {
643 int code;
639 - if (!conn || conn == &no_fork)
644 + if (!conn || git_connection_is_socket(conn))
645 return 0;
646
647 code = finish_command(conn);