* Parse trailers in "str", populating the trailer_block and "trailer_objects" * linked list structure. */
| 1065 | * linked list structure. |
| 1066 | */ |
| 1067 | struct trailer_block *parse_trailers(const struct process_trailer_options *opts, |
| 1068 | const char *str, |
| 1069 | struct list_head *trailer_objects) |
| 1070 | { |
| 1071 | struct trailer_block *trailer_block; |
| 1072 | struct strbuf tok = STRBUF_INIT; |
| 1073 | struct strbuf val = STRBUF_INIT; |
| 1074 | size_t i; |
| 1075 | |
| 1076 | trailer_block = trailer_block_get(opts, str); |
| 1077 | |
| 1078 | for (i = 0; i < trailer_block->trailer_nr; i++) { |
| 1079 | int separator_pos; |
| 1080 | char *trailer = trailer_block->trailers[i]; |
| 1081 | if (starts_with(trailer, comment_line_str)) |
| 1082 | continue; |
| 1083 | separator_pos = find_separator(trailer, separators); |
| 1084 | if (separator_pos >= 1) { |
| 1085 | parse_trailer(&tok, &val, NULL, trailer, |
| 1086 | separator_pos); |
| 1087 | if (opts->unfold) |
| 1088 | unfold_value(&val); |
| 1089 | add_trailer_item(trailer_objects, |
| 1090 | strbuf_detach(&tok, NULL), |
| 1091 | strbuf_detach(&val, NULL)); |
| 1092 | } else if (!opts->only_trailers) { |
| 1093 | strbuf_addstr(&val, trailer); |
| 1094 | strbuf_strip_suffix(&val, "\n"); |
| 1095 | add_trailer_item(trailer_objects, |
| 1096 | NULL, |
| 1097 | strbuf_detach(&val, NULL)); |
| 1098 | } |
| 1099 | } |
| 1100 | |
| 1101 | return trailer_block; |
| 1102 | } |
| 1103 | |
| 1104 | void free_trailers(struct list_head *trailers) |
| 1105 | { |
no test coverage detected