X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=log-tree.c;h=0cf21bc05180b577a5f14dc57031c260e7c44334;hb=7051c3b1294a110a862a7b48e983490fba32389f;hp=dad551323082461c9fa1e5b9ad56a30d5cfc6343;hpb=402fa75eed29c104ae5392ce88560f6bffc64ce7;p=git.git diff --git a/log-tree.c b/log-tree.c index dad551323..0cf21bc05 100644 --- a/log-tree.c +++ b/log-tree.c @@ -4,6 +4,8 @@ #include "log-tree.h" #include "reflog-walk.h" +struct decoration name_decoration = { "object names" }; + static void show_parents(struct commit *commit, int abbrev) { struct commit_list *p; @@ -13,6 +15,23 @@ static void show_parents(struct commit *commit, int abbrev) } } +static void show_decorations(struct commit *commit) +{ + const char *prefix; + struct name_decoration *decoration; + + decoration = lookup_decoration(&name_decoration, &commit->object); + if (!decoration) + return; + prefix = " ("; + while (decoration) { + printf("%s%s", prefix, decoration->name); + prefix = ", "; + decoration = decoration->next; + } + putchar(')'); +} + /* * Search for "^[-A-Za-z]+: [^@]+@" pattern. It usually matches * Signed-off-by: and Acked-by: lines. @@ -60,16 +79,25 @@ static int detect_any_signoff(char *letter, int size) return seen_head && seen_name; } -static int append_signoff(char *buf, int buf_sz, int at, const char *signoff) +static unsigned long append_signoff(char **buf_p, unsigned long *buf_sz_p, + unsigned long at, const char *signoff) { static const char signed_off_by[] = "Signed-off-by: "; - int signoff_len = strlen(signoff); + size_t signoff_len = strlen(signoff); int has_signoff = 0; - char *cp = buf; - - /* Do we have enough space to add it? */ - if (buf_sz - at <= strlen(signed_off_by) + signoff_len + 3) - return at; + char *cp; + char *buf; + unsigned long buf_sz; + + buf = *buf_p; + buf_sz = *buf_sz_p; + if (buf_sz <= at + strlen(signed_off_by) + signoff_len + 3) { + buf_sz += strlen(signed_off_by) + signoff_len + 3; + buf = xrealloc(buf, buf_sz); + *buf_p = buf; + *buf_sz_p = buf_sz; + } + cp = buf; /* First see if we already have the sign-off by the signer */ while ((cp = strstr(cp, signed_off_by))) { @@ -114,7 +142,8 @@ static unsigned int digits_in_number(unsigned int number) void show_log(struct rev_info *opt, const char *sep) { - static char this_header[16384]; + char *msgbuf = NULL; + unsigned long msgbuf_len = 0; struct log_info *log = opt->loginfo; struct commit *commit = log->commit, *parent = log->parent; int abbrev = opt->diffopt.abbrev; @@ -136,6 +165,7 @@ void show_log(struct rev_info *opt, const char *sep) fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit), stdout); if (opt->parents) show_parents(commit, abbrev_commit); + show_decorations(commit); putchar(opt->diffopt.line_termination); return; } @@ -224,10 +254,10 @@ void show_log(struct rev_info *opt, const char *sep) stdout); if (opt->commit_format != CMIT_FMT_ONELINE) fputs("commit ", stdout); - if (opt->left_right) { - if (commit->object.flags & BOUNDARY) - putchar('-'); - else if (commit->object.flags & SYMMETRIC_LEFT) + if (commit->object.flags & BOUNDARY) + putchar('-'); + else if (opt->left_right) { + if (commit->object.flags & SYMMETRIC_LEFT) putchar('<'); else putchar('>'); @@ -240,13 +270,14 @@ void show_log(struct rev_info *opt, const char *sep) printf(" (from %s)", diff_unique_abbrev(parent->object.sha1, abbrev_commit)); + show_decorations(commit); printf("%s", diff_get_color(opt->diffopt.color_diff, DIFF_RESET)); putchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\n'); if (opt->reflog_info) { show_reflog_message(opt->reflog_info, opt->commit_format == CMIT_FMT_ONELINE, - opt->relative_date); + opt->date_mode); if (opt->commit_format == CMIT_FMT_ONELINE) { printf("%s", sep); return; @@ -257,14 +288,15 @@ void show_log(struct rev_info *opt, const char *sep) /* * And then the pretty-printed message itself */ - len = pretty_print_commit(opt->commit_format, commit, ~0u, this_header, - sizeof(this_header), abbrev, subject, - extra_headers, opt->relative_date); + len = pretty_print_commit(opt->commit_format, commit, ~0u, + &msgbuf, &msgbuf_len, abbrev, subject, + extra_headers, opt->date_mode); if (opt->add_signoff) - len = append_signoff(this_header, sizeof(this_header), len, + len = append_signoff(&msgbuf, &msgbuf_len, len, opt->add_signoff); - printf("%s%s%s", this_header, extra, sep); + printf("%s%s%s", msgbuf, extra, sep); + free(msgbuf); } int log_tree_diff_flush(struct rev_info *opt)