diff options
author | Alban Gruin <alban.gruin@gmail.com> | 2018-08-10 18:51:34 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-08-10 20:56:22 +0200 |
commit | 4df66c40b08931eb224964f12decbb0f660cf932 (patch) | |
tree | d50cbac660ed4085f7477a56beb248abfdc90221 /sequencer.c | |
parent | rebase -i: rewrite setup_reflog_action() in C (diff) | |
download | git-4df66c40b08931eb224964f12decbb0f660cf932.tar.xz git-4df66c40b08931eb224964f12decbb0f660cf932.zip |
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.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sequencer.c b/sequencer.c index e48b37bc0e..df2c80d879 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" |