run-command.c: introduce trace_run_command()

This is the same as the old code that uses trace_argv_printf() in run-command.c. This function will be improved in later patches to print more information from struct child_process. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Jan 18, 2018 at 16:45 UTC e73dd78699c4a0a84960c3519e6bdc6e49009740
1 file changed +17 -1
run-command.c
+17 -1
@@ -6,6 +6,7 @@
6 #include "thread-utils.h"
7 #include "strbuf.h"
8 #include "string-list.h"
9 +#include "quote.h"
10
11 void child_process_init(struct child_process *child)
12 {
@@ -556,6 +557,20 @@ static int wait_or_whine(pid_t pid, const char *argv0, int in_signal)
557 return code;
558 }
559
560 +static void trace_run_command(const struct child_process *cp)
561 +{
562 + struct strbuf buf = STRBUF_INIT;
563 +
564 + if (!trace_want(&trace_default_key))
565 + return;
566 +
567 + strbuf_addf(&buf, "trace: run_command:");
568 + sq_quote_argv_pretty(&buf, cp->argv);
569 +
570 + trace_printf("%s", buf.buf);
571 + strbuf_release(&buf);
572 +}
573 +
574 int start_command(struct child_process *cmd)
575 {
576 int need_in, need_out, need_err;
@@ -624,7 +639,8 @@ fail_pipe:
639 cmd->err = fderr[0];
640 }
641
627 - trace_argv_printf(cmd->argv, "trace: run_command:");
642 + trace_run_command(cmd);
643 +
644 fflush(NULL);
645
646 #ifndef GIT_WINDOWS_NATIVE