From: Junio C Hamano Date: Mon, 21 Jul 2014 18:17:45 +0000 (-0700) Subject: Merge branch 'cc/for-each-mergetag' X-Git-Tag: v2.1.0-rc0~25 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/dadb89d92ce9c81846c1b4c743a41b6e845b572c?hp=-c Merge branch 'cc/for-each-mergetag' * cc/for-each-mergetag: commit: add for_each_mergetag() --- dadb89d92ce9c81846c1b4c743a41b6e845b572c diff --combined commit.c index f43970dca1,94b1af9392..f1c9d0e2b9 --- a/commit.c +++ b/commit.c @@@ -447,7 -447,12 +447,7 @@@ struct commit_list *copy_commit_list(st struct commit_list *head = NULL; struct commit_list **pp = &head; while (list) { - struct commit_list *new; - new = xmalloc(sizeof(struct commit_list)); - new->item = list->item; - new->next = NULL; - *pp = new; - pp = &new->next; + pp = commit_list_append(list->item, pp); list = list->next; } return head; @@@ -609,7 -614,8 +609,7 @@@ static void record_author_date(struct a for (buf = buffer; buf; buf = line_end + 1) { line_end = strchrnul(buf, '\n'); - ident_line = skip_prefix(buf, "author "); - if (!ident_line) { + if (!skip_prefix(buf, "author ", &ident_line)) { if (!line_end[0] || line_end[1] == '\n') return; /* end of header */ continue; @@@ -1231,7 -1237,8 +1231,7 @@@ static void parse_gpg_output(struct sig for (i = 0; i < ARRAY_SIZE(sigcheck_gpg_status); i++) { const char *found, *next; - found = skip_prefix(buf, sigcheck_gpg_status[i].check + 1); - if (!found) { + if (!skip_prefix(buf, sigcheck_gpg_status[i].check + 1, &found)) { found = strstr(buf, sigcheck_gpg_status[i].check); if (!found) continue; @@@ -1265,7 -1272,6 +1265,7 @@@ void check_commit_signature(const struc &gpg_output, &gpg_status); if (status && !gpg_output.len) goto out; + sigc->payload = strbuf_detach(&payload, NULL); sigc->gpg_output = strbuf_detach(&gpg_output, NULL); sigc->gpg_status = strbuf_detach(&gpg_status, NULL); parse_gpg_output(sigc); @@@ -1310,6 -1316,19 +1310,19 @@@ struct commit_extra_header *read_commit return extra; } + void for_each_mergetag(each_mergetag_fn fn, struct commit *commit, void *data) + { + struct commit_extra_header *extra, *to_free; + + to_free = read_commit_extra_headers(commit, NULL); + for (extra = to_free; extra; extra = extra->next) { + if (strcmp(extra->key, "mergetag")) + continue; /* not a merge tag */ + fn(commit, extra, data); + } + free_commit_extra_headers(to_free); + } + static inline int standard_header_field(const char *field, size_t len) { return ((len == 4 && !memcmp(field, "tree ", 5)) || diff --combined log-tree.c index f87b7e891a,706ed4c250..0c53dc11ab --- a/log-tree.c +++ b/log-tree.c @@@ -365,7 -365,6 +365,7 @@@ static void show_sig_lines(struct rev_i eol = strchrnul(bol, '\n'); printf("%s%.*s%s%s", color, (int)(eol - bol), bol, reset, *eol ? "\n" : ""); + graph_show_oneline(opt->graph); bol = (*eol) ? (eol + 1) : eol; } } @@@ -414,10 -413,11 +414,11 @@@ static int is_common_merge(const struc && !commit->parents->next->next); } - static void show_one_mergetag(struct rev_info *opt, + static void show_one_mergetag(struct commit *commit, struct commit_extra_header *extra, - struct commit *commit) + void *data) { + struct rev_info *opt = (struct rev_info *)data; unsigned char sha1[20]; struct tag *tag; struct strbuf verify_message; @@@ -447,17 -447,16 +448,17 @@@ payload_size = parse_signature(extra->value, extra->len); status = -1; - if (extra->len > payload_size) - if (verify_signed_buffer(extra->value, payload_size, - extra->value + payload_size, - extra->len - payload_size, - &verify_message, NULL)) { - if (verify_message.len <= gpg_message_offset) - strbuf_addstr(&verify_message, "No signature\n"); - else - status = 0; - } + if (extra->len > payload_size) { + /* could have a good signature */ + if (!verify_signed_buffer(extra->value, payload_size, + extra->value + payload_size, + extra->len - payload_size, + &verify_message, NULL)) + status = 0; /* good */ + else if (verify_message.len <= gpg_message_offset) + strbuf_addstr(&verify_message, "No signature\n"); + /* otherwise we couldn't verify, which is shown as bad */ + } show_sig_lines(opt, status, verify_message.buf); strbuf_release(&verify_message); @@@ -465,15 -464,7 +466,7 @@@ static void show_mergetag(struct rev_info *opt, struct commit *commit) { - struct commit_extra_header *extra, *to_free; - - to_free = read_commit_extra_headers(commit, NULL); - for (extra = to_free; extra; extra = extra->next) { - if (strcmp(extra->key, "mergetag")) - continue; /* not a merge tag */ - show_one_mergetag(opt, extra, commit); - } - free_commit_extra_headers(to_free); + for_each_mergetag(show_one_mergetag, commit, opt); } void show_log(struct rev_info *opt)