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

Function find_commit_multiline_header

builtin/fast-export.c:627–650  ·  view source on GitHub ↗

* find_commit_multiline_header is similar to find_commit_header, * except that it handles multi-line headers, rather than simply * returning the first line of the header. * * The returned string has had the ' ' line continuation markers * removed, and points to allocated memory that must be free()d (not * to memory within 'msg'). * * If the header is found, then *end is set to point at the

Source from the content-addressed store, hash-verified

625 * msg that immediately follows the header value.
626 */
627static const char *find_commit_multiline_header(const char *msg,
628 const char *key,
629 const char **end)
630{
631 struct strbuf val = STRBUF_INIT;
632 const char *bol, *eol;
633 size_t len;
634
635 bol = find_commit_header(msg, key, &len);
636 if (!bol)
637 return NULL;
638 eol = bol + len;
639 strbuf_add(&val, bol, len);
640
641 while (eol[0] == '\n' && eol[1] == ' ') {
642 bol = eol + 2;
643 eol = strchrnul(bol, '\n');
644 strbuf_addch(&val, '\n');
645 strbuf_add(&val, bol, eol - bol);
646 }
647
648 *end = eol;
649 return strbuf_detach(&val, NULL);
650}
651
652static void print_signature(const char *signature, const char *object_hash)
653{

Callers 1

Calls 4

find_commit_headerFunction · 0.85
strbuf_addFunction · 0.85
strbuf_addchFunction · 0.85
strbuf_detachFunction · 0.85

Tested by

no test coverage detected