Refactor `sequencer_remove_state()` to stop using `the_repository` in favor of a passed-in repository. A lot of the other code in our sequencer infrastructure still uses `the_repository`, but this bigger refactoring is left for another day. Signed-off-by: Patrick Steinhardt <ps@xxxxxx> --- builtin/rebase.c | 4 ++-- builtin/revert.c | 2 +- sequencer.c | 18 +++++++++--------- sequencer.h | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 3c85768d29..66824ae136 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -568,7 +568,7 @@ static int finish_rebase(struct rebase_options *opts) struct replay_opts replay = REPLAY_OPTS_INIT; replay.action = REPLAY_INTERACTIVE_REBASE; - ret = sequencer_remove_state(&replay); + ret = sequencer_remove_state(the_repository, &replay); replay_opts_release(&replay); } else { strbuf_addstr(&dir, opts->state_dir); @@ -1405,7 +1405,7 @@ int cmd_rebase(int argc, struct replay_opts replay = REPLAY_OPTS_INIT; replay.action = REPLAY_INTERACTIVE_REBASE; - ret = sequencer_remove_state(&replay); + ret = sequencer_remove_state(the_repository, &replay); replay_opts_release(&replay); } else { strbuf_reset(&buf); diff --git a/builtin/revert.c b/builtin/revert.c index c3f92b585d..6456cf2171 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -263,7 +263,7 @@ static int run_sequencer(int argc, const char **argv, const char *prefix, free(options); if (cmd == 'q') { - int ret = sequencer_remove_state(opts); + int ret = sequencer_remove_state(the_repository, opts); if (!ret) remove_branch_state(the_repository, 0); return ret; diff --git a/sequencer.c b/sequencer.c index 9a66e7d128..36e4db8526 100644 --- a/sequencer.c +++ b/sequencer.c @@ -425,7 +425,7 @@ void replay_opts_release(struct replay_opts *opts) free(opts->ctx); } -int sequencer_remove_state(struct replay_opts *opts) +int sequencer_remove_state(struct repository *repo, struct replay_opts *opts) { struct strbuf buf = STRBUF_INIT; int ret = 0; @@ -437,7 +437,7 @@ int sequencer_remove_state(struct replay_opts *opts) char *eol = strchr(p, '\n'); if (eol) *eol = '\0'; - if (refs_delete_ref(get_main_ref_store(the_repository), "(rebase) cleanup", p, NULL, 0) < 0) { + if (refs_delete_ref(get_main_ref_store(repo), "(rebase) cleanup", p, NULL, 0) < 0) { warning(_("could not delete '%s'"), p); ret = -1; } @@ -3048,7 +3048,7 @@ void sequencer_post_commit_cleanup(struct repository *r, int verbose) if (!have_finished_the_last_pick()) goto out; - sequencer_remove_state(&opts); + sequencer_remove_state(the_repository, &opts); out: replay_opts_release(&opts); } @@ -3595,7 +3595,7 @@ int sequencer_rollback(struct repository *r, struct replay_opts *opts) if (reset_merge(&oid)) goto fail; strbuf_release(&buf); - return sequencer_remove_state(opts); + return sequencer_remove_state(the_repository, opts); fail: strbuf_release(&buf); return -1; @@ -4897,7 +4897,7 @@ static int checkout_onto(struct repository *r, struct replay_opts *opts, }; if (reset_head(r, &ropts)) { apply_autostash(rebase_path_autostash()); - sequencer_remove_state(opts); + sequencer_remove_state(the_repository, opts); return error(_("could not detach HEAD")); } @@ -5262,7 +5262,7 @@ static int pick_commits(struct repository *r, * Sequence of picks finished successfully; cleanup by * removing the .git/sequencer directory */ - return sequencer_remove_state(opts); + return sequencer_remove_state(the_repository, opts); } static int continue_single_pick(struct repository *r, struct replay_opts *opts) @@ -6593,7 +6593,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla if (count_commands(todo_list) == 0) { apply_autostash(rebase_path_autostash()); - sequencer_remove_state(opts); + sequencer_remove_state(the_repository, opts); return error(_("nothing to do")); } @@ -6604,12 +6604,12 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla return -1; else if (res == -2) { apply_autostash(rebase_path_autostash()); - sequencer_remove_state(opts); + sequencer_remove_state(the_repository, opts); return -1; } else if (res == -3) { apply_autostash(rebase_path_autostash()); - sequencer_remove_state(opts); + sequencer_remove_state(the_repository, opts); todo_list_release(&new_todo); return error(_("nothing to do")); diff --git a/sequencer.h b/sequencer.h index 082fbe3e35..0e0e7301b8 100644 --- a/sequencer.h +++ b/sequencer.h @@ -170,7 +170,7 @@ int sequencer_continue(struct repository *repo, struct replay_opts *opts); int sequencer_rollback(struct repository *repo, struct replay_opts *opts); int sequencer_skip(struct repository *repo, struct replay_opts *opts); void replay_opts_release(struct replay_opts *opts); -int sequencer_remove_state(struct replay_opts *opts); +int sequencer_remove_state(struct repository *repo, struct replay_opts *opts); #define TODO_LIST_KEEP_EMPTY (1U << 0) #define TODO_LIST_SHORTEN_IDS (1U << 1) -- 2.51.0.417.g1ba7204a04.dirty