Merge branch 'lw/daemon-log-destination'
authorJunio C Hamano <gitster@pobox.com>
Wed, 25 Apr 2018 04:28:58 +0000 (13:28 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Apr 2018 04:28:58 +0000 (13:28 +0900)
Recent introduction of "--log-destination" option to "git daemon"
did not work well when the daemon was run under "--inetd" mode.

* lw/daemon-log-destination:
daemon.c: fix condition for redirecting stderr

1  2 
daemon.c
diff --combined daemon.c
index fe833ea7de7685968915c93950bb54768dd04586,78571690553850f3f96facd06b5e41bd414f4c35..9d2e0d20ef302aaeac02aaeba791509dd43a2712
+++ b/daemon.c
@@@ -611,7 -611,6 +611,7 @@@ static char *parse_host_arg(struct host
                if (strncasecmp("host=", extra_args, 5) == 0) {
                        val = extra_args + 5;
                        vallen = strlen(val) + 1;
 +                      loginfo("Extended attribute \"host\": %s", val);
                        if (*val) {
                                /* Split <host>:<port> at colon. */
                                char *host;
@@@ -662,11 -661,9 +662,11 @@@ static void parse_extra_args(struct hos
                }
        }
  
 -      if (git_protocol.len > 0)
 +      if (git_protocol.len > 0) {
 +              loginfo("Extended attribute \"protocol\": %s", git_protocol.buf);
                argv_array_pushf(env, GIT_PROTOCOL_ENVIRONMENT "=%s",
                                 git_protocol.buf);
 +      }
        strbuf_release(&git_protocol);
  }
  
@@@ -774,8 -771,14 +774,8 @@@ static int execute(void
        alarm(0);
  
        len = strlen(line);
 -      if (pktlen != len)
 -              loginfo("Extended attributes (%d bytes) exist <%.*s>",
 -                      (int) pktlen - len,
 -                      (int) pktlen - len, line + len + 1);
 -      if (len && line[len-1] == '\n') {
 -              line[--len] = 0;
 -              pktlen--;
 -      }
 +      if (len && line[len-1] == '\n')
 +              line[len-1] = 0;
  
        /* parse additional args hidden behind a NUL byte */
        if (len != pktlen)
@@@ -1459,7 -1462,7 +1459,7 @@@ int cmd_main(int argc, const char **arg
                die("base-path '%s' does not exist or is not a directory",
                    base_path);
  
-       if (inetd_mode) {
+       if (log_destination != LOG_DESTINATION_STDERR) {
                if (!freopen("/dev/null", "w", stderr))
                        die_errno("failed to redirect stderr to /dev/null");
        }