credential-cache: new option to ignore sighup

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>

Noam Postavsky committed Nov 9, 2015 at 19:26 UTC 7f4d4746c14f928b7b6cdc2d21e4bbb2a770187f
2 files changed +10
Documentation/config.txt
+3
@@ -1122,6 +1122,9 @@ credential.<url>.*::
1122 example.com. See linkgit:gitcredentials[7] for details on how URLs are
1123 matched.
1124
1125 +credentialCache.ignoreSIGHUP::
1126 + Tell git-credential-cache--daemon to ignore SIGHUP, instead of quitting.
1127 +
1128 include::diff-config.txt[]
1129
1130 difftool.<tool>.path::
credential-cache--daemon.c
+7
@@ -244,6 +244,7 @@ static void check_socket_directory(const char *path)
244 int main(int argc, const char **argv)
245 {
246 const char *socket_path;
247 + int ignore_sighup = 0;
248 static const char *usage[] = {
249 "git-credential-cache--daemon [opts] <socket_path>",
250 NULL
@@ -255,6 +256,8 @@ int main(int argc, const char **argv)
256 OPT_END()
257 };
258
259 + git_config_get_bool("credentialcache.ignoresighup", &ignore_sighup);
260 +
261 argc = parse_options(argc, argv, NULL, options, usage, 0);
262 socket_path = argv[0];
263
@@ -263,6 +266,10 @@ int main(int argc, const char **argv)
266
267 check_socket_directory(socket_path);
268 register_tempfile(&socket_file, socket_path);
269 +
270 + if (ignore_sighup)
271 + signal(SIGHUP, SIG_IGN);
272 +
273 serve_cache(socket_path, debug);
274 delete_tempfile(&socket_file);
275