Merge branch 'nd/am-quit'
authorJunio C Hamano <gitster@pobox.com>
Wed, 28 Feb 2018 21:37:52 +0000 (13:37 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 28 Feb 2018 21:37:52 +0000 (13:37 -0800)
"git am" has learned the "--quit" option, in addition to the existing
"--abort" option; having the pair mirrors a few other commands like
"rebase" and "cherry-pick".

* nd/am-quit:
am: support --quit

1  2 
builtin/am.c
diff --combined builtin/am.c
index 6661edc162b770d40c62f3a03b7c0e59cb47ca51,793c1e276520b311b122f4d0ad817c8f6f10fe45..05a82f4aa5be6ba82d409f002dce7786734780a1
@@@ -1641,8 -1641,8 +1641,8 @@@ static void do_commit(const struct am_s
                setenv("GIT_COMMITTER_DATE",
                        state->ignore_date ? "" : state->author_date, 1);
  
 -      if (commit_tree(state->msg, state->msg_len, tree.hash, parents, commit.hash,
 -                              author, state->sign_commit))
 +      if (commit_tree(state->msg, state->msg_len, &tree, parents, &commit,
 +                      author, state->sign_commit))
                die(_("failed to write commit object"));
  
        reflog_msg = getenv("GIT_REFLOG_ACTION");
@@@ -2149,7 -2149,8 +2149,8 @@@ enum resume_mode 
        RESUME_APPLY,
        RESUME_RESOLVED,
        RESUME_SKIP,
-       RESUME_ABORT
+       RESUME_ABORT,
+       RESUME_QUIT
  };
  
  static int git_am_config(const char *k, const char *v, void *cb)
@@@ -2249,6 -2250,9 +2250,9 @@@ int cmd_am(int argc, const char **argv
                OPT_CMDMODE(0, "abort", &resume,
                        N_("restore the original branch and abort the patching operation."),
                        RESUME_ABORT),
+               OPT_CMDMODE(0, "quit", &resume,
+                       N_("abort the patching operation but keep HEAD where it is."),
+                       RESUME_QUIT),
                OPT_BOOL(0, "committer-date-is-author-date",
                        &state.committer_date_is_author_date,
                        N_("lie about committer date")),
                 * stray directories.
                 */
                if (file_exists(state.dir) && !state.rebasing) {
-                       if (resume == RESUME_ABORT) {
+                       if (resume == RESUME_ABORT || resume == RESUME_QUIT) {
                                am_destroy(&state);
                                am_state_release(&state);
                                return 0;
        case RESUME_ABORT:
                am_abort(&state);
                break;
+       case RESUME_QUIT:
+               am_rerere_clear();
+               am_destroy(&state);
+               break;
        default:
                die("BUG: invalid resume value");
        }