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>
Johannes Schindelin committed
Oct 14, 2016 at 15:17 UTC
285abf561aa410b3a9dfb2887e42fcdc4c461971
1 file changed
+13
-8
sequencer.c
+13
-8
@@ -27,6 +27,11 @@ static GIT_PATH_FUNC(git_path_todo_file, "sequencer/todo")
27
static GIT_PATH_FUNC(git_path_opts_file, "sequencer/opts")
28
static GIT_PATH_FUNC(git_path_head_file, "sequencer/head")
29
30
+static const char *get_dir(const struct replay_opts *opts)
31
+{
32
+ return git_path_seq_dir();
33
+}
34
+
35
static int is_rfc2822_line(const char *buf, int len)
36
{
37
int i;
@@ -109,13 +114,13 @@ static int has_conforming_footer(struct strbuf *sb, struct strbuf *sob,
114
return 1;
115
}
116
112
-static void remove_sequencer_state(void)
117
+static void remove_sequencer_state(const struct replay_opts *opts)
118
{
114
- struct strbuf seq_dir = STRBUF_INIT;
119
+ struct strbuf dir = STRBUF_INIT;
120
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);
124
}
125
126
static const char *action_name(const struct replay_opts *opts)
@@ -940,7 +945,7 @@ static int sequencer_rollback(struct replay_opts *opts)
945
}
946
if (reset_for_rollback(sha1))
947
goto fail;
943
- remove_sequencer_state();
948
+ remove_sequencer_state(opts);
949
strbuf_release(&buf);
950
return 0;
951
fail:
@@ -1034,7 +1039,7 @@ static int pick_commits(struct commit_list *todo_list, struct replay_opts *opts)
1039
* Sequence of picks finished successfully; cleanup by
1040
* removing the .git/sequencer directory
1041
*/
1037
- remove_sequencer_state();
1042
+ remove_sequencer_state(opts);
1043
return 0;
1044
}
1045
@@ -1095,7 +1100,7 @@ int sequencer_pick_revisions(struct replay_opts *opts)
1100
* one that is being continued
1101
*/
1102
if (opts->subcommand == REPLAY_REMOVE_STATE) {
1098
- remove_sequencer_state();
1103
+ remove_sequencer_state(opts);
1104
return 0;
1105
}
1106
if (opts->subcommand == REPLAY_ROLLBACK)