rebase -i: use struct object_id rather than looking up commit
We already have a struct object_id containing the oid that we want to set ORIG_HEAD to so use that rather than converting it to a string and then calling get_oid() on that string. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood committed
Nov 4, 2020 at 15:29 UTC
f3e27a02d598084a0ef5c8dd6b410bd6a5c5299f
3 files changed
+9
-11
builtin/rebase.c
+3
-2
@@ -370,8 +370,9 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
370
371
split_exec_commands(opts->cmd, &commands);
372
ret = complete_action(the_repository, &replay, flags,
373
- shortrevisions, opts->onto_name, opts->onto, head_hash,
374
- &commands, opts->autosquash, &todo_list);
373
+ shortrevisions, opts->onto_name, opts->onto,
374
+ &opts->orig_head, &commands, opts->autosquash,
375
+ &todo_list);
376
}
377
378
string_list_clear(&commands, 0);
sequencer.c
+3
-7
@@ -3965,21 +3965,17 @@ static int run_git_checkout(struct repository *r, struct replay_opts *opts,
3965
3966
static int checkout_onto(struct repository *r, struct replay_opts *opts,
3967
const char *onto_name, const struct object_id *onto,
3968
- const char *orig_head)
3968
+ const struct object_id *orig_head)
3969
{
3970
- struct object_id oid;
3970
const char *action = reflog_message(opts, "start", "checkout %s", onto_name);
3971
3973
- if (get_oid(orig_head, &oid))
3974
- return error(_("%s: not a valid OID"), orig_head);
3975
-
3972
if (run_git_checkout(r, opts, oid_to_hex(onto), action)) {
3973
apply_autostash(rebase_path_autostash());
3974
sequencer_remove_state(opts);
3975
return error(_("could not detach HEAD"));
3976
}
3977
3982
- return update_ref(NULL, "ORIG_HEAD", &oid, NULL, 0, UPDATE_REFS_MSG_ON_ERR);
3978
+ return update_ref(NULL, "ORIG_HEAD", orig_head, NULL, 0, UPDATE_REFS_MSG_ON_ERR);
3979
}
3980
3981
static int stopped_at_head(struct repository *r)
@@ -5314,7 +5310,7 @@ static int skip_unnecessary_picks(struct repository *r,
5310
5311
int complete_action(struct repository *r, struct replay_opts *opts, unsigned flags,
5312
const char *shortrevisions, const char *onto_name,
5317
- struct commit *onto, const char *orig_head,
5313
+ struct commit *onto, const struct object_id *orig_head,
5314
struct string_list *commands, unsigned autosquash,
5315
struct todo_list *todo_list)
5316
{
sequencer.h
+3
-2
@@ -163,8 +163,9 @@ void todo_list_add_exec_commands(struct todo_list *todo_list,
163
struct string_list *commands);
164
int complete_action(struct repository *r, struct replay_opts *opts, unsigned flags,
165
const char *shortrevisions, const char *onto_name,
166
- struct commit *onto, const char *orig_head, struct string_list *commands,
167
- unsigned autosquash, struct todo_list *todo_list);
166
+ struct commit *onto, const struct object_id *orig_head,
167
+ struct string_list *commands, unsigned autosquash,
168
+ struct todo_list *todo_list);
169
int todo_list_rearrange_squash(struct todo_list *todo_list);
170
171
/*