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>
This commit is contained in:

committed by
Junio C Hamano

parent
5adf9bdc1b
commit
285abf561a
21
sequencer.c
21
sequencer.c
@ -27,6 +27,11 @@ static GIT_PATH_FUNC(git_path_todo_file, "sequencer/todo")
|
|||||||
static GIT_PATH_FUNC(git_path_opts_file, "sequencer/opts")
|
static GIT_PATH_FUNC(git_path_opts_file, "sequencer/opts")
|
||||||
static GIT_PATH_FUNC(git_path_head_file, "sequencer/head")
|
static GIT_PATH_FUNC(git_path_head_file, "sequencer/head")
|
||||||
|
|
||||||
|
static const char *get_dir(const struct replay_opts *opts)
|
||||||
|
{
|
||||||
|
return git_path_seq_dir();
|
||||||
|
}
|
||||||
|
|
||||||
static int is_rfc2822_line(const char *buf, int len)
|
static int is_rfc2822_line(const char *buf, int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -109,13 +114,13 @@ static int has_conforming_footer(struct strbuf *sb, struct strbuf *sob,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void remove_sequencer_state(void)
|
static void remove_sequencer_state(const struct replay_opts *opts)
|
||||||
{
|
{
|
||||||
struct strbuf seq_dir = STRBUF_INIT;
|
struct strbuf dir = STRBUF_INIT;
|
||||||
|
|
||||||
strbuf_addstr(&seq_dir, git_path_seq_dir());
|
strbuf_addf(&dir, "%s", get_dir(opts));
|
||||||
remove_dir_recursively(&seq_dir, 0);
|
remove_dir_recursively(&dir, 0);
|
||||||
strbuf_release(&seq_dir);
|
strbuf_release(&dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *action_name(const struct replay_opts *opts)
|
static const char *action_name(const struct replay_opts *opts)
|
||||||
@ -940,7 +945,7 @@ static int sequencer_rollback(struct replay_opts *opts)
|
|||||||
}
|
}
|
||||||
if (reset_for_rollback(sha1))
|
if (reset_for_rollback(sha1))
|
||||||
goto fail;
|
goto fail;
|
||||||
remove_sequencer_state();
|
remove_sequencer_state(opts);
|
||||||
strbuf_release(&buf);
|
strbuf_release(&buf);
|
||||||
return 0;
|
return 0;
|
||||||
fail:
|
fail:
|
||||||
@ -1034,7 +1039,7 @@ static int pick_commits(struct commit_list *todo_list, struct replay_opts *opts)
|
|||||||
* Sequence of picks finished successfully; cleanup by
|
* Sequence of picks finished successfully; cleanup by
|
||||||
* removing the .git/sequencer directory
|
* removing the .git/sequencer directory
|
||||||
*/
|
*/
|
||||||
remove_sequencer_state();
|
remove_sequencer_state(opts);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1095,7 +1100,7 @@ int sequencer_pick_revisions(struct replay_opts *opts)
|
|||||||
* one that is being continued
|
* one that is being continued
|
||||||
*/
|
*/
|
||||||
if (opts->subcommand == REPLAY_REMOVE_STATE) {
|
if (opts->subcommand == REPLAY_REMOVE_STATE) {
|
||||||
remove_sequencer_state();
|
remove_sequencer_state(opts);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (opts->subcommand == REPLAY_ROLLBACK)
|
if (opts->subcommand == REPLAY_ROLLBACK)
|
||||||
|
Reference in New Issue
Block a user