[prev in list] [next in list] [prev in thread] [next in thread] 

List:       git
Subject:    Re: [PATCH 17/18] revert: Introduce --continue to continue the operation
From:       Christian Couder <chriscool () tuxfamily ! org>
Date:       2011-07-31 15:51:52
Message-ID: 201107311751.52965.chriscool () tuxfamily ! org
[Download RAW message or body]

On Thursday 28 July 2011 18:52:30 Ramkumar Ramachandra wrote:
> +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.

> +		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...

> +		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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic