-static const char *get_header(struct rev_info *opt,
- const unsigned char *commit_sha1,
- const unsigned char *parent_sha1,
- const struct commit *commit)
-{
- static char this_header[16384];
- int offset;
- unsigned long len;
- int abbrev = opt->diffopt.abbrev;
- const char *msg = commit->buffer;
-
- if (opt->use_precomputed_header)
- return opt->use_precomputed_header;
-
- if (!opt->verbose_header)
- return sha1_to_hex(commit_sha1);
-
- len = strlen(msg);
-
- offset = sprintf(this_header, "%s%s ",
- opt->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(opt->commit_format, commit, len,
- this_header + offset,
- sizeof(this_header) - offset, abbrev);
- return this_header;
-}
-
-static const char *generate_header(struct rev_info *opt,
- const unsigned char *commit_sha1,
- const unsigned char *parent_sha1,
- const struct commit *commit)
-{
- const char *header = get_header(opt, commit_sha1, parent_sha1, commit);
-
- if (opt->always_show_header) {
- puts(header);
- header = NULL;
- }
- return header;
-}
-