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

Function reassemble_patch

add-patch.c:1015–1049  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1013}
1014
1015static void reassemble_patch(struct add_p_state *s,
1016 struct file_diff *file_diff, int use_all,
1017 struct strbuf *out)
1018{
1019 struct hunk *hunk;
1020 size_t save_len = s->plain.len, i;
1021 ssize_t delta = 0;
1022
1023 render_diff_header(s, file_diff, 0, out);
1024
1025 for (i = file_diff->mode_change; i < file_diff->hunk_nr; i++) {
1026 struct hunk merged = { 0 };
1027
1028 hunk = file_diff->hunk + i;
1029 if (!use_all && hunk->use != USE_HUNK)
1030 delta += hunk->header.old_count
1031 - hunk->header.new_count;
1032 else {
1033 /* merge overlapping hunks into a temporary hunk */
1034 if (merge_hunks(s, file_diff, &i, use_all, &merged))
1035 hunk = &merged;
1036
1037 render_hunk(s, hunk, delta, 0, out);
1038
1039 /*
1040 * In case `merge_hunks()` used `plain` as a scratch
1041 * pad (this happens when an edited hunk had to be
1042 * coalesced with another hunk).
1043 */
1044 strbuf_setlen(&s->plain, save_len);
1045
1046 delta += hunk->delta;
1047 }
1048 }
1049}
1050
1051static int split_hunk(struct add_p_state *s, struct file_diff *file_diff,
1052 size_t hunk_index)

Callers 2

run_apply_checkFunction · 0.85
apply_patchFunction · 0.85

Calls 4

render_diff_headerFunction · 0.85
merge_hunksFunction · 0.85
render_hunkFunction · 0.85
strbuf_setlenFunction · 0.85

Tested by

no test coverage detected