use strbuf_addstr() for adding strings to strbufs
authorRené Scharfe <l.s.r@web.de>
Sun, 1 Oct 2017 14:44:20 +0000 (16:44 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 2 Oct 2017 04:13:46 +0000 (13:13 +0900)
Use strbuf_addstr() instead of strbuf_addf() for adding strings. That's
simpler and makes the intent clearer.

Patch generated by Coccinelle and contrib/coccinelle/strbuf.cocci;
adjusted indentation in refs/packed-backend.c manually.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/branch.c
refs/packed-backend.c
sequencer.c
index 355f9ef5da164d4d3e88872984fced9e9a744a84..a2b7c554275e871b2d175353459bbfa0744327f2 100644 (file)
@@ -352,7 +352,7 @@ static char *build_format(struct ref_filter *filter, int maxwidth, const char *r
                        strbuf_addf(&obname, "%%(objectname:short=%d)", filter->abbrev);
 
                strbuf_addf(&local, "%%(align:%d,left)%%(refname:lstrip=2)%%(end)", maxwidth);
-               strbuf_addf(&local, "%s", branch_get_color(BRANCH_COLOR_RESET));
+               strbuf_addstr(&local, branch_get_color(BRANCH_COLOR_RESET));
                strbuf_addf(&local, " %s ", obname.buf);
 
                if (filter->verbose > 1)
index 3bc47ffd5ea4e82f2505a8649b162d18ebf11a21..2951514f251bcb9274932789a0535caefbf03c2d 100644 (file)
@@ -729,8 +729,8 @@ static int write_with_updates(struct packed_ref_store *refs,
        }
 
        if (ok != ITER_DONE) {
-               strbuf_addf(err, "unable to write packed-refs file: "
-                           "error iterating over old contents");
+               strbuf_addstr(err, "unable to write packed-refs file: "
+                             "error iterating over old contents");
                goto error;
        }
 
index 60636ce54b615e19a22dc2396211d56540b4e920..ba95cefc7d22d849163d28795d644995641606ef 100644 (file)
@@ -203,7 +203,7 @@ int sequencer_remove_state(struct replay_opts *opts)
                free(opts->xopts[i]);
        free(opts->xopts);
 
-       strbuf_addf(&dir, "%s", get_dir(opts));
+       strbuf_addstr(&dir, get_dir(opts));
        remove_dir_recursively(&dir, 0);
        strbuf_release(&dir);