MCPcopy Index your code
hub / github.com/git/git / read_commit_extra_header_lines

Function read_commit_extra_header_lines

commit.c:1511–1552  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1509}
1510
1511static struct commit_extra_header *read_commit_extra_header_lines(
1512 const char *buffer, size_t size,
1513 const char **exclude)
1514{
1515 struct commit_extra_header *extra = NULL, **tail = &extra, *it = NULL;
1516 const char *line, *next, *eof, *eob;
1517 struct strbuf buf = STRBUF_INIT;
1518
1519 for (line = buffer, eob = line + size;
1520 line < eob && *line != '\n';
1521 line = next) {
1522 next = memchr(line, '\n', eob - line);
1523 next = next ? next + 1 : eob;
1524 if (*line == ' ') {
1525 /* continuation */
1526 if (it)
1527 strbuf_add(&buf, line + 1, next - (line + 1));
1528 continue;
1529 }
1530 if (it)
1531 it->value = strbuf_detach(&buf, &it->len);
1532 strbuf_reset(&buf);
1533 it = NULL;
1534
1535 eof = memchr(line, ' ', next - line);
1536 if (!eof)
1537 eof = next;
1538 else if (standard_header_field(line, eof - line) ||
1539 excluded_header_field(line, eof - line, exclude))
1540 continue;
1541
1542 CALLOC_ARRAY(it, 1);
1543 it->key = xmemdupz(line, eof-line);
1544 *tail = it;
1545 tail = &it->next;
1546 if (eof + 1 < next)
1547 strbuf_add(&buf, eof + 1, next - (eof + 1));
1548 }
1549 if (it)
1550 it->value = strbuf_detach(&buf, &it->len);
1551 return extra;
1552}
1553
1554void free_commit_extra_headers(struct commit_extra_header *extra)
1555{

Callers 1

Calls 5

strbuf_addFunction · 0.85
strbuf_detachFunction · 0.85
standard_header_fieldFunction · 0.85
excluded_header_fieldFunction · 0.85
xmemdupzFunction · 0.85

Tested by

no test coverage detected