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

Function am_setup

builtin/am.c:993–1111  ·  view source on GitHub ↗

* Setup a new am session for applying patches */

Source from the content-addressed store, hash-verified

991 * Setup a new am session for applying patches
992 */
993static void am_setup(struct am_state *state, enum patch_format patch_format,
994 const char **paths, int keep_cr)
995{
996 struct object_id curr_head;
997 const char *str;
998 struct strbuf sb = STRBUF_INIT;
999
1000 if (!patch_format)
1001 patch_format = detect_patch_format(paths);
1002
1003 if (!patch_format) {
1004 fprintf_ln(stderr, _("Patch format detection failed."));
1005 die(NULL);
1006 }
1007
1008 if (mkdir(state->dir, 0777) < 0 && errno != EEXIST)
1009 die_errno(_("failed to create directory '%s'"), state->dir);
1010 refs_delete_ref(get_main_ref_store(the_repository), NULL,
1011 "REBASE_HEAD", NULL, REF_NO_DEREF);
1012
1013 if (split_mail(state, patch_format, paths, keep_cr) < 0) {
1014 am_destroy(state);
1015 die(_("Failed to split patches."));
1016 }
1017
1018 if (state->rebasing)
1019 state->threeway = 1;
1020
1021 write_state_bool(state, "threeway", state->threeway);
1022 write_state_bool(state, "quiet", state->quiet);
1023 write_state_bool(state, "sign", state->signoff);
1024 write_state_bool(state, "utf8", state->utf8);
1025
1026 if (state->allow_rerere_autoupdate)
1027 write_state_bool(state, "rerere-autoupdate",
1028 state->allow_rerere_autoupdate == RERERE_AUTOUPDATE);
1029
1030 switch (state->keep) {
1031 case KEEP_FALSE:
1032 str = "f";
1033 break;
1034 case KEEP_TRUE:
1035 str = "t";
1036 break;
1037 case KEEP_NON_PATCH:
1038 str = "b";
1039 break;
1040 default:
1041 BUG("invalid value for state->keep");
1042 }
1043
1044 write_state_text(state, "keep", str);
1045 write_state_bool(state, "messageid", state->message_id);
1046
1047 switch (state->scissors) {
1048 case SCISSORS_UNSET:
1049 str = "";
1050 break;

Callers 1

cmd_amFunction · 0.85

Calls 15

detect_patch_formatFunction · 0.85
fprintf_lnFunction · 0.85
die_errnoFunction · 0.85
refs_delete_refFunction · 0.85
get_main_ref_storeFunction · 0.85
split_mailFunction · 0.85
am_destroyFunction · 0.85
write_state_boolFunction · 0.85
write_state_textFunction · 0.85
sq_quote_argvFunction · 0.85
repo_get_oidFunction · 0.85
oid_to_hexFunction · 0.85

Tested by

no test coverage detected