credential-cache: new option to ignore sighup
authorNoam Postavsky <npostavs@users.sourceforge.net>
Tue, 10 Nov 2015 00:26:29 +0000 (19:26 -0500)
committerJeff King <peff@peff.net>
Fri, 20 Nov 2015 13:02:07 +0000 (08:02 -0500)
Introduce new option "credentialCache.ignoreSIGHUP" which stops
git-credential-cache--daemon from quitting on SIGHUP. This is useful
when "git push" is started from Emacs, because all child
processes (including the daemon) will receive a SIGHUP when "git push"
exits.

Signed-off-by: Noam Postavsky <npostavs@users.sourceforge.net>
Signed-off-by: Jeff King <peff@peff.net>
Documentation/config.txt
credential-cache--daemon.c
index b4b01948d0c52a42a322ed2cdeb33f475bf08c22..2d06b11f25e66779e84d9762c825a5d9c0a39ee0 100644 (file)
@@ -1122,6 +1122,9 @@ credential.<url>.*::
        example.com. See linkgit:gitcredentials[7] for details on how URLs are
        matched.
 
+credentialCache.ignoreSIGHUP::
+       Tell git-credential-cache--daemon to ignore SIGHUP, instead of quitting.
+
 include::diff-config.txt[]
 
 difftool.<tool>.path::
index 82715aa8b8c050591559a1c4f9f92b2e99602212..9365f2ce5c188d86b1b60029e4549e1bd844214f 100644 (file)
@@ -244,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
@@ -255,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];
 
@@ -263,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);