Subject: Re: [PATCH v10.1 5/7] bisect: simplify the addition of new bisect terms

From: Junio C Hamano <[email-masked]>
Date: Fri, 26 Jun 2015 14:27:57 -0700

Matthieu Moy <[email-masked]> writes:

> We do need two functions because we pass the pointer as callback, but
> it reads nicer with a third helper function.
>
> diff --git a/revision.c b/revision.c
> index 3ff8723..5cd08e9 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -21,6 +21,9 @@
>  
>  volatile show_early_output_fn_t show_early_output;
>  
> +static const char *name_bad;
> +static const char *name_good;
> +
> ...
> +
> +static int for_each_bisect_ref(const char *submodule, each_ref_fn fn, void *cb_data, const char *term) {
> +	struct strbuf bisect_refs = STRBUF_INIT;
> +	int status;
> +	strbuf_addf(&bisect_refs, "refs/bisect/%s", term);
> +	status = for_each_ref_in_submodule(submodule, bisect_refs.buf, fn, cb_data);
> +	strbuf_release(&bisect_refs);
> +	return status;
> +}
> +
>  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);
> +	return for_each_bisect_ref(submodule, fn, cb_data, "bad");
>  }

Shouldn't this be passing name_bad instead of "bad"?

>  
>  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);
> +	return for_each_bisect_ref(submodule, fn, cb_data, "good");
>  }

Likewise.