All of lore.kernel.org
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Jonas Rebmann <kernel@schlaraffenlan.de>, git@vger.kernel.org
Cc: Chris Down <chris@chrisdown.name>, Jeff King <peff@peff.net>
Subject: Re: [PATCH v2 2/2] rev-parse: use selected alternate terms too look up refs
Date: Tue, 24 Mar 2026 10:49:32 +0000	[thread overview]
Message-ID: <d366fc82-efcc-46cb-9536-cd38b1fd18d4@gmail.com> (raw)
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 <kernel@schlaraffenlan.de>
> ---
>   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;
> 


  reply	other threads:[~2026-03-24 10:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-23 22:48 [PATCH v2 0/2] Avoid hardcoded "good"/"bad" bisect terms Jonas Rebmann
2026-03-23 22:48 ` [PATCH v2 1/2] bisect: use selected alternate terms in status output Jonas Rebmann
2026-03-24 10:43   ` Phillip Wood
2026-03-24 17:33     ` Junio C Hamano
2026-03-23 22:49 ` [PATCH v2 2/2] rev-parse: use selected alternate terms too look up refs Jonas Rebmann
2026-03-24 10:49   ` Phillip Wood [this message]
2026-03-24 12:30     ` Jonas Rebmann
2026-03-24 14:11       ` Phillip Wood
2026-03-24 13:45   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d366fc82-efcc-46cb-9536-cd38b1fd18d4@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=chris@chrisdown.name \
    --cc=git@vger.kernel.org \
    --cc=kernel@schlaraffenlan.de \
    --cc=peff@peff.net \
    --cc=phillip.wood@dunelm.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.