- return commit;
-
- offset = sprintf(this_header, "%s%s (from %s)\n", header_prefix, commit, parent);
- offset += pretty_print_commit(commit_format, msg, len, this_header + offset, sizeof(this_header) - offset);
+ return sha1_to_hex(commit_sha1);
+
+ len = strlen(msg);
+
+ offset = sprintf(this_header, "%s%s ",
+ header_prefix,
+ diff_unique_abbrev(commit_sha1, abbrev));
+ if (commit_sha1 != parent_sha1)
+ offset += sprintf(this_header + offset, "(from %s)\n",
+ parent_sha1
+ ? diff_unique_abbrev(parent_sha1, abbrev)
+ : "root");
+ else
+ offset += sprintf(this_header + offset, "(from parents)\n");
+ offset += pretty_print_commit(commit_format, commit, len,
+ this_header + offset,
+ sizeof(this_header) - offset, abbrev);
+ if (always_show_header) {
+ puts(this_header);
+ return NULL;
+ }