From a94bb683970a111b467a36590ca36e52754ad504 Mon Sep 17 00:00:00 2001 From: René Scharfe Date: Sat, 8 Oct 2016 17:38:47 +0200 Subject: use strbuf_add_unique_abbrev() for adding short hashes, part 3 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 in most cases and a bit more efficient. The changes here are not easily handled by a semantic patch because they involve removing temporary variables and deconstructing format strings for strbuf_addf(). Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- pretty.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'pretty.c') diff --git a/pretty.c b/pretty.c index 9609afb510..19089b35a9 100644 --- a/pretty.c +++ b/pretty.c @@ -544,15 +544,13 @@ static void add_merge_info(const struct pretty_print_context *pp, strbuf_addstr(sb, "Merge:"); while (parent) { - struct commit *p = parent->item; - const char *hex = NULL; + struct object_id *oidp = &parent->item->object.oid; + strbuf_addch(sb, ' '); if (pp->abbrev) - hex = find_unique_abbrev(p->object.oid.hash, pp->abbrev); - if (!hex) - hex = oid_to_hex(&p->object.oid); + strbuf_add_unique_abbrev(sb, oidp->hash, pp->abbrev); + else + strbuf_addstr(sb, oid_to_hex(oidp)); parent = parent->next; - - strbuf_addf(sb, " %s", hex); } strbuf_addch(sb, '\n'); } -- cgit v1.2.3