]> git.ipfire.org Git - thirdparty/git.git/commit
refs: make errno output explicit for read_raw_ref_fn
authorHan-Wen Nienhuys <hanwen@google.com>
Mon, 23 Aug 2021 11:52:40 +0000 (13:52 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Aug 2021 20:30:26 +0000 (13:30 -0700)
commit5b12e16bb134969747eaa983ab8d83d57f41e960
treea857828ceefcfba2e3710a3de9f019f1c9b8744f
parent1ae6ed230ae696ceb7c4607e00d94642b416ea1c
refs: make errno output explicit for read_raw_ref_fn

This makes it explicit how alternative ref backends should report errors in
read_raw_ref_fn.

read_raw_ref_fn needs to supply a credible errno for a number of cases. These
are primarily:

1) The files backend calls read_raw_ref from lock_raw_ref, and uses the
resulting error codes to create/remove directories as needed.

2) ENOENT should be translated in a zero OID, optionally with REF_ISBROKEN set,
returning the last successfully resolved symref. This is necessary so
read_raw_ref("HEAD") on an empty repo returns refs/heads/main (or the default branch
du-jour), and we know on which branch to create the first commit.

Make this information flow explicit by adding a failure_errno to the signature
of read_raw_ref. All errnos from the files backend are still propagated
unchanged, even though inspection suggests only ENOTDIR, EISDIR and ENOENT are
relevant.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
refs/debug.c
refs/files-backend.c
refs/packed-backend.c
refs/refs-internal.h