git/refs
Patrick Steinhardt b0f6b6b523 refs/reftable: don't fail empty transactions in repo without HEAD
Under normal circumstances, it shouldn't ever happen that a repository
has no HEAD reference. In fact, git-update-ref(1) would fail any request
to delete the HEAD reference, and a newly initialized repository always
pre-creates it, too.

We have however changed git-clone(1) to partially initialize the
refdb just up to the point where remote helpers can find the
repository. With that change, we are going to run into a situation
where repositories have no refs at all.

Now there is a very particular edge case in this situation: when
preparing an empty ref transacton, we end up returning whatever value
`read_ref_without_reload()` returned to the caller. Under normal
conditions this would be fine: "HEAD" should usually exist, and thus the
function would return `0`. But if "HEAD" doesn't exist, the function
returns a positive value which we end up returning to the caller.

Fix this bug by resetting the return code to `0` and add a test.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-27 13:53:39 -08:00
..
debug.c refs: prepare `refs_init_db()` for initializing worktree refs 2024-01-08 13:17:30 -08:00
files-backend.c Merge branch 'ps/worktree-refdb-initialization' 2024-01-26 08:54:46 -08:00
iterator.c
packed-backend.c Merge branch 'ps/worktree-refdb-initialization' 2024-01-26 08:54:46 -08:00
packed-backend.h
ref-cache.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
ref-cache.h
refs-internal.h refs: introduce reftable backend 2024-02-07 08:28:37 -08:00
reftable-backend.c refs/reftable: don't fail empty transactions in repo without HEAD 2024-02-27 13:53:39 -08:00