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

Re: [PATCH] refs: don't clear oid before read_raw_ref in the debug ref backend

From
Patrick Steinhardt <ps@pks.im>
Date
Oct 31, 2025, 06:48 UTC
Message-ID
<aQRbygXjkffQoNPi@pks.im>
In-Reply-To
<pull.2089.git.git.1761881825025.gitgitgadget@gmail.com>
On Fri, Oct 31, 2025 at 03:37:05AM +0000, Xinyu Ruan via GitGitGadget wrote:
Show 5 quoted lines
> From: Xinyu Ruan <r200981113@gmail.com>
> 
> The debug_read_raw_ref function clears the oid to null_oid before
> calling read_raw_ref, which causes the oid to be lost even when
> read_raw_ref successfully reads the reference.

This sentence doesn't quite make sense to me. If `read_raw_ref()` succeeds, wouldn't we expect that the OID was set to the target's object ID anyway? So why does it hurt to set the object ID to the null ID if it's going to get rewritten anyway?

Another question is why we were setting it to the null OID in the first place. Ideally, this should be discussed in the commit message.

> This leads to failures
> when executing commands like "git branch new_branch <commit_id>" with
> GIT_TRACE_REFS=1, as the command cannot find a valid branch point
> because the oid is null.

This smells like an issue that can be be demonstrated via a unit test. Right now though we got zero testing for `GIT_TRACE_REFS` in our test suite. Maybe this could be used as a starting point for a new test suite "t0620-ref-debug.sh" that exercises the different callbacks?

Thanks!
Patrick
Previous: Xinyu Ruan via GitGitGadget
Message 2 of 2 in “refs: don't clear oid before read_raw_ref in the debug ref backend”
  1. refs: don't clear oid before read_raw_ref in the debug ref backendXinyu Ruan via GitGitGadget, Oct 31, 2025
  2. Patrick SteinhardtOct 31, 2025

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.