Skip to content

Commit c024650

Browse files
dschogitster
authored andcommitted
sequencer: future-proof read_populate_todo()
Over the next commits, we will work on improving the sequencer to the point where it can process the todo script of an interactive rebase. To that end, we will need to teach the sequencer to read interactive rebase's todo file. In preparation, we consolidate all places where that todo file is needed to call a function that we will later extend. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 03a4e26 commit c024650

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

sequencer.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ static const char *get_dir(const struct replay_opts *opts)
3232
return git_path_seq_dir();
3333
}
3434

35+
static const char *get_todo_path(const struct replay_opts *opts)
36+
{
37+
return git_path_todo_file();
38+
}
39+
3540
static int is_rfc2822_line(const char *buf, int len)
3641
{
3742
int i;
@@ -769,25 +774,24 @@ static int parse_insn_buffer(char *buf, struct commit_list **todo_list,
769774
static int read_populate_todo(struct commit_list **todo_list,
770775
struct replay_opts *opts)
771776
{
777+
const char *todo_file = get_todo_path(opts);
772778
struct strbuf buf = STRBUF_INIT;
773779
int fd, res;
774780

775-
fd = open(git_path_todo_file(), O_RDONLY);
781+
fd = open(todo_file, O_RDONLY);
776782
if (fd < 0)
777-
return error_errno(_("Could not open %s"),
778-
git_path_todo_file());
783+
return error_errno(_("Could not open %s"), todo_file);
779784
if (strbuf_read(&buf, fd, 0) < 0) {
780785
close(fd);
781786
strbuf_release(&buf);
782-
return error(_("Could not read %s."), git_path_todo_file());
787+
return error(_("Could not read %s."), todo_file);
783788
}
784789
close(fd);
785790

786791
res = parse_insn_buffer(buf.buf, todo_list, opts);
787792
strbuf_release(&buf);
788793
if (res)
789-
return error(_("Unusable instruction sheet: %s"),
790-
git_path_todo_file());
794+
return error(_("Unusable instruction sheet: %s"), todo_file);
791795
return 0;
792796
}
793797

@@ -1075,7 +1079,7 @@ static int sequencer_continue(struct replay_opts *opts)
10751079
{
10761080
struct commit_list *todo_list = NULL;
10771081

1078-
if (!file_exists(git_path_todo_file()))
1082+
if (!file_exists(get_todo_path(opts)))
10791083
return continue_single_pick();
10801084
if (read_populate_opts(opts) ||
10811085
read_populate_todo(&todo_list, opts))

0 commit comments

Comments
 (0)