* 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
| 625 | * msg that immediately follows the header value. |
| 626 | */ |
| 627 | static 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 | |
| 652 | static void print_signature(const char *signature, const char *object_hash) |
| 653 | { |
no test coverage detected