static void read_populate_todo(struct commit_list **todo_list, struct replay_opts *opts) { struct strbuf buf = STRBUF_INIT; int fd, res; fd = open(git_path_todo_file(), O_RDONLY); if (fd < 0) die_errno(_("Could not open %s"), git_path_todo_file()); if (strbuf_read(&buf, fd, 0) < 0) { close(fd); strbuf_release(&buf); die(_("Could not read %s."), git_path_todo_file()); } close(fd); res = parse_insn_buffer(buf.buf, todo_list, opts); strbuf_release(&buf); if (res) die(_("Unusable instruction sheet: %s"), git_path_todo_file()); }
static int read_populate_todo(struct todo_list *todo_list, struct replay_opts *opts) { const char *todo_file = get_todo_path(opts); int fd, res; strbuf_reset(&todo_list->buf); fd = open(todo_file, O_RDONLY); if (fd < 0) return error_errno(_("could not open '%s'"), todo_file); if (strbuf_read(&todo_list->buf, fd, 0) < 0) { close(fd); return error(_("could not read '%s'."), todo_file); } close(fd); res = parse_insn_buffer(todo_list->buf.buf, todo_list); if (res) return error(_("unusable instruction sheet: '%s'"), todo_file); if (!is_rebase_i(opts)) { enum todo_command valid = opts->action == REPLAY_PICK ? TODO_PICK : TODO_REVERT; int i; for (i = 0; i < todo_list->nr; i++) if (valid == todo_list->items[i].command) continue; else if (valid == TODO_PICK) return error(_("cannot cherry-pick during a revert.")); else return error(_("cannot revert during a cherry-pick.")); } return 0; }