From: Phillip Wood Date: Tue, 24 Mar 2026 10:49:32 GMT Subject: Re: [PATCH v2 2/2] rev-parse: use selected alternate terms too look up refs Message-ID: In-Reply-To: <20260323-bisect-terms-v2-2-8d6bdb2c9c7e@schlaraffenlan.de> Hi Jonas On 23/03/2026 22:49, Jonas Rebmann wrote: > An old/new bisect will name refs "refs/bisect/old" (or new) accordingly > so the hardcoded "refs/bisect/bad" (and good) yields no results in a > bisect using alternate terms. > > Use the current bisect_terms to make rev-parse --bisect work in an > alternate term bisect. It would be clearer if the commit message started by stating the problem that it is solving i.e. "git rev-parse --bisect" does not work if the bisect is using alternate term names. > > Signed-off-by: Jonas Rebmann > --- > builtin/rev-parse.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c > index 01a62800e8..f20f0554ed 100644 > --- a/builtin/rev-parse.c > +++ b/builtin/rev-parse.c > @@ -10,6 +10,7 @@ > #include "builtin.h" > > #include "abspath.h" > +#include "bisect.h" > #include "config.h" > #include "commit.h" > #include "environment.h" > @@ -940,11 +941,14 @@ int cmd_rev_parse(int argc, > continue; > } > if (!strcmp(arg, "--bisect")) { > + char *term_bad = NULL; > + char *term_good = NULL; > struct refs_for_each_ref_options opts = { 0 }; > - opts.prefix = "refs/bisect/bad"; > + read_bisect_terms(&term_bad, &term_good); If we fail to read the terms because there is no bisect in progress then term_bad and term_good will be NULL and so the next line will segfault. We should also free term_bad and term_good once we've finished with them to avoid a memory leak. It would be a good idea to add some tests. Thanks Phillip > + opts.prefix = xstrfmt("refs/bisect/%s", term_bad); > refs_for_each_ref_ext(get_main_ref_store(the_repository), > show_reference, NULL, &opts); > - opts.prefix = "refs/bisect/good"; > + opts.prefix = xstrfmt("refs/bisect/%s", term_good); > refs_for_each_ref_ext(get_main_ref_store(the_repository), > anti_reference, NULL, &opts); > continue; >