Re: [PATCH v7 3/5] bisect: simplify the addition of new bisect terms
On Tue, Jun 23, 2015 at 8:54 AM, Matthieu Moy <Matthieu.Moy@imag.fr> wrote:
Show 18 quoted lines
> diff --git a/revision.c b/revision.c
> index 3ff8723..f22923f 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -2076,14 +2079,32 @@ void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
> ctx->argc -= n;
> }
>
> +extern void read_bisect_terms(const char **bad, const char **good);
> +
> static int for_each_bad_bisect_ref(const char *submodule, each_ref_fn fn, void *cb_data)
> {
> - return for_each_ref_in_submodule(submodule, "refs/bisect/bad", fn, cb_data);
> + struct strbuf bisect_refs_buf = STRBUF_INIT;
> + const char *bisect_refs_str;
> + int status;
> + strbuf_addstr(&bisect_refs_buf, "refs/bisect/");
> + strbuf_addstr(&bisect_refs_buf, name_bad);A single strbuf_addf() rather than two strbuf_addstr()s?
> + bisect_refs_str = strbuf_detach(&bisect_refs_buf, NULL);
> + status = for_each_ref_in_submodule(submodule, bisect_refs_str, fn, cb_data);
> + free((char *)bisect_refs_str);
Why the above rather than the simpler?
strbuf_addstr(&bisect_refs, ...);
status = for_each_ref_in_submodule(submodule, bisect_refs.buf, fn, cb_data);
strbuf_release(&bisect_refs);What am I missing?
Show 14 quoted lines
> + return status;
> }
>
> static int for_each_good_bisect_ref(const char *submodule, each_ref_fn fn, void *cb_data)
> {
> - return for_each_ref_in_submodule(submodule, "refs/bisect/good", fn, cb_data);
> + struct strbuf bisect_refs_buf = STRBUF_INIT;
> + const char *bisect_refs_str;
> + int status;
> + strbuf_addstr(&bisect_refs_buf, "refs/bisect/");
> + strbuf_addstr(&bisect_refs_buf, name_bad);
> + bisect_refs_str = strbuf_detach(&bisect_refs_buf, NULL);
> + status = for_each_ref_in_submodule(submodule, bisect_refs_str, fn, cb_data);
> + free((char *)bisect_refs_str);> + return status;
> }