mktree: there are only two possible line terminations
[gitweb.git] / credential-cache--daemon.c
index eef6fce4c72ab37d75a0f75129666009a6a1ee54..cc65a9c0d342aa51d4b307fe10c626d940e2f211 100644 (file)
@@ -2,7 +2,6 @@
 #include "tempfile.h"
 #include "credential.h"
 #include "unix-socket.h"
-#include "sigchain.h"
 #include "parse-options.h"
 
 static struct tempfile socket_file;
@@ -97,12 +96,12 @@ static int read_request(FILE *fh, struct credential *c,
        static struct strbuf item = STRBUF_INIT;
        const char *p;
 
-       strbuf_getline(&item, fh, '\n');
+       strbuf_getline_lf(&item, fh);
        if (!skip_prefix(item.buf, "action=", &p))
                return error("client sent bogus action line: %s", item.buf);
        strbuf_addstr(action, p);
 
-       strbuf_getline(&item, fh, '\n');
+       strbuf_getline_lf(&item, fh);
        if (!skip_prefix(item.buf, "timeout=", &p))
                return error("client sent bogus timeout line: %s", item.buf);
        *timeout = atoi(p);
@@ -245,6 +244,7 @@ static void check_socket_directory(const char *path)
 int main(int argc, const char **argv)
 {
        const char *socket_path;
+       int ignore_sighup = 0;
        static const char *usage[] = {
                "git-credential-cache--daemon [opts] <socket_path>",
                NULL
@@ -256,6 +256,8 @@ int main(int argc, const char **argv)
                OPT_END()
        };
 
+       git_config_get_bool("credentialcache.ignoresighup", &ignore_sighup);
+
        argc = parse_options(argc, argv, NULL, options, usage, 0);
        socket_path = argv[0];
 
@@ -264,6 +266,10 @@ int main(int argc, const char **argv)
 
        check_socket_directory(socket_path);
        register_tempfile(&socket_file, socket_path);
+
+       if (ignore_sighup)
+               signal(SIGHUP, SIG_IGN);
+
        serve_cache(socket_path, debug);
        delete_tempfile(&socket_file);