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

Re: [PATCH v2 2/2] rev-parse: use selected alternate terms too look up refs

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Mar 24, 2026, 14:11 UTC
Message-ID
<5e7aa1bb-1eb7-4b8c-8bd1-032be6a02a82@gmail.com>
In-Reply-To
<888f8670-856a-4ce7-8177-da78ba4f0c8a@schlaraffenlan.de>
Hi Jonas
On 24/03/2026 12:30, Jonas Rebmann wrote:
Show 21 quoted lines
> 
> 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
Previous: Jonas RebmannNext: Junio C Hamano
Message 8 of 9 in “Avoid hardcoded "good"/"bad" bisect terms”
  1. 0/2 Avoid hardcoded "good"/"bad" bisect termsJonas Rebmann, Mar 23, 2026
  2. 1/2 bisect: use selected alternate terms in status outputJonas Rebmann, Mar 23, 2026
  3. Phillip WoodMar 24, 2026
  4. Junio C HamanoMar 24, 2026
  5. 2/2 rev-parse: use selected alternate terms too look up refsJonas Rebmann, Mar 23, 2026
  6. Phillip WoodMar 24, 2026
  7. Jonas RebmannMar 24, 2026
  8. Phillip WoodMar 24, 2026
  9. Junio C HamanoMar 24, 2026

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.