| 1548 | "HUNKS SUMMARY - Hunks: %d, USE: %d, SKIP: %d\n"); |
| 1549 | |
| 1550 | static 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 | |
| 1586 | static size_t dec_mod(size_t a, size_t m) |
| 1587 | { |
no test coverage detected