]> git.ipfire.org Git - thirdparty/git.git/commitdiff
trace2: cleanup whitespace in normal format
authorJeff Hostetler <jeffhost@microsoft.com>
Fri, 9 Aug 2019 15:00:56 +0000 (08:00 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 9 Aug 2019 17:48:02 +0000 (10:48 -0700)
Make use of new sq_append_quote_argv_pretty() to normalize
how we handle leading whitespace in normal format messages.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
trace2/tr2_tgt_normal.c

index 213724d5cb92649192e8fab06b4b5283a8b0319b..438ed05a408e627d1cee0776e22762e10a5e4a3a 100644 (file)
@@ -87,7 +87,7 @@ static void fn_start_fl(const char *file, int line,
        struct strbuf buf_payload = STRBUF_INIT;
 
        strbuf_addstr(&buf_payload, "start ");
-       sq_quote_argv_pretty(&buf_payload, argv);
+       sq_append_quote_argv_pretty(&buf_payload, argv);
        normal_io_write_fl(file, line, &buf_payload);
        strbuf_release(&buf_payload);
 }
@@ -186,8 +186,8 @@ static void fn_alias_fl(const char *file, int line, const char *alias,
 {
        struct strbuf buf_payload = STRBUF_INIT;
 
-       strbuf_addf(&buf_payload, "alias %s ->", alias);
-       sq_quote_argv_pretty(&buf_payload, argv);
+       strbuf_addf(&buf_payload, "alias %s -> ", alias);
+       sq_append_quote_argv_pretty(&buf_payload, argv);
        normal_io_write_fl(file, line, &buf_payload);
        strbuf_release(&buf_payload);
 }
@@ -198,12 +198,12 @@ static void fn_child_start_fl(const char *file, int line,
 {
        struct strbuf buf_payload = STRBUF_INIT;
 
-       strbuf_addf(&buf_payload, "child_start[%d] ", cmd->trace2_child_id);
+       strbuf_addf(&buf_payload, "child_start[%d]", cmd->trace2_child_id);
 
        if (cmd->dir) {
-               strbuf_addstr(&buf_payload, " cd");
+               strbuf_addstr(&buf_payload, " cd ");
                sq_quote_buf_pretty(&buf_payload, cmd->dir);
-               strbuf_addstr(&buf_payload, "; ");
+               strbuf_addstr(&buf_payload, ";");
        }
 
        /*
@@ -211,9 +211,10 @@ static void fn_child_start_fl(const char *file, int line,
         * See trace_add_env() in run-command.c as used by original trace.c
         */
 
+       strbuf_addch(&buf_payload, ' ');
        if (cmd->git_cmd)
-               strbuf_addstr(&buf_payload, "git");
-       sq_quote_argv_pretty(&buf_payload, cmd->argv);
+               strbuf_addstr(&buf_payload, "git ");
+       sq_append_quote_argv_pretty(&buf_payload, cmd->argv);
 
        normal_io_write_fl(file, line, &buf_payload);
        strbuf_release(&buf_payload);
@@ -238,9 +239,11 @@ static void fn_exec_fl(const char *file, int line, uint64_t us_elapsed_absolute,
        struct strbuf buf_payload = STRBUF_INIT;
 
        strbuf_addf(&buf_payload, "exec[%d] ", exec_id);
-       if (exe)
+       if (exe) {
                strbuf_addstr(&buf_payload, exe);
-       sq_quote_argv_pretty(&buf_payload, argv);
+               strbuf_addch(&buf_payload, ' ');
+       }
+       sq_append_quote_argv_pretty(&buf_payload, argv);
        normal_io_write_fl(file, line, &buf_payload);
        strbuf_release(&buf_payload);
 }