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

Function apply_patch

add-patch.c:1550–1584  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1548 "HUNKS SUMMARY - Hunks: %d, USE: %d, SKIP: %d\n");
1549
1550static void apply_patch(struct add_p_state *s, struct file_diff *file_diff)
1551{
1552 struct child_process cp = CHILD_PROCESS_INIT;
1553 size_t j;
1554
1555 /* Any hunk to be used? */
1556 for (j = 0; j < file_diff->hunk_nr; j++)
1557 if (file_diff->hunk[j].use == USE_HUNK)
1558 break;
1559
1560 if (j < file_diff->hunk_nr ||
1561 (!file_diff->hunk_nr && file_diff->head.use == USE_HUNK)) {
1562 /* At least one hunk selected: apply */
1563 strbuf_reset(&s->buf);
1564 reassemble_patch(s, file_diff, 0, &s->buf);
1565
1566 discard_index(s->index);
1567 if (s->mode->apply_for_checkout)
1568 apply_for_checkout(s, &s->buf,
1569 s->mode->is_reverse);
1570 else {
1571 setup_child_process(s, &cp, "apply", NULL);
1572 strvec_pushv(&cp.args, s->mode->apply_args);
1573 if (pipe_command(&cp, s->buf.buf, s->buf.len,
1574 NULL, 0, NULL, 0))
1575 error(_("'git apply' failed"));
1576 }
1577 if (read_index_from(s->index, s->index_file, s->r->gitdir) >= 0 &&
1578 s->index == s->r->index) {
1579 repo_refresh_and_write_index(s->r, REFRESH_QUIET, 0,
1580 1, NULL, NULL, NULL);
1581 }
1582 }
1583
1584}
1585
1586static size_t dec_mod(size_t a, size_t m)
1587{

Callers 2

patch_update_fileFunction · 0.70
run_add_p_commonFunction · 0.70

Calls 9

reassemble_patchFunction · 0.85
discard_indexFunction · 0.85
apply_for_checkoutFunction · 0.85
setup_child_processFunction · 0.85
strvec_pushvFunction · 0.85
pipe_commandFunction · 0.85
errorFunction · 0.85
read_index_fromFunction · 0.85

Tested by

no test coverage detected