use strbuf_addstr() for adding constant strings to a strbuf, part 2

Replace uses of strbuf_addf() for adding strings with more lightweight
strbuf_addstr() calls.  This makes the intent clearer and avoids
potential issues with printf format specifiers.

02962d3684 already converted six cases,
this patch covers eleven more.

A semantic patch for Coccinelle is included for easier checking for
new cases that might be introduced in the future.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe
2016-09-15 20:31:00 +02:00
committed by Junio C Hamano
parent 63f0a758a0
commit a22ae753cb
7 changed files with 18 additions and 12 deletions

View File

@ -206,7 +206,7 @@ static void output_commit_title(struct merge_options *o, struct commit *commit)
find_unique_abbrev(commit->object.oid.hash,
DEFAULT_ABBREV));
if (parse_commit(commit) != 0)
strbuf_addf(&o->obuf, _("(bad commit)\n"));
strbuf_addstr(&o->obuf, _("(bad commit)\n"));
else {
const char *title;
const char *msg = get_commit_buffer(commit, NULL);