MCPcopy Create free account
hub / github.com/git/git / parse_trailers

Function parse_trailers

trailer.c:1067–1102  ·  view source on GitHub ↗

* Parse trailers in "str", populating the trailer_block and "trailer_objects" * linked list structure. */

Source from the content-addressed store, hash-verified

1065 * linked list structure.
1066 */
1067struct 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
1104void free_trailers(struct list_head *trailers)
1105{

Callers 2

process_trailersFunction · 0.85

Calls 9

trailer_block_getFunction · 0.85
starts_withFunction · 0.85
find_separatorFunction · 0.85
parse_trailerFunction · 0.85
unfold_valueFunction · 0.85
add_trailer_itemFunction · 0.85
strbuf_detachFunction · 0.85
strbuf_addstrFunction · 0.85
strbuf_strip_suffixFunction · 0.85

Tested by

no test coverage detected