trace2: cleanup whitespace in normal format

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>

Jeff Hostetler committed Aug 9, 2019 at 08:00 UTC e34430556c8cb7c99a561125df3c8f595c385e7e
1 file changed +13 -10
trace2/tr2_tgt_normal.c
+13 -10
@@ -87,7 +87,7 @@ static void fn_start_fl(const char *file, int line,
87 struct strbuf buf_payload = STRBUF_INIT;
88
89 strbuf_addstr(&buf_payload, "start ");
90 - sq_quote_argv_pretty(&buf_payload, argv);
90 + sq_append_quote_argv_pretty(&buf_payload, argv);
91 normal_io_write_fl(file, line, &buf_payload);
92 strbuf_release(&buf_payload);
93 }
@@ -186,8 +186,8 @@ static void fn_alias_fl(const char *file, int line, const char *alias,
186 {
187 struct strbuf buf_payload = STRBUF_INIT;
188
189 - strbuf_addf(&buf_payload, "alias %s ->", alias);
190 - sq_quote_argv_pretty(&buf_payload, argv);
189 + strbuf_addf(&buf_payload, "alias %s -> ", alias);
190 + sq_append_quote_argv_pretty(&buf_payload, argv);
191 normal_io_write_fl(file, line, &buf_payload);
192 strbuf_release(&buf_payload);
193 }
@@ -198,12 +198,12 @@ static void fn_child_start_fl(const char *file, int line,
198 {
199 struct strbuf buf_payload = STRBUF_INIT;
200
201 - strbuf_addf(&buf_payload, "child_start[%d] ", cmd->trace2_child_id);
201 + strbuf_addf(&buf_payload, "child_start[%d]", cmd->trace2_child_id);
202
203 if (cmd->dir) {
204 - strbuf_addstr(&buf_payload, " cd");
204 + strbuf_addstr(&buf_payload, " cd ");
205 sq_quote_buf_pretty(&buf_payload, cmd->dir);
206 - strbuf_addstr(&buf_payload, "; ");
206 + strbuf_addstr(&buf_payload, ";");
207 }
208
209 /*
@@ -211,9 +211,10 @@ static void fn_child_start_fl(const char *file, int line,
211 * See trace_add_env() in run-command.c as used by original trace.c
212 */
213
214 + strbuf_addch(&buf_payload, ' ');
215 if (cmd->git_cmd)
215 - strbuf_addstr(&buf_payload, "git");
216 - sq_quote_argv_pretty(&buf_payload, cmd->argv);
216 + strbuf_addstr(&buf_payload, "git ");
217 + sq_append_quote_argv_pretty(&buf_payload, cmd->argv);
218
219 normal_io_write_fl(file, line, &buf_payload);
220 strbuf_release(&buf_payload);
@@ -238,9 +239,11 @@ static void fn_exec_fl(const char *file, int line, uint64_t us_elapsed_absolute,
239 struct strbuf buf_payload = STRBUF_INIT;
240
241 strbuf_addf(&buf_payload, "exec[%d] ", exec_id);
241 - if (exe)
242 + if (exe) {
243 strbuf_addstr(&buf_payload, exe);
243 - sq_quote_argv_pretty(&buf_payload, argv);
244 + strbuf_addch(&buf_payload, ' ');
245 + }
246 + sq_append_quote_argv_pretty(&buf_payload, argv);
247 normal_io_write_fl(file, line, &buf_payload);
248 strbuf_release(&buf_payload);
249 }