106
int keep; /* enum keep_type */
107
int message_id;
108
int scissors; /* enum scissors_type */
109
+ struct argv_array git_apply_opts;
110
const char *resolvemsg;
111
int rebasing;
112
};
129
git_config_get_bool("am.messageid", &state->message_id);
130
131
state->scissors = SCISSORS_UNSET;
132
+
133
+ argv_array_init(&state->git_apply_opts);
134
}
135
136
/**
143
free(state->author_email);
144
free(state->author_date);
145
free(state->msg);
146
+ argv_array_clear(&state->git_apply_opts);
147
}
148
149
/**
415
else
416
state->scissors = SCISSORS_UNSET;
417
418
+ read_state_file(&sb, state, "apply-opt", 1);
419
+ argv_array_clear(&state->git_apply_opts);
420
+ if (sq_dequote_to_argv_array(sb.buf, &state->git_apply_opts) < 0)
421
+ die(_("could not parse %s"), am_path(state, "apply-opt"));
422
+
423
state->rebasing = !!file_exists(am_path(state, "rebasing"));
424
425
strbuf_release(&sb);
594
{
595
unsigned char curr_head[GIT_SHA1_RAWSZ];
596
const char *str;
597
+ struct strbuf sb = STRBUF_INIT;
598
599
if (!patch_format)
600
patch_format = detect_patch_format(paths);
657
658
write_file(am_path(state, "scissors"), 1, "%s", str);
659
660
+ sq_quote_argv(&sb, state->git_apply_opts.argv, 0);
661
+ write_file(am_path(state, "apply-opt"), 1, "%s", sb.buf);
662
+
663
if (state->rebasing)
664
write_file(am_path(state, "rebasing"), 1, "%s", "");
665
else
684
write_file(am_path(state, "next"), 1, "%d", state->cur);
685
686
write_file(am_path(state, "last"), 1, "%d", state->last);
687
+
688
+ strbuf_release(&sb);
689
}
690
691
/**
1073
1074
argv_array_push(&cp.args, "apply");
1075
1076
+ argv_array_pushv(&cp.args, state->git_apply_opts.argv);
1077
+
1078
if (index_file)
1079
argv_array_push(&cp.args, "--cached");
1080
else
1101
1102
cp.git_cmd = 1;
1103
argv_array_push(&cp.args, "apply");
1104
+ argv_array_pushv(&cp.args, state->git_apply_opts.argv);
1105
argv_array_pushf(&cp.args, "--build-fake-ancestor=%s", index_file);
1106
argv_array_push(&cp.args, am_path(state, "patch"));
1107
1617
PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 0},
1618
OPT_BOOL('c', "scissors", &state.scissors,
1619
N_("strip everything before a scissors line")),
1620
+ OPT_PASSTHRU_ARGV(0, "whitespace", &state.git_apply_opts, N_("action"),
1621
+ N_("pass it through git-apply"),
1622
+ 0),
1623
+ OPT_PASSTHRU_ARGV(0, "ignore-space-change", &state.git_apply_opts, NULL,
1624
+ N_("pass it through git-apply"),
1625
+ PARSE_OPT_NOARG),
1626
+ OPT_PASSTHRU_ARGV(0, "ignore-whitespace", &state.git_apply_opts, NULL,
1627
+ N_("pass it through git-apply"),
1628
+ PARSE_OPT_NOARG),
1629
+ OPT_PASSTHRU_ARGV(0, "directory", &state.git_apply_opts, N_("root"),
1630
+ N_("pass it through git-apply"),
1631
+ 0),
1632
+ OPT_PASSTHRU_ARGV(0, "exclude", &state.git_apply_opts, N_("path"),
1633
+ N_("pass it through git-apply"),
1634
+ 0),
1635
+ OPT_PASSTHRU_ARGV(0, "include", &state.git_apply_opts, N_("path"),
1636
+ N_("pass it through git-apply"),
1637
+ 0),
1638
+ OPT_PASSTHRU_ARGV('C', NULL, &state.git_apply_opts, N_("n"),
1639
+ N_("pass it through git-apply"),
1640
+ 0),
1641
+ OPT_PASSTHRU_ARGV('p', NULL, &state.git_apply_opts, N_("num"),
1642
+ N_("pass it through git-apply"),
1643
+ 0),
1644
OPT_CALLBACK(0, "patch-format", &patch_format, N_("format"),
1645
N_("format the patch(es) are in"),
1646
parse_opt_patchformat),
1647
+ OPT_PASSTHRU_ARGV(0, "reject", &state.git_apply_opts, NULL,
1648
+ N_("pass it through git-apply"),
1649
+ PARSE_OPT_NOARG),
1650
OPT_STRING(0, "resolvemsg", &state.resolvemsg, NULL,
1651
N_("override error message when patch failure occurs")),
1652
OPT_CMDMODE(0, "continue", &resume,