]> git.ipfire.org Git - thirdparty/git.git/blobdiff - sequencer.c
Merge branch 'en/rebase-merge-on-sequencer'
[thirdparty/git.git] / sequencer.c
index 4f1cb5e38fe77171cbcb7c070a1b5557d0bdcd6a..a6333abd3990825ed0573c408837dbf164f31f4f 100644 (file)
@@ -150,6 +150,7 @@ static GIT_PATH_FUNC(rebase_path_refs_to_delete, "rebase-merge/refs-to-delete")
 static GIT_PATH_FUNC(rebase_path_gpg_sign_opt, "rebase-merge/gpg_sign_opt")
 static GIT_PATH_FUNC(rebase_path_orig_head, "rebase-merge/orig-head")
 static GIT_PATH_FUNC(rebase_path_verbose, "rebase-merge/verbose")
+static GIT_PATH_FUNC(rebase_path_quiet, "rebase-merge/quiet")
 static GIT_PATH_FUNC(rebase_path_signoff, "rebase-merge/signoff")
 static GIT_PATH_FUNC(rebase_path_head_name, "rebase-merge/head-name")
 static GIT_PATH_FUNC(rebase_path_onto, "rebase-merge/onto")
@@ -157,7 +158,7 @@ static GIT_PATH_FUNC(rebase_path_autostash, "rebase-merge/autostash")
 static GIT_PATH_FUNC(rebase_path_strategy, "rebase-merge/strategy")
 static GIT_PATH_FUNC(rebase_path_strategy_opts, "rebase-merge/strategy_opts")
 static GIT_PATH_FUNC(rebase_path_allow_rerere_autoupdate, "rebase-merge/allow_rerere_autoupdate")
-static GIT_PATH_FUNC(rebase_path_quiet, "rebase-merge/quiet")
+static GIT_PATH_FUNC(rebase_path_reschedule_failed_exec, "rebase-merge/reschedule-failed-exec")
 
 static int git_sequencer_config(const char *k, const char *v, void *cb)
 {
@@ -1790,9 +1791,13 @@ static int do_pick_commit(struct repository *r,
                        return error(_("commit %s does not have parent %d"),
                                oid_to_hex(&commit->object.oid), opts->mainline);
                parent = p->item;
-       } else if (0 < opts->mainline)
-               return error(_("mainline was specified but commit %s is not a merge."),
-                       oid_to_hex(&commit->object.oid));
+       } else if (1 < opts->mainline)
+               /*
+                *  Non-first parent explicitly specified as mainline for
+                *  non-merge commit
+                */
+               return error(_("commit %s does not have parent %d"),
+                            oid_to_hex(&commit->object.oid), opts->mainline);
        else
                parent = commit->parents->item;
 
@@ -2385,11 +2390,17 @@ static int read_populate_opts(struct replay_opts *opts)
                if (file_exists(rebase_path_verbose()))
                        opts->verbose = 1;
 
+               if (file_exists(rebase_path_quiet()))
+                       opts->quiet = 1;
+
                if (file_exists(rebase_path_signoff())) {
                        opts->allow_ff = 0;
                        opts->signoff = 1;
                }
 
+               if (file_exists(rebase_path_reschedule_failed_exec()))
+                       opts->reschedule_failed_exec = 1;
+
                read_strategy_opts(opts, &buf);
                strbuf_release(&buf);
 
@@ -2452,9 +2463,6 @@ int write_basic_state(struct replay_opts *opts, const char *head_name,
 
        if (quiet)
                write_file(rebase_path_quiet(), "%s\n", quiet);
-       else
-               write_file(rebase_path_quiet(), "\n");
-
        if (opts->verbose)
                write_file(rebase_path_verbose(), "%s", "");
        if (opts->strategy)
@@ -2471,6 +2479,8 @@ int write_basic_state(struct replay_opts *opts, const char *head_name,
                write_file(rebase_path_gpg_sign_opt(), "-S%s\n", opts->gpg_sign);
        if (opts->signoff)
                write_file(rebase_path_signoff(), "--signoff\n");
+       if (opts->reschedule_failed_exec)
+               write_file(rebase_path_reschedule_failed_exec(), "%s", "");
 
        return 0;
 }
@@ -3545,10 +3555,11 @@ static int pick_commits(struct repository *r,
                                        fprintf(f, "%d\n", todo_list->done_nr);
                                        fclose(f);
                                }
-                               fprintf(stderr, "Rebasing (%d/%d)%s",
-                                       todo_list->done_nr,
-                                       todo_list->total_nr,
-                                       opts->verbose ? "\n" : "\r");
+                               if (!opts->quiet)
+                                       fprintf(stderr, "Rebasing (%d/%d)%s",
+                                               todo_list->done_nr,
+                                               todo_list->total_nr,
+                                               opts->verbose ? "\n" : "\r");
                        }
                        unlink(rebase_path_message());
                        unlink(rebase_path_author_script());
@@ -3628,9 +3639,10 @@ static int pick_commits(struct repository *r,
                        *end_of_arg = saved;
 
                        /* Reread the todo file if it has changed. */
-                       if (res)
-                               ; /* fall through */
-                       else if (stat(get_todo_path(opts), &st))
+                       if (res) {
+                               if (opts->reschedule_failed_exec)
+                                       reschedule = 1;
+                       } else if (stat(get_todo_path(opts), &st))
                                res = error_errno(_("could not stat '%s'"),
                                                  get_todo_path(opts));
                        else if (match_stat_data(&todo_list->stat, &st)) {
@@ -3781,8 +3793,10 @@ cleanup_head_ref:
                }
                apply_autostash(opts);
 
-               fprintf(stderr, "Successfully rebased and updated %s.\n",
-                       head_ref.buf);
+               if (!opts->quiet)
+                       fprintf(stderr,
+                               "Successfully rebased and updated %s.\n",
+                               head_ref.buf);
 
                strbuf_release(&buf);
                strbuf_release(&head_ref);