* [PATCH] refs: don't clear oid before read_raw_ref in the debug ref backend
@ 2025-10-31 3:37 Xinyu Ruan via GitGitGadget
2025-10-31 6:48 ` Patrick Steinhardt
0 siblings, 1 reply; 2+ messages in thread
From: Xinyu Ruan via GitGitGadget @ 2025-10-31 3:37 UTC (permalink / raw)
To: git; +Cc: Xinyu Ruan, Xinyu Ruan
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 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.
Signed-off-by: Xinyu Ruan <r200981113@gmail.com>
---
refs: don't clear oid before read_raw_ref in the debug ref backend
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2089%2FRuanXinyu%2Fref-debug-disable-clear-oid-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2089/RuanXinyu/ref-debug-disable-clear-oid-v1
Pull-Request: https://github.com/git/git/pull/2089
refs/debug.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/refs/debug.c b/refs/debug.c
index 697adbd0dc..c8dde3558d 100644
--- a/refs/debug.c
+++ b/refs/debug.c
@@ -227,7 +227,6 @@ static int debug_read_raw_ref(struct ref_store *ref_store, const char *refname,
struct debug_ref_store *drefs = (struct debug_ref_store *)ref_store;
int res = 0;
- oidcpy(oid, null_oid(ref_store->repo->hash_algo));
res = drefs->refs->be->read_raw_ref(drefs->refs, refname, oid, referent,
type, failure_errno);
base-commit: a99f379adf116d53eb11957af5bab5214915f91d
--
gitgitgadget
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] refs: don't clear oid before read_raw_ref in the debug ref backend
2025-10-31 3:37 [PATCH] refs: don't clear oid before read_raw_ref in the debug ref backend Xinyu Ruan via GitGitGadget
@ 2025-10-31 6:48 ` Patrick Steinhardt
0 siblings, 0 replies; 2+ messages in thread
From: Patrick Steinhardt @ 2025-10-31 6:48 UTC (permalink / raw)
To: Xinyu Ruan via GitGitGadget; +Cc: git, Xinyu Ruan
On Fri, Oct 31, 2025 at 03:37:05AM +0000, Xinyu Ruan via GitGitGadget wrote:
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-31 6:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-31 3:37 [PATCH] refs: don't clear oid before read_raw_ref in the debug ref backend Xinyu Ruan via GitGitGadget
2025-10-31 6:48 ` Patrick Steinhardt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).