X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=commit.c;h=67e11d7a4f211c1d2cf62635029f60597ff618de;hb=8e1618f9612a78ea09b2a926797c781fe06027c9;hp=97205bfb2ceaf77c2b90552327c9a4a1de83a39d;hpb=36b5b3c65948694d9a92de5a17f2b97c3cd84879;p=git.git diff --git a/commit.c b/commit.c index 97205bfb..67e11d7a 100644 --- a/commit.c +++ b/commit.c @@ -438,13 +438,13 @@ static int add_merge_info(enum cmit_fmt fmt, char *buf, const struct commit *com while (parent) { struct commit *p = parent->item; + const char *hex = abbrev + ? find_unique_abbrev(p->object.sha1, abbrev) + : sha1_to_hex(p->object.sha1); + char *dots = (abbrev && strlen(hex) != 40) ? "..." : ""; parent = parent->next; - offset += sprintf(buf + offset, - abbrev ? " %s..." : " %s", - abbrev - ? find_unique_abbrev(p->object.sha1, abbrev) - : sha1_to_hex(p->object.sha1)); + offset += sprintf(buf + offset, " %s%s", hex, dots); } buf[offset++] = '\n'; return offset;