public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Jonas Rebmann <kernel@schlaraffenlan.de>,
	phillip.wood@dunelm.org.uk, 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 14:11:13 +0000	[thread overview]
Message-ID: <5e7aa1bb-1eb7-4b8c-8bd1-032be6a02a82@gmail.com> (raw)
In-Reply-To: <888f8670-856a-4ce7-8177-da78ba4f0c8a@schlaraffenlan.de>

Hi Jonas

On 24/03/2026 12:30, Jonas Rebmann wrote:
> 
> On 24/03/2026 11.49, Phillip Wood wrote:
>> 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.
> 
> My understanding of read_bisect_terms() was that it never sets the terms
> to NULL, that if no bisect is in progress, .git/BISECT_TERMS does not
> exist, and the terms default to "good"/"bad" here in bisect.c:
> 
>      if (errno == ENOENT) {
>          free(*read_bad);
>          *read_bad = xstrdup("bad");
>          free(*read_good);
>          *read_good = xstrdup("good");
>          return;
>      } else {
>          die_errno(_("could not read file '%s'"), filename);
>      }
> 
> So is a NULL-check really needed on caller end?

Oh, sorry I'd misread it, you're correct that we don't need a NULL 
check. Looking at the history of "git rev-parse --bisect" it was 
introduced in ad3f9a71a82 (Add '--bisect' revision machinery argument, 
2009-10-27) which also added a '--bisect' option to "git rev-list". 
Looking at the implementation of that option I wonder if we should make 
revision.c:for_each_bisect_ref() public and call it from 
builtin/rev-parse.c rather than building the refnames and calling 
refs_for_each_ref_ext().

Thanks

Phillip

> 
> Regards,
> Jonas


  reply	other threads:[~2026-03-24 14:11 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
2026-03-24 12:30     ` Jonas Rebmann
2026-03-24 14:11       ` Phillip Wood [this message]
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=5e7aa1bb-1eb7-4b8c-8bd1-032be6a02a82@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox