X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=commit.c;h=a6d543eee7831cd6a479d4cf8b2ba81a1438b298;hb=151602df00b8e5c5b4a8193f59a94b85f9b5aebc;hp=5b6e082c85f203cf27ac5b50f2d06a18b36fdc70;hpb=0f2ca9d5c99436d048bfe0a7161b4365a731938f;p=git.git diff --git a/commit.c b/commit.c index 5b6e082c8..a6d543eee 100644 --- a/commit.c +++ b/commit.c @@ -548,10 +548,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); - const char *dots = (abbrev && strlen(hex) != 40) ? "..." : ""; + const char *hex = NULL; + const char *dots; + if (abbrev) + hex = find_unique_abbrev(p->object.sha1, abbrev); + if (!hex) + hex = sha1_to_hex(p->object.sha1); + dots = (abbrev && strlen(hex) != 40) ? "..." : ""; parent = parent->next; offset += sprintf(buf + offset, " %s%s", hex, dots);