# [PATCH] run-command: use strbuf_addstr() for adding a string to a strbuf

3 messages from 2018-03-25 to 2018-03-25. Participants: René Scharfe, Junio C Hamano, Duy Nguyen.
Thread: https://gitlist.dev/t/48139

## René Scharfe, 2018-03-25 10:57

Subject: [PATCH] run-command: use strbuf_addstr() for adding a string to a strbuf
Message-ID: <19c993cf-7220-42e1-6a76-d257d97d6f55@web.de>
URL: https://gitlist.dev/e/19c993cf-7220-42e1-6a76-d257d97d6f55%40web.de

```
Patch generated with Coccinelle and contrib/coccinelle/strbuf.cocci.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
That line was added by e73dd78699 (run-command.c: introduce
trace_run_command()).

 run-command.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/run-command.c b/run-command.c
index a483d5904a..84899e423f 100644
--- a/run-command.c
+++ b/run-command.c
@@ -621,7 +621,7 @@ static void trace_run_command(const struct child_process *cp)
 	if (!trace_want(&trace_default_key))
 		return;
 
-	strbuf_addf(&buf, "trace: run_command:");
+	strbuf_addstr(&buf, "trace: run_command:");
 	if (cp->dir) {
 		strbuf_addstr(&buf, " cd ");
 		sq_quote_buf_pretty(&buf, cp->dir);
-- 
2.16.3

```

## Junio C Hamano, 2018-03-25 16:49

Subject: Re: [PATCH] run-command: use strbuf_addstr() for adding a string to a strbuf
Message-ID: <xmqqbmfcf6cu.fsf@gitster-ct.c.googlers.com>
URL: https://gitlist.dev/e/xmqqbmfcf6cu.fsf%40gitster-ct.c.googlers.com
In-Reply-To: <19c993cf-7220-42e1-6a76-d257d97d6f55@web.de>

```
René Scharfe <l.s.r@web.de> writes:

> Patch generated with Coccinelle and contrib/coccinelle/strbuf.cocci.
>
> Signed-off-by: Rene Scharfe <l.s.r@web.de>
> ---
> That line was added by e73dd78699 (run-command.c: introduce
> trace_run_command()).

Thanks.

>
>  run-command.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/run-command.c b/run-command.c
> index a483d5904a..84899e423f 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -621,7 +621,7 @@ static void trace_run_command(const struct child_process *cp)
>  	if (!trace_want(&trace_default_key))
>  		return;
>  
> -	strbuf_addf(&buf, "trace: run_command:");
> +	strbuf_addstr(&buf, "trace: run_command:");
>  	if (cp->dir) {
>  		strbuf_addstr(&buf, " cd ");
>  		sq_quote_buf_pretty(&buf, cp->dir);

```

## Duy Nguyen, 2018-03-25 16:49

Subject: Re: [PATCH] run-command: use strbuf_addstr() for adding a string to a strbuf
Message-ID: <CACsJy8C+JDqfg2a3Ju-rb8n+ovUsoXsn0P7vqJZ71PQ38Fs8gg@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8C%2BJDqfg2a3Ju-rb8n%2BovUsoXsn0P7vqJZ71PQ38Fs8gg%40mail.gmail.com
In-Reply-To: <19c993cf-7220-42e1-6a76-d257d97d6f55@web.de>

```
On Sun, Mar 25, 2018 at 12:57 PM, René Scharfe <l.s.r@web.de> wrote:
> Patch generated with Coccinelle and contrib/coccinelle/strbuf.cocci.
>
> Signed-off-by: Rene Scharfe <l.s.r@web.de>
> ---
> That line was added by e73dd78699 (run-command.c: introduce
> trace_run_command()).
>
>  run-command.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/run-command.c b/run-command.c
> index a483d5904a..84899e423f 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -621,7 +621,7 @@ static void trace_run_command(const struct child_process *cp)
>         if (!trace_want(&trace_default_key))
>                 return;
>
> -       strbuf_addf(&buf, "trace: run_command:");
> +       strbuf_addstr(&buf, "trace: run_command:");

Obviously correct. Ack.

>         if (cp->dir) {
>                 strbuf_addstr(&buf, " cd ");
>                 sq_quote_buf_pretty(&buf, cp->dir);
> --
> 2.16.3



-- 
Duy

```
