| 2222 | } |
| 2223 | |
| 2224 | static int show_patch(struct am_state *state, enum resume_type resume_mode) |
| 2225 | { |
| 2226 | struct strbuf sb = STRBUF_INIT; |
| 2227 | const char *patch_path; |
| 2228 | int len; |
| 2229 | |
| 2230 | if (!is_null_oid(&state->orig_commit)) { |
| 2231 | struct child_process cmd = CHILD_PROCESS_INIT; |
| 2232 | |
| 2233 | strvec_pushl(&cmd.args, "show", oid_to_hex(&state->orig_commit), |
| 2234 | "--", NULL); |
| 2235 | cmd.git_cmd = 1; |
| 2236 | return run_command(&cmd); |
| 2237 | } |
| 2238 | |
| 2239 | switch (resume_mode) { |
| 2240 | case RESUME_SHOW_PATCH_RAW: |
| 2241 | patch_path = am_path(state, msgnum(state)); |
| 2242 | break; |
| 2243 | case RESUME_SHOW_PATCH_DIFF: |
| 2244 | patch_path = am_path(state, "patch"); |
| 2245 | break; |
| 2246 | default: |
| 2247 | BUG("invalid mode for --show-current-patch"); |
| 2248 | } |
| 2249 | |
| 2250 | len = strbuf_read_file(&sb, patch_path, 0); |
| 2251 | if (len < 0) |
| 2252 | die_errno(_("failed to read '%s'"), patch_path); |
| 2253 | |
| 2254 | setup_pager(the_repository); |
| 2255 | write_in_full(1, sb.buf, sb.len); |
| 2256 | strbuf_release(&sb); |
| 2257 | return 0; |
| 2258 | } |
| 2259 | |
| 2260 | /** |
| 2261 | * parse_options() callback that validates and sets opt->value to the |
no test coverage detected