summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/sequencer.c b/sequencer.c
index 960a935444..e48b37bc0e 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -3139,6 +3139,36 @@ static const char *reflog_message(struct replay_opts *opts,
return buf.buf;
}
+static int run_git_checkout(struct replay_opts *opts, const char *commit,
+ const char *action)
+{
+ struct child_process cmd = CHILD_PROCESS_INIT;
+
+ cmd.git_cmd = 1;
+
+ argv_array_push(&cmd.args, "checkout");
+ argv_array_push(&cmd.args, commit);
+ argv_array_pushf(&cmd.env_array, GIT_REFLOG_ACTION "=%s", action);
+
+ if (opts->verbose)
+ return run_command(&cmd);
+ else
+ return run_command_silent_on_success(&cmd);
+}
+
+int prepare_branch_to_be_rebased(struct replay_opts *opts, const char *commit)
+{
+ const char *action;
+
+ if (commit && *commit) {
+ action = reflog_message(opts, "start", "checkout %s", commit);
+ if (run_git_checkout(opts, commit, action))
+ return error(_("could not checkout %s"), commit);
+ }
+
+ return 0;
+}
+
static const char rescheduled_advice[] =
N_("Could not execute the todo command\n"
"\n"