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

Function parse_trailer

trailer.c:658–691  ·  view source on GitHub ↗

* Obtain the token, value, and conf from the given trailer. * * separator_pos must not be 0, since the token cannot be an empty string. * * If separator_pos is -1, interpret the whole trailer as a token. */

Source from the content-addressed store, hash-verified

656 * If separator_pos is -1, interpret the whole trailer as a token.
657 */
658static void parse_trailer(struct strbuf *tok, struct strbuf *val,
659 const struct conf_info **conf, const char *trailer,
660 ssize_t separator_pos)
661{
662 struct arg_item *item;
663 size_t tok_len;
664 struct list_head *pos;
665
666 if (separator_pos != -1) {
667 strbuf_add(tok, trailer, separator_pos);
668 strbuf_trim(tok);
669 strbuf_addstr(val, trailer + separator_pos + 1);
670 strbuf_trim(val);
671 } else {
672 strbuf_addstr(tok, trailer);
673 strbuf_trim(tok);
674 }
675
676 /* Lookup if the token matches something in the config */
677 tok_len = token_len_without_separator(tok->buf, tok->len);
678 if (conf)
679 *conf = &default_conf_info;
680 list_for_each(pos, &conf_head) {
681 item = list_entry(pos, struct arg_item, list);
682 if (token_matches_item(tok->buf, item, tok_len)) {
683 char *tok_buf = strbuf_detach(tok, NULL);
684 if (conf)
685 *conf = &item->conf;
686 strbuf_addstr(tok, token_from_item(item, tok_buf));
687 free(tok_buf);
688 break;
689 }
690 }
691}
692
693static struct trailer_item *add_trailer_item(struct list_head *head, char *tok,
694 char *val)

Callers 3

parse_trailersFunction · 0.85
trailer_iterator_advanceFunction · 0.85

Calls 7

strbuf_addFunction · 0.85
strbuf_trimFunction · 0.85
strbuf_addstrFunction · 0.85
token_matches_itemFunction · 0.85
strbuf_detachFunction · 0.85
token_from_itemFunction · 0.85

Tested by

no test coverage detected