Skip to content

Commit 285abf5

Browse files
dschogitster
authored andcommitted
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 5adf9bd commit 285abf5

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

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_addstr(&seq_dir, 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)
@@ -940,7 +945,7 @@ static int sequencer_rollback(struct replay_opts *opts)
940945
}
941946
if (reset_for_rollback(sha1))
942947
goto fail;
943-
remove_sequencer_state();
948+
remove_sequencer_state(opts);
944949
strbuf_release(&buf);
945950
return 0;
946951
fail:
@@ -1034,7 +1039,7 @@ static int pick_commits(struct commit_list *todo_list, struct replay_opts *opts)
10341039
* Sequence of picks finished successfully; cleanup by
10351040
* removing the .git/sequencer directory
10361041
*/
1037-
remove_sequencer_state();
1042+
remove_sequencer_state(opts);
10381043
return 0;
10391044
}
10401045

@@ -1095,7 +1100,7 @@ int sequencer_pick_revisions(struct replay_opts *opts)
10951100
* one that is being continued
10961101
*/
10971102
if (opts->subcommand == REPLAY_REMOVE_STATE) {
1098-
remove_sequencer_state();
1103+
remove_sequencer_state(opts);
10991104
return 0;
11001105
}
11011106
if (opts->subcommand == REPLAY_ROLLBACK)

0 commit comments

Comments
 (0)