git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 05/11] bisect--helper: introduce new `decide_next()` function

From
Miriam R. <mirucam@gmail.com>
Date
Jan 30, 2020, 14:05 UTC
Message-ID
<CAN7CjDBjJT30BrpWUnPOe-T7e3FkBohxxSP16PJvOF68quvw8A@mail.gmail.com>
In-Reply-To
<nycvar.QRO.7.76.6.2001301330070.46@tvgsbejvaqbjf.bet>
Hi,

El jue., 30 ene. 2020 a las 13:31, Johannes Schindelin (<Johannes.Schindelin@gmx.de>) escribió:

Show 61 quoted lines
>
> Hi Miriam,
>
> On Tue, 28 Jan 2020, Miriam Rubio wrote:
>
> > diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
> > index 21de5c096c..826fcba2ed 100644
> > --- a/builtin/bisect--helper.c
> > +++ b/builtin/bisect--helper.c
> > @@ -291,26 +291,14 @@ static const char need_bisect_start_warning[] =
> >          "You then need to give me at least one %s and %s revision.\n"
> >          "You can use \"git bisect %s\" and \"git bisect %s\" for that.");
> >
> > -static int bisect_next_check(const struct bisect_terms *terms,
> > -                          const char *current_term)
> > +static int decide_next(const struct bisect_terms *terms,
> > +                    const char *current_term, int missing_good,
> > +                    int missing_bad)
> >  {
> > -     int missing_good = 1, missing_bad = 1, res = 0;
> > -     const char *bad_ref = xstrfmt("refs/bisect/%s", terms->term_bad);
> > -     const char *good_glob = xstrfmt("%s-*", terms->term_good);
> > -
> > -     if (ref_exists(bad_ref))
> > -             missing_bad = 0;
> > -
> > -     for_each_glob_ref_in(mark_good, good_glob, "refs/bisect/",
> > -                          (void *) &missing_good);
> > -
> >       if (!missing_good && !missing_bad)
> > -             goto finish;
> > -
> > -     if (!current_term) {
> > -             res = -1;
> > -             goto finish;
> > -     }
> > +             return 0;
> > +     if (!current_term)
> > +             return -1;
> >  [...]
> > +
> > +static int bisect_next_check(const struct bisect_terms *terms,
> > +                          const char *current_term)
> > +{
> > +     int missing_good = 1, missing_bad = 1;
> > +     const char *bad_ref = xstrfmt("refs/bisect/%s", terms->term_bad);
> > +     const char *good_glob = xstrfmt("%s-*", terms->term_good);
> > +
> > +     if (ref_exists(bad_ref))
> > +             missing_bad = 0;
> > +
> > +     for_each_glob_ref_in(mark_good, good_glob, "refs/bisect/",
> > +                          (void *) &missing_good);
> > +
> >       free((void *) good_glob);
> >       free((void *) bad_ref);
>
> I know this is not something you introduced, but while you are already in
> the neighborhood, why not fix the types of `bad_ref` and `good_glob`? The
> `xstrfmt()` function returns `char *` for a reason: so that you do not
> have to cast it when `free()`ing the memory.

Sure! I will fix this. Thank you for reviewing. Best, Miriam

Show 14 quoted lines
>
> Thanks,
> Dscho
>
> > -     return res;
> > +
> > +     return decide_next(terms, current_term, missing_good, missing_bad);
> >  }
> >
> >  static int get_terms(struct bisect_terms *terms)
> > --
> > 2.21.1 (Apple Git-122.3)
> >
> >
Previous: Johannes SchindelinNext: Miriam Rubio
Message 9 of 29 in “Finish converting git bisect to C part 1”
  1. Miriam RubioJan 28, 2020
  2. 01/11 bisect--helper: convert `vocab_*` char pointers to char arraysMiriam Rubio, Jan 28, 2020
  3. 02/11 bisect--helper: change `retval` to `res`Miriam Rubio, Jan 28, 2020
  4. 03/11 bisect: use the standard 'if (!var)' way to check for 0Miriam Rubio, Jan 28, 2020
  5. 04/11 run-command: make `exists_in_PATH()` non-staticMiriam Rubio, Jan 28, 2020
  6. Johannes SchindelinJan 30, 2020
  7. 05/11 bisect--helper: introduce new `decide_next()` functionMiriam Rubio, Jan 28, 2020
  8. Johannes SchindelinJan 30, 2020
  9. Miriam R.Jan 30, 2020
  10. 06/11 bisect: libify `exit_if_skipped_commits` to `error_if_skipped*` and its dependentsMiriam Rubio, Jan 28, 2020
  11. Junio C HamanoJan 31, 2020
  12. 07/11 bisect: libify `bisect_checkout`Miriam Rubio, Jan 28, 2020
  13. Junio C HamanoJan 31, 2020
  14. 08/11 bisect: libify `check_merge_bases` and its dependentsMiriam Rubio, Jan 28, 2020
  15. Junio C HamanoJan 31, 2020
  16. 11/11 bisect: libify `bisect_next_all`Miriam Rubio, Jan 28, 2020
  17. 10/11 bisect: libify `handle_bad_merge_base` and its dependentsMiriam Rubio, Jan 28, 2020
  18. 09/11 bisect: libify `check_good_are_ancestors_of_bad` and its dependentsMiriam Rubio, Jan 28, 2020
  19. Johannes SchindelinJan 30, 2020
  20. Miriam R.Jan 30, 2020
  21. Johannes SchindelinJan 30, 2020
  22. Miriam R.Jan 30, 2020
  23. Christian CouderJan 30, 2020
  24. Johannes SchindelinJan 31, 2020
  25. Christian CouderJan 31, 2020
  26. Johannes SchindelinJan 30, 2020
  27. Miriam R.Jan 30, 2020
  28. Fwd: [PATCH v2 04/11] run-command: make `exists_in_PATH()` non-staticMiriam R., Jan 30, 2020
  29. Fwd: [PATCH v2 09/11] bisect: libify `check_good_are_ancestors_of_bad` and its dependentsMiriam R., Jan 31, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.