if (memcmp(bufptr, "tree ", 5))
return error("bogus commit object %s", sha1_to_hex(item->object.sha1));
if (get_sha1_hex(bufptr + 5, parent) < 0)
- return error("bad tree pointer in commit %s\n", sha1_to_hex(item->object.sha1));
+ return error("bad tree pointer in commit %s",
+ sha1_to_hex(item->object.sha1));
item->tree = lookup_tree(parent);
if (item->tree)
n_refs++;
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;