summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c38
1 files changed, 11 insertions, 27 deletions
diff --git a/sequencer.c b/sequencer.c
index 55ed074..bdd66b4 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -4223,42 +4223,26 @@ int apply_autostash_oid(const char *stash_oid)
return apply_save_autostash_oid(stash_oid, 1);
}
-static int run_git_checkout(struct repository *r, struct replay_opts *opts,
- const char *commit, const char *action)
-{
- struct child_process cmd = CHILD_PROCESS_INIT;
- int ret;
-
- cmd.git_cmd = 1;
-
- strvec_push(&cmd.args, "checkout");
- strvec_push(&cmd.args, commit);
- strvec_pushf(&cmd.env_array, GIT_REFLOG_ACTION "=%s", action);
-
- if (opts->verbose)
- ret = run_command(&cmd);
- else
- ret = run_command_silent_on_success(&cmd);
-
- if (!ret)
- discard_index(r->index);
-
- return ret;
-}
-
static int checkout_onto(struct repository *r, struct replay_opts *opts,
const char *onto_name, const struct object_id *onto,
const struct object_id *orig_head)
{
- const char *action = reflog_message(opts, "start", "checkout %s", onto_name);
-
- if (run_git_checkout(r, opts, oid_to_hex(onto), action)) {
+ struct reset_head_opts ropts = {
+ .oid = onto,
+ .orig_head = orig_head,
+ .flags = RESET_HEAD_DETACH | RESET_ORIG_HEAD |
+ RESET_HEAD_RUN_POST_CHECKOUT_HOOK,
+ .head_msg = reflog_message(opts, "start", "checkout %s",
+ onto_name),
+ .default_reflog_action = "rebase"
+ };
+ if (reset_head(r, &ropts)) {
apply_autostash(rebase_path_autostash());
sequencer_remove_state(opts);
return error(_("could not detach HEAD"));
}
- return update_ref(NULL, "ORIG_HEAD", orig_head, NULL, 0, UPDATE_REFS_MSG_ON_ERR);
+ return 0;
}
static int stopped_at_head(struct repository *r)