diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-07-19 13:22:19 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-07-19 13:22:19 -0700 |
commit | d4c6375fd8996d7d809fb34b9743339d7192c58b (patch) | |
tree | 958ff37108df971e18b2989cfc390d4dde80c41e /daemon.c | |
parent | df9da64a7c2aee12fd967cb9ff1730312d4b271d (diff) | |
parent | de61cebde72a15b85b6e6a06ef4c3614b6afdac8 (diff) | |
download | git-d4c6375fd8996d7d809fb34b9743339d7192c58b.tar.gz |
Merge branch 'jk/common-main'
There are certain house-keeping tasks that need to be performed at
the very beginning of any Git program, and programs that are not
built-in commands had to do them exactly the same way as "git"
potty does. It was easy to make mistakes in one-off standalone
programs (like test helpers). A common "main()" function that
calls cmd_main() of individual program has been introduced to
make it harder to make mistakes.
* jk/common-main:
mingw: declare main()'s argv as const
common-main: call git_setup_gettext()
common-main: call restore_sigpipe_to_default()
common-main: call sanitize_stdfds()
common-main: call git_extract_argv0_path()
add an extra level of indirection to main()
Diffstat (limited to 'daemon.c')
-rw-r--r-- | daemon.c | 16 |
1 files changed, 5 insertions, 11 deletions
@@ -1,6 +1,5 @@ #include "cache.h" #include "pkt-line.h" -#include "exec_cmd.h" #include "run-command.h" #include "strbuf.h" #include "string-list.h" @@ -32,7 +31,7 @@ static const char daemon_usage[] = " [<directory>...]"; /* List of acceptable pathname prefixes */ -static char **ok_paths; +static const char **ok_paths; static int strict_paths; /* If this is set, git-daemon-export-ok is not required */ @@ -240,7 +239,7 @@ static const char *path_ok(const char *directory, struct hostinfo *hi) } if ( ok_paths && *ok_paths ) { - char **pp; + const char **pp; int pathlen = strlen(path); /* The validation is done on the paths after enter_repo @@ -1192,7 +1191,7 @@ static int serve(struct string_list *listen_addr, int listen_port, return service_loop(&socklist); } -int main(int argc, char **argv) +int cmd_main(int argc, const char **argv) { int listen_port = 0; struct string_list listen_addr = STRING_LIST_INIT_NODUP; @@ -1202,12 +1201,8 @@ int main(int argc, char **argv) struct credentials *cred = NULL; int i; - git_setup_gettext(); - - git_extract_argv0_path(argv[0]); - for (i = 1; i < argc; i++) { - char *arg = argv[i]; + const char *arg = argv[i]; const char *v; if (skip_prefix(arg, "--listen=", &v)) { @@ -1381,8 +1376,7 @@ int main(int argc, char **argv) if (detach) { if (daemonize()) die("--detach not supported on this platform"); - } else - sanitize_stdfds(); + } if (pid_file) write_file(pid_file, "%"PRIuMAX, (uintmax_t) getpid()); |