revert: Remove sequencer state when no commits are pending
[gitweb.git] / builtin / revert.c
index a8accd6c7a1964e9e1dc233ad2bfb574286c705e..000806c7c42b282a0a6c37af8772e01ae9308a5b 100644 (file)
@@ -763,8 +763,18 @@ static int pick_commits(struct commit_list *todo_list, struct replay_opts *opts)
        for (cur = todo_list; cur; cur = cur->next) {
                save_todo(cur, opts);
                res = do_pick_commit(cur->item, opts);
-               if (res)
+               if (res) {
+                       if (!cur->next)
+                               /*
+                                * An error was encountered while
+                                * picking the last commit; the
+                                * sequencer state is useless now --
+                                * the user simply needs to resolve
+                                * the conflict and commit
+                                */
+                               remove_sequencer_state(0);
                        return res;
+               }
        }
 
        /*