Skip to content

Commit 05a01fa

Browse files
committed
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 edit 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>
1 parent 8f67756 commit 05a01fa

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

sequencer.c

Lines changed: 11 additions & 6 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;
@@ -747,25 +752,25 @@ static int parse_insn_buffer(char *buf, struct commit_list **todo_list,
747752
static int read_populate_todo(struct commit_list **todo_list,
748753
struct replay_opts *opts)
749754
{
755+
const char *todo_file = get_todo_path(opts);
750756
struct strbuf buf = STRBUF_INIT;
751757
int fd, res;
752758

753-
fd = open(git_path_todo_file(), O_RDONLY);
759+
fd = open(todo_file, O_RDONLY);
754760
if (fd < 0)
755761
return error(_("Could not open %s (%s)"),
756-
git_path_todo_file(), strerror(errno));
762+
todo_file, strerror(errno));
757763
if (strbuf_read(&buf, fd, 0) < 0) {
758764
close(fd);
759765
strbuf_release(&buf);
760-
return error(_("Could not read %s."), git_path_todo_file());
766+
return error(_("Could not read %s."), todo_file);
761767
}
762768
close(fd);
763769

764770
res = parse_insn_buffer(buf.buf, todo_list, opts);
765771
strbuf_release(&buf);
766772
if (res)
767-
return error(_("Unusable instruction sheet: %s"),
768-
git_path_todo_file());
773+
return error(_("Unusable instruction sheet: %s"), todo_file);
769774
return 0;
770775
}
771776

@@ -1021,7 +1026,7 @@ static int sequencer_continue(struct replay_opts *opts)
10211026
{
10221027
struct commit_list *todo_list = NULL;
10231028

1024-
if (!file_exists(git_path_todo_file()))
1029+
if (!file_exists(get_todo_path(opts)))
10251030
return continue_single_pick();
10261031
if (read_populate_opts(opts) ||
10271032
read_populate_todo(&todo_list, opts))

0 commit comments

Comments
 (0)