Merge branch 'jt/trailer-with-cruft'
authorJunio C Hamano <gitster@pobox.com>
Mon, 31 Oct 2016 20:15:22 +0000 (13:15 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 31 Oct 2016 20:15:22 +0000 (13:15 -0700)
Update "interpret-trailers" machinery and teaches it that people in
real world write all sorts of crufts in the "trailer" that was
originally designed to have the neat-o "Mail-Header: like thing"
and nothing else.

* jt/trailer-with-cruft:
trailer: support values folded to multiple lines
trailer: forbid leading whitespace in trailers
trailer: allow non-trailers in trailer block
trailer: clarify failure modes in parse_trailer
trailer: make args have their own struct
trailer: streamline trailer item create and add
trailer: use list.h for doubly-linked list
trailer: improve const correctness

1  2 
trailer.c
diff --cc trailer.c
index aecaf9232a92fcab4996037fc779e0165750fb36,d19a92cd1c4448bf4c3f34f387554ba8719520a7..f0ecde2d2f8b35c565ab176c76882a5fee8d8fb2
+++ b/trailer.c
@@@ -425,23 -413,25 +413,22 @@@ static int set_if_missing(struct conf_i
        return 0;
  }
  
- static void duplicate_conf(struct conf_info *dst, struct conf_info *src)
+ static void duplicate_conf(struct conf_info *dst, const struct conf_info *src)
  {
        *dst = *src;
 -      if (src->name)
 -              dst->name = xstrdup(src->name);
 -      if (src->key)
 -              dst->key = xstrdup(src->key);
 -      if (src->command)
 -              dst->command = xstrdup(src->command);
 +      dst->name = xstrdup_or_null(src->name);
 +      dst->key = xstrdup_or_null(src->key);
 +      dst->command = xstrdup_or_null(src->command);
  }
  
- static struct trailer_item *get_conf_item(const char *name)
+ static struct arg_item *get_conf_item(const char *name)
  {
-       struct trailer_item *item;
-       struct trailer_item *previous;
+       struct list_head *pos;
+       struct arg_item *item;
  
        /* Look up item with same name */
-       for (previous = NULL, item = first_conf_item;
-            item;
-            previous = item, item = item->next) {
+       list_for_each(pos, &conf_head) {
+               item = list_entry(pos, struct arg_item, list);
                if (!strcasecmp(item->conf.name, name))
                        return item;
        }