Skip to content

Commit e344305

Browse files
jeffhostetlergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c2b890a commit e344305

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

trace2/tr2_tgt_normal.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static void fn_start_fl(const char *file, int line,
8787
struct strbuf buf_payload = STRBUF_INIT;
8888

8989
strbuf_addstr(&buf_payload, "start ");
90-
sq_quote_argv_pretty(&buf_payload, argv);
90+
sq_append_quote_argv_pretty(&buf_payload, argv);
9191
normal_io_write_fl(file, line, &buf_payload);
9292
strbuf_release(&buf_payload);
9393
}
@@ -186,8 +186,8 @@ static void fn_alias_fl(const char *file, int line, const char *alias,
186186
{
187187
struct strbuf buf_payload = STRBUF_INIT;
188188

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);
191191
normal_io_write_fl(file, line, &buf_payload);
192192
strbuf_release(&buf_payload);
193193
}
@@ -198,22 +198,23 @@ static void fn_child_start_fl(const char *file, int line,
198198
{
199199
struct strbuf buf_payload = STRBUF_INIT;
200200

201-
strbuf_addf(&buf_payload, "child_start[%d] ", cmd->trace2_child_id);
201+
strbuf_addf(&buf_payload, "child_start[%d]", cmd->trace2_child_id);
202202

203203
if (cmd->dir) {
204-
strbuf_addstr(&buf_payload, " cd");
204+
strbuf_addstr(&buf_payload, " cd ");
205205
sq_quote_buf_pretty(&buf_payload, cmd->dir);
206-
strbuf_addstr(&buf_payload, "; ");
206+
strbuf_addstr(&buf_payload, ";");
207207
}
208208

209209
/*
210210
* TODO if (cmd->env) { Consider dumping changes to environment. }
211211
* See trace_add_env() in run-command.c as used by original trace.c
212212
*/
213213

214+
strbuf_addch(&buf_payload, ' ');
214215
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);
217218

218219
normal_io_write_fl(file, line, &buf_payload);
219220
strbuf_release(&buf_payload);
@@ -238,9 +239,11 @@ static void fn_exec_fl(const char *file, int line, uint64_t us_elapsed_absolute,
238239
struct strbuf buf_payload = STRBUF_INIT;
239240

240241
strbuf_addf(&buf_payload, "exec[%d] ", exec_id);
241-
if (exe)
242+
if (exe) {
242243
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);
244247
normal_io_write_fl(file, line, &buf_payload);
245248
strbuf_release(&buf_payload);
246249
}

0 commit comments

Comments
 (0)