summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorAlban Gruin <alban.gruin@gmail.com>2018-08-10 16:51:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-08-10 18:56:22 (GMT)
commit4df66c40b08931eb224964f12decbb0f660cf932 (patch)
treed50cbac660ed4085f7477a56beb248abfdc90221 /sequencer.c
parent2c58483a5983d1313f674e2ba32b3bac24df6911 (diff)
downloadgit-4df66c40b08931eb224964f12decbb0f660cf932.zip
git-4df66c40b08931eb224964f12decbb0f660cf932.tar.gz
git-4df66c40b08931eb224964f12decbb0f660cf932.tar.bz2
rebase -i: rewrite checkout_onto() in C
This rewrites checkout_onto() from shell to C. A new command (“checkout-onto”) is added to rebase--helper.c. The shell version is then stripped. Signed-off-by: Alban Gruin <alban.gruin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sequencer.c b/sequencer.c
index e48b37b..df2c80d 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -3169,6 +3169,25 @@ int prepare_branch_to_be_rebased(struct replay_opts *opts, const char *commit)
return 0;
}
+int checkout_onto(struct replay_opts *opts,
+ const char *onto_name, const char *onto,
+ const char *orig_head)
+{
+ struct object_id oid;
+ const char *action = reflog_message(opts, "start", "checkout %s", onto_name);
+
+ if (get_oid(orig_head, &oid))
+ return error(_("%s: not a valid OID"), orig_head);
+
+ if (run_git_checkout(opts, onto, action)) {
+ apply_autostash(opts);
+ sequencer_remove_state(opts);
+ return error(_("could not detach HEAD"));
+ }
+
+ return update_ref(NULL, "ORIG_HEAD", &oid, NULL, 0, UPDATE_REFS_MSG_ON_ERR);
+}
+
static const char rescheduled_advice[] =
N_("Could not execute the todo command\n"
"\n"