* Interactively prompt the user on whether the current patch should be * applied. * * Returns 0 if the user chooses to apply the patch, 1 if the user chooses to * skip it. */
| 1755 | * skip it. |
| 1756 | */ |
| 1757 | static int do_interactive(struct am_state *state) |
| 1758 | { |
| 1759 | assert(state->msg); |
| 1760 | |
| 1761 | for (;;) { |
| 1762 | char reply[64]; |
| 1763 | |
| 1764 | puts(_("Commit Body is:")); |
| 1765 | puts("--------------------------"); |
| 1766 | printf("%s", state->msg); |
| 1767 | puts("--------------------------"); |
| 1768 | |
| 1769 | /* |
| 1770 | * TRANSLATORS: Make sure to include [y], [n], [e], [v] and [a] |
| 1771 | * in your translation. The program will only accept English |
| 1772 | * input at this point. |
| 1773 | */ |
| 1774 | printf(_("Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all: ")); |
| 1775 | if (!fgets(reply, sizeof(reply), stdin)) |
| 1776 | die("unable to read from stdin; aborting"); |
| 1777 | |
| 1778 | if (*reply == 'y' || *reply == 'Y') { |
| 1779 | return 0; |
| 1780 | } else if (*reply == 'a' || *reply == 'A') { |
| 1781 | state->interactive = 0; |
| 1782 | return 0; |
| 1783 | } else if (*reply == 'n' || *reply == 'N') { |
| 1784 | return 1; |
| 1785 | } else if (*reply == 'e' || *reply == 'E') { |
| 1786 | struct strbuf msg = STRBUF_INIT; |
| 1787 | |
| 1788 | if (!launch_editor(am_path(state, "final-commit"), &msg, NULL)) { |
| 1789 | free(state->msg); |
| 1790 | state->msg = strbuf_detach(&msg, &state->msg_len); |
| 1791 | } |
| 1792 | strbuf_release(&msg); |
| 1793 | } else if (*reply == 'v' || *reply == 'V') { |
| 1794 | const char *pager = git_pager(the_repository, 1); |
| 1795 | struct child_process cp = CHILD_PROCESS_INIT; |
| 1796 | |
| 1797 | if (!pager) |
| 1798 | pager = "cat"; |
| 1799 | prepare_pager_args(&cp, pager); |
| 1800 | strvec_push(&cp.args, am_path(state, "patch")); |
| 1801 | run_command(&cp); |
| 1802 | } |
| 1803 | } |
| 1804 | } |
| 1805 | |
| 1806 | /** |
| 1807 | * Applies all queued mail. |
no test coverage detected