Re: [PATCH 17/18] revert: Introduce --continue to continue the operation
- From
Christian Couder <chriscool@tuxfamily.org>
- Date
- Jul 31, 2011, 15:51 UTC
- Message-ID
- <201107311751.52965.chriscool@tuxfamily.org>
- In-Reply-To
- <1311871951-3497-18-git-send-email-artagnon@gmail.com>
On Thursday 28 July 2011 18:52:30 Ramkumar Ramachandra wrote:
Show 13 quoted lines
> +static void read_populate_todo(struct commit_list **todo_list,
> + struct replay_opts *opts)
> +{
> + const char *todo_file = git_path(SEQ_TODO_FILE);
> + struct strbuf buf = STRBUF_INIT;
> + struct commit_list **next;
> + struct commit *commit;
> + char *p;
> + int fd;
> +
> + fd = open(todo_file, O_RDONLY);
> + if (fd < 0) {
> + strbuf_release(&buf);We don't need to release buf here.
> + die_errno(_("Could not open %s."), todo_file);
> + }
> + if (strbuf_read(&buf, fd, 0) < buf.len) {The other places in the code are using "strbuf_read(...) < 0" to detect an error.
Show 8 quoted lines
> + close(fd);
> + strbuf_release(&buf);
> + die(_("Could not read %s."), todo_file);
> + }
> + close(fd);
> +
> + next = todo_list;
> + for (p = buf.buf; *p; p = strchr(p, '\n') + 1) {This relies on a "\n" at the end of the last line...
Show 13 quoted lines
> + commit = parse_insn_line(p, opts);
> + if (!commit)
> + goto error;
> + next = commit_list_append(commit, next);
> + }
> + if (!*todo_list)
> + goto error;
> + strbuf_release(&buf);
> + return;
> +error:
> + strbuf_release(&buf);
> + die(_("Unusable instruction sheet: %s"), todo_file);
> +}Thanks, Christian.