path: root/contrib/coccinelle
diff options
authorRené Scharfe <>2016-09-27 19:11:58 (GMT)
committerJunio C Hamano <>2016-09-27 21:02:40 (GMT)
commitf937d78553ce22505543580ae7958d9f5ffeeb89 (patch)
treea6344bff6d36dda957aa9f0242ffa8ee47127a8b /contrib/coccinelle
parent92d52fab3af8b1d5231285ac13b364f008d1a886 (diff)
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. 1eb47f167d65d1d305b9c196a1bb40eb96117cb1 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 <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'contrib/coccinelle')
1 files changed, 6 insertions, 0 deletions
diff --git a/contrib/coccinelle/strbuf.cocci b/contrib/coccinelle/strbuf.cocci
index 4b7553f..1e24298 100644
--- a/contrib/coccinelle/strbuf.cocci
+++ b/contrib/coccinelle/strbuf.cocci
@@ -9,3 +9,9 @@ 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);