summaryrefslogtreecommitdiff
path: root/builtin/am.c
diff options
context:
space:
mode:
authorPaul Tan <pyokagan@gmail.com>2015-08-04 13:51:33 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-08-05 05:02:11 (GMT)
commit8c7b1563eeb2dd42eef0c5ab1a65b7a93300908c (patch)
tree2e9b399056e5090d37dd0a110323fb3749569395 /builtin/am.c
parent240bfd2de9a7aec31240300ba1d7e89c59dbafe9 (diff)
downloadgit-8c7b1563eeb2dd42eef0c5ab1a65b7a93300908c.zip
git-8c7b1563eeb2dd42eef0c5ab1a65b7a93300908c.tar.gz
git-8c7b1563eeb2dd42eef0c5ab1a65b7a93300908c.tar.bz2
builtin-am: don't parse mail when resuming
Since 271440e (git-am: make it easier after fixing up an unapplicable patch., 2005-10-25), when "git am" is run again after being paused, the current mail message will not be re-parsed, but instead the contents of the state directory's patch, msg and author-script files will be used as-is instead. Re-implement this in builtin/am.c. Signed-off-by: Paul Tan <pyokagan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/am.c')
-rw-r--r--builtin/am.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/builtin/am.c b/builtin/am.c
index fd26721..ec579a6 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -776,8 +776,12 @@ static void validate_resume_state(const struct am_state *state)
/**
* Applies all queued mail.
+ *
+ * If `resume` is true, we are "resuming". The "msg" and authorship fields, as
+ * well as the state directory's "patch" file is used as-is for applying the
+ * patch and committing it.
*/
-static void am_run(struct am_state *state)
+static void am_run(struct am_state *state, int resume)
{
const char *argv_gc_auto[] = {"gc", "--auto", NULL};
struct strbuf sb = STRBUF_INIT;
@@ -795,11 +799,16 @@ static void am_run(struct am_state *state)
if (!file_exists(mail))
goto next;
- if (parse_mail(state, mail))
- goto next; /* mail should be skipped */
+ if (resume) {
+ validate_resume_state(state);
+ resume = 0;
+ } else {
+ if (parse_mail(state, mail))
+ goto next; /* mail should be skipped */
- write_author_script(state);
- write_commit_msg(state);
+ write_author_script(state);
+ write_commit_msg(state);
+ }
printf_ln(_("Applying: %.*s"), linelen(state->msg), state->msg);
@@ -855,7 +864,7 @@ static void am_resolve(struct am_state *state)
do_commit(state);
am_next(state);
- am_run(state);
+ am_run(state, 0);
}
/**
@@ -875,6 +884,7 @@ static int parse_opt_patchformat(const struct option *opt, const char *arg, int
enum resume_mode {
RESUME_FALSE = 0,
+ RESUME_APPLY,
RESUME_RESOLVED
};
@@ -927,9 +937,12 @@ int cmd_am(int argc, const char **argv, const char *prefix)
if (read_index_preload(&the_index, NULL) < 0)
die(_("failed to read the index"));
- if (am_in_progress(&state))
+ if (am_in_progress(&state)) {
+ if (resume == RESUME_FALSE)
+ resume = RESUME_APPLY;
+
am_load(&state);
- else {
+ } else {
struct argv_array paths = ARGV_ARRAY_INIT;
int i;
@@ -950,7 +963,10 @@ int cmd_am(int argc, const char **argv, const char *prefix)
switch (resume) {
case RESUME_FALSE:
- am_run(&state);
+ am_run(&state, 0);
+ break;
+ case RESUME_APPLY:
+ am_run(&state, 1);
break;
case RESUME_RESOLVED:
am_resolve(&state);