Merge branch 'cc/for-each-mergetag'
authorJunio C Hamano <gitster@pobox.com>
Mon, 21 Jul 2014 18:17:45 +0000 (11:17 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 Jul 2014 18:17:45 +0000 (11:17 -0700)
* cc/for-each-mergetag:
commit: add for_each_mergetag()

1  2 
commit.c
log-tree.c
diff --combined commit.c
index f43970dca1e11baf3b7690df81e13866f536f8db,94b1af9392bcfee0e6a6127e4da530531671b711..f1c9d0e2b99bd6f21ce0a0debae646eb677fccf5
+++ 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 f87b7e891adc5dfb429bc0ae35227e19f335b90f,706ed4c250814bba867986fadbf378c10c99da33..0c53dc11abf5aa10c83b35f07452f3c00a2998d4
@@@ -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;
  
        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);
  
  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)