From: Christian Couder Date: Fri, 26 Jun 2015 19:22:26 GMT Subject: Re: [PATCH v10 5/7] bisect: simplify the addition of new bisect terms Message-ID: In-Reply-To: <1435337896-20709-6-git-send-email-Matthieu.Moy@imag.fr> On Fri, Jun 26, 2015 at 6:58 PM, Matthieu Moy wrote: > > 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 = STRBUF_INIT; > + int status; > + strbuf_addf(&bisect_refs, "refs/bisect/%s", name_bad); > + status = for_each_ref_in_submodule(submodule, bisect_refs.buf, fn, cb_data); > + strbuf_release(&bisect_refs); > + 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 = STRBUF_INIT; > + int status; > + strbuf_addf(&bisect_refs, "refs/bisect/%s", name_good); > + status = for_each_ref_in_submodule(submodule, bisect_refs.buf, fn, cb_data); > + strbuf_release(&bisect_refs); > + return status; > } I wonder if it would not be better to just have: static int for_each_bisect_ref(const char *submodule, each_ref_fn fn, const char *term, void *cb_data) { 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; } This way it can be used with either name_good, name_bad or "skip" as the term argument.