Skip to content

Commit f3e27a0

Browse files
phillipwoodgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e100bea commit f3e27a0

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

builtin/rebase.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,9 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
370370

371371
split_exec_commands(opts->cmd, &commands);
372372
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);
375376
}
376377

377378
string_list_clear(&commands, 0);

sequencer.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3965,21 +3965,17 @@ static int run_git_checkout(struct repository *r, struct replay_opts *opts,
39653965

39663966
static int checkout_onto(struct repository *r, struct replay_opts *opts,
39673967
const char *onto_name, const struct object_id *onto,
3968-
const char *orig_head)
3968+
const struct object_id *orig_head)
39693969
{
3970-
struct object_id oid;
39713970
const char *action = reflog_message(opts, "start", "checkout %s", onto_name);
39723971

3973-
if (get_oid(orig_head, &oid))
3974-
return error(_("%s: not a valid OID"), orig_head);
3975-
39763972
if (run_git_checkout(r, opts, oid_to_hex(onto), action)) {
39773973
apply_autostash(rebase_path_autostash());
39783974
sequencer_remove_state(opts);
39793975
return error(_("could not detach HEAD"));
39803976
}
39813977

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);
39833979
}
39843980

39853981
static int stopped_at_head(struct repository *r)
@@ -5314,7 +5310,7 @@ static int skip_unnecessary_picks(struct repository *r,
53145310

53155311
int complete_action(struct repository *r, struct replay_opts *opts, unsigned flags,
53165312
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,
53185314
struct string_list *commands, unsigned autosquash,
53195315
struct todo_list *todo_list)
53205316
{

sequencer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,9 @@ void todo_list_add_exec_commands(struct todo_list *todo_list,
163163
struct string_list *commands);
164164
int complete_action(struct repository *r, struct replay_opts *opts, unsigned flags,
165165
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);
168169
int todo_list_rearrange_squash(struct todo_list *todo_list);
169170

170171
/*

0 commit comments

Comments
 (0)