git/contrib/coccinelle/strbuf.cocci
René Scharfe f937d78553 use strbuf_add_unique_abbrev() for adding short hashes, part 2
Call strbuf_add_unique_abbrev() to add abbreviated hashes to strbufs
instead of taking detours through find_unique_abbrev() and its static
buffer.  This is shorter and a bit more efficient.

1eb47f167d already converted six cases,
this patch covers three 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>
2016-09-27 14:02:40 -07:00

18 lines
272 B
Plaintext

@@
expression E1, E2;
@@
- strbuf_addf(E1, E2);
+ strbuf_addstr(E1, E2);
@@
expression E1, E2;
@@
- strbuf_addf(E1, "%s", E2);
+ strbuf_addstr(E1, E2);
@@
expression E1, E2, E3;
@@
- strbuf_addstr(E1, find_unique_abbrev(E2, E3));
+ strbuf_add_unique_abbrev(E1, E2, E3);