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");
        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)
                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");
        }