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

Re: [PATCH 2/2] config: fix evaluating "onbranch" with nonexistent git dir

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 24, 2024, 16:17 UTC
Message-ID
<xmqq7cb1vxee.fsf@gitster.g>
In-Reply-To
<535d0d07506e8248e47f90c1a7581679fc297b3d.1727171197.git.ps@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 20 quoted lines
> As the quoted comment mentions, we'd ideally refactor the code to not
> set up `gitdir` with an invalid value in the first place, but that may
> be a bigger undertaking. Instead, refactor the code to use the ref
> storage format as an indicator of whether or not the ref store has been
> set up to fix the bug.
>
> Reported-by: Ronan Pigott <ronan@rjp.ie>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> ...
> -	const char *refname = (!data->repo || !data->repo->gitdir) ?
> -		NULL : refs_resolve_ref_unsafe(get_main_ref_store(data->repo),
> -					       "HEAD", 0, NULL, &flags);
> -	const char *shortname;
> +	const char *refname, *shortname;
>  
> -	if (!refname || !(flags & REF_ISSYMREF)	||
> -			!skip_prefix(refname, "refs/heads/", &shortname))
> +	if (!data->repo || data->repo->ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)
> +		return 0;
OK.  A very direct check to see what we really care about.
Previous: shejialuoNext: shejialuo
Message 12 of 13 in “BUG: refs.c:1933: reference backend is unknown”
  1. Ronan PigottSep 20, 2024
  2. shejialuoSep 21, 2024
  3. Ronan PigottSep 21, 2024
  4. René ScharfeSep 21, 2024
  5. shejialuoSep 22, 2024
  6. shejialuoSep 22, 2024
  7. 0/2 config: fix evaluating "onbranch" with nonexistent git dirPatrick Steinhardt, Sep 24, 2024
  8. 1/2 t1305: exercise edge cases of "onbranch" includesPatrick Steinhardt, Sep 24, 2024
  9. Junio C HamanoSep 24, 2024
  10. 2/2 config: fix evaluating "onbranch" with nonexistent git dirPatrick Steinhardt, Sep 24, 2024
  11. shejialuoSep 24, 2024
  12. Junio C HamanoSep 24, 2024
  13. shejialuoSep 24, 2024

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.