Re: [PATCH v2 05/11] bisect--helper: introduce new `decide_next()` function
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 30, 2020, 12:31 UTC
- Message-ID
- <nycvar.QRO.7.76.6.2001301330070.46@tvgsbejvaqbjf.bet>
- In-Reply-To
- <20200128144026.53128-6-mirucam@gmail.com>
Hi Miriam,
On Tue, 28 Jan 2020, Miriam Rubio wrote:
Show 51 quoted lines
> 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.
Thanks, Dscho
Show 10 quoted lines
> - 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) > >