aboutsummaryrefslogtreecommitdiffstats
path: root/daemon.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-09-08 21:35:50 -0700
committerJunio C Hamano <gitster@pobox.com>2016-09-08 21:35:51 -0700
commitfaacc8efe503a470c0c549c7949824728d7f1461 (patch)
treef30d2326414d09425902be4e3eb56bcdd0413241 /daemon.c
parente0c1ceafc5bece92d35773a75fff59497e1d9bd5 (diff)
parentde61cebde72a15b85b6e6a06ef4c3614b6afdac8 (diff)
downloadgit-faacc8efe503a470c0c549c7949824728d7f1461.tar.gz
Merge branch 'jk/common-main' into maint
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.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/daemon.c b/daemon.c
index a84495113e..425aad0507 100644
--- a/daemon.c
+++ b/daemon.c
@@ -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
@@ -1194,7 +1193,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;
@@ -1204,12 +1203,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)) {
@@ -1383,8 +1378,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());