Skip to content

Commit 8f67756

Browse files
committed
sequencer: future-proof remove_sequencer_state()
In a couple of commits, we will teach the sequencer to handle the nitty gritty of the interactive rebase, which keeps its state in a different directory. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 85605ed commit 8f67756

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

sequencer.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ static GIT_PATH_FUNC(git_path_todo_file, "sequencer/todo")
2727
static GIT_PATH_FUNC(git_path_opts_file, "sequencer/opts")
2828
static GIT_PATH_FUNC(git_path_head_file, "sequencer/head")
2929

30+
static const char *get_dir(const struct replay_opts *opts)
31+
{
32+
return git_path_seq_dir();
33+
}
34+
3035
static int is_rfc2822_line(const char *buf, int len)
3136
{
3237
int i;
@@ -109,13 +114,13 @@ static int has_conforming_footer(struct strbuf *sb, struct strbuf *sob,
109114
return 1;
110115
}
111116

112-
static void remove_sequencer_state(void)
117+
static void remove_sequencer_state(const struct replay_opts *opts)
113118
{
114-
struct strbuf seq_dir = STRBUF_INIT;
119+
struct strbuf dir = STRBUF_INIT;
115120

116-
strbuf_addf(&seq_dir, "%s", git_path_seq_dir());
117-
remove_dir_recursively(&seq_dir, 0);
118-
strbuf_release(&seq_dir);
121+
strbuf_addf(&dir, "%s", get_dir(opts));
122+
remove_dir_recursively(&dir, 0);
123+
strbuf_release(&dir);
119124
}
120125

121126
static const char *action_name(const struct replay_opts *opts)
@@ -909,7 +914,7 @@ static int sequencer_rollback(struct replay_opts *opts)
909914
}
910915
if (reset_for_rollback(sha1))
911916
goto fail;
912-
remove_sequencer_state();
917+
remove_sequencer_state(opts);
913918
strbuf_release(&buf);
914919
return 0;
915920
fail:
@@ -998,7 +1003,7 @@ static int pick_commits(struct commit_list *todo_list, struct replay_opts *opts)
9981003
* Sequence of picks finished successfully; cleanup by
9991004
* removing the .git/sequencer directory
10001005
*/
1001-
remove_sequencer_state();
1006+
remove_sequencer_state(opts);
10021007
return 0;
10031008
}
10041009

@@ -1059,7 +1064,7 @@ int sequencer_pick_revisions(struct replay_opts *opts)
10591064
* one that is being continued
10601065
*/
10611066
if (opts->subcommand == REPLAY_REMOVE_STATE) {
1062-
remove_sequencer_state();
1067+
remove_sequencer_state(opts);
10631068
return 0;
10641069
}
10651070
if (opts->subcommand == REPLAY_ROLLBACK)

0 commit comments

Comments
 (0)