MCPcopy Create free account
hub / github.com/git/git / show_patch

Function show_patch

builtin/am.c:2224–2258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2222}
2223
2224static 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

Callers 1

cmd_amFunction · 0.85

Calls 11

is_null_oidFunction · 0.85
strvec_pushlFunction · 0.85
oid_to_hexFunction · 0.85
run_commandFunction · 0.85
am_pathFunction · 0.85
msgnumFunction · 0.85
strbuf_read_fileFunction · 0.85
die_errnoFunction · 0.85
setup_pagerFunction · 0.85
write_in_fullFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected