From: Phillip Wood Date: Thu, 23 Mar 2023 19:34:57 GMT Subject: Re: [PATCH 7/8] sequencer: pass `onto` to complete_action() as object-id Message-ID: In-Reply-To: <20230323162235.995574-8-oswald.buddenhagen@gmx.de> Hi Oswald On 23/03/2023 16:22, Oswald Buddenhagen wrote: > ... instead of as a commit, which makes the purpose clearer and will > simplify things later. given that we want onto to be a commit I'm not sure how this makes anything clearer. > As a side effect, this change revealed that skip_unnecessary_picks() was > butchering the commit object due to missing const-correctness. Slightly > adjust its API to rectify this. I don't think this is correct. If you look at the original code it makes a copy of the oid and uses the copy when calling skip_unnecessary_picks() > int complete_action(struct repository *r, struct replay_opts *opts, unsigned flags, > const char *shortrevisions, const char *onto_name, > - struct commit *onto, const struct object_id *orig_head, > + const struct object_id *onto, const struct object_id *orig_head, > struct string_list *commands, unsigned autosquash, > unsigned update_refs, struct todo_list *todo_list, > enum rebase_action action) > { > char shortonto[GIT_MAX_HEXSZ + 1]; > const char *todo_file = rebase_path_todo(); > struct todo_list new_todo = TODO_LIST_INIT; > struct strbuf *buf = &todo_list->buf, buf2 = STRBUF_INIT; > - struct object_id oid = onto->object.oid; Here we copy the onto's oid > @@ -6158,7 +6157,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla > BUG("invalid todo list after expanding IDs:\n%s", > new_todo.buf.buf); > > - if (opts->allow_ff && skip_unnecessary_picks(r, &new_todo, &oid)) { Here we pass the copy to skip_unnecessary_picks() Best Wishes Phillip > + if (opts->allow_ff && skip_unnecessary_picks(r, &new_todo, &onto)) { > todo_list_release(&new_todo); > return error(_("could not skip unnecessary pick commands")); > } > @@ -6171,7 +6170,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla > > res = -1; > > - if (checkout_onto(r, opts, onto_name, &oid, orig_head)) > + if (checkout_onto(r, opts, onto_name, onto, orig_head)) > goto cleanup; > > if (require_clean_work_tree(r, "rebase", NULL, 1, 1)) > diff --git a/sequencer.h b/sequencer.h > index a1b8ca6eb1..24bf71d5db 100644 > --- a/sequencer.h > +++ b/sequencer.h > @@ -188,7 +188,7 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc, > > int complete_action(struct repository *r, struct replay_opts *opts, unsigned flags, > const char *shortrevisions, const char *onto_name, > - struct commit *onto, const struct object_id *orig_head, > + const struct object_id *onto, const struct object_id *orig_head, > struct string_list *commands, unsigned autosquash, > unsigned update_refs, struct todo_list *todo_list, > enum rebase_action action);