Code

revert: allow cherry-pick --continue to commit before resuming
[git.git] / builtin / revert.c
index 9f6c85c1a7104f7626c671169d37cefb4651e22c..a43b4d85fbddb8adb024bc23785894ca4cd20ef5 100644 (file)
@@ -1038,18 +1038,35 @@ static int pick_commits(struct commit_list *todo_list, struct replay_opts *opts)
        return 0;
 }
 
+static int continue_single_pick(void)
+{
+       const char *argv[] = { "commit", NULL };
+
+       if (!file_exists(git_path("CHERRY_PICK_HEAD")) &&
+           !file_exists(git_path("REVERT_HEAD")))
+               return error(_("no cherry-pick or revert in progress"));
+       return run_command_v_opt(argv, RUN_GIT_CMD);
+}
+
 static int sequencer_continue(struct replay_opts *opts)
 {
        struct commit_list *todo_list = NULL;
 
        if (!file_exists(git_path(SEQ_TODO_FILE)))
-               return error(_("No %s in progress"), action_name(opts));
+               return continue_single_pick();
        read_populate_opts(&opts);
        read_populate_todo(&todo_list, opts);
 
        /* Verify that the conflict has been resolved */
-       if (!index_differs_from("HEAD", 0))
-               todo_list = todo_list->next;
+       if (file_exists(git_path("CHERRY_PICK_HEAD")) ||
+           file_exists(git_path("REVERT_HEAD"))) {
+               int ret = continue_single_pick();
+               if (ret)
+                       return ret;
+       }
+       if (index_differs_from("HEAD", 0))
+               return error_dirty_index(opts);
+       todo_list = todo_list->next;
        return pick_commits(todo_list, opts);
 }