use strbuf_addstr() instead of strbuf_addf() with "%s", part 2
Replace uses of strbuf_addf() for adding strings with more lightweight strbuf_addstr() calls. This is shorter and makes the intent clearer. bc57b9c0cc5a123365a922fa1831177e3fd607ed already converted three cases, this patch covers two 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>
René Scharfe committed
Sep 27, 2016 at 21:08 UTC
92d52fab3af8b1d5231285ac13b364f008d1a886
3 files changed
+8
-2
builtin/submodule--helper.c
+1
-1
@@ -637,7 +637,7 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
637
if (suc->recursive_prefix)
638
strbuf_addf(&sb, "%s/%s", suc->recursive_prefix, ce->name);
639
else
640
- strbuf_addf(&sb, "%s", ce->name);
640
+ strbuf_addstr(&sb, ce->name);
641
strbuf_addf(out, _("Skipping unmerged submodule %s"), sb.buf);
642
strbuf_addch(out, '\n');
643
goto cleanup;
contrib/coccinelle/strbuf.cocci
+6
@@ -3,3 +3,9 @@ expression E1, E2;
3
@@
4
- strbuf_addf(E1, E2);
5
+ strbuf_addstr(E1, E2);
6
+
7
+@@
8
+expression E1, E2;
9
+@@
10
+- strbuf_addf(E1, "%s", E2);
11
++ strbuf_addstr(E1, E2);
submodule.c
+1
-1
@@ -374,7 +374,7 @@ void show_submodule_summary(FILE *f, const char *path,
374
find_unique_abbrev(one, DEFAULT_ABBREV));
375
if (!fast_backward && !fast_forward)
376
strbuf_addch(&sb, '.');
377
- strbuf_addf(&sb, "%s", find_unique_abbrev(two, DEFAULT_ABBREV));
377
+ strbuf_addstr(&sb, find_unique_abbrev(two, DEFAULT_ABBREV));
378
if (message)
379
strbuf_addf(&sb, " %s%s\n", message, reset);
380
else