Thread (11 messages) flat view 11 messages, 2 authors, 2016-06-15

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

From: Christian Couder <hidden>
Date: 2016-06-15 23:05:33

On Fri, Jun 26, 2015 at 6:58 PM, Matthieu Moy [off-list ref] 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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help