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

Function summarize_hunk

add-patch.c:1488–1509  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1486#define SUMMARY_HEADER_WIDTH 20
1487#define SUMMARY_LINE_WIDTH 80
1488static void summarize_hunk(struct add_p_state *s, struct hunk *hunk,
1489 struct strbuf *out)
1490{
1491 struct hunk_header *header = &hunk->header;
1492 struct strbuf *plain = &s->plain;
1493 size_t len = out->len, i;
1494
1495 strbuf_addf(out, " -%lu,%lu +%lu,%lu ",
1496 header->old_offset, header->old_count,
1497 header->new_offset, header->new_count);
1498 if (out->len - len < SUMMARY_HEADER_WIDTH)
1499 strbuf_addchars(out, ' ',
1500 SUMMARY_HEADER_WIDTH + len - out->len);
1501 for (i = hunk->start; i < hunk->end; i = find_next_line(plain, i))
1502 if (plain->buf[i] != ' ')
1503 break;
1504 if (i < hunk->end)
1505 strbuf_add(out, plain->buf + i, find_next_line(plain, i) - i);
1506 if (out->len - len > SUMMARY_LINE_WIDTH)
1507 strbuf_setlen(out, len + SUMMARY_LINE_WIDTH);
1508 strbuf_complete_line(out);
1509}
1510
1511#define DISPLAY_HUNKS_LINES 20
1512static size_t display_hunks(struct add_p_state *s,

Callers 1

display_hunksFunction · 0.85

Calls 6

strbuf_addfFunction · 0.85
strbuf_addcharsFunction · 0.85
find_next_lineFunction · 0.85
strbuf_addFunction · 0.85
strbuf_setlenFunction · 0.85
strbuf_complete_lineFunction · 0.85

Tested by

no test coverage detected