git/refs
Han-Wen Nienhuys 20d422cfd7 refs: remove EINVAL errno output from specification of read_raw_ref_fn
This commit does not change code; it documents the fact that an alternate ref
backend does not need to return EINVAL from read_raw_ref_fn to function
properly.

This is correct, because refs_read_raw_ref is only called from;

* resolve_ref_unsafe(), which does not care for the EINVAL errno result.

* refs_verify_refname_available(), which does not inspect errno.

* files-backend.c, where errno is overwritten on failure.

* packed-backend.c (is_packed_transaction_needed), which calls it for the
  packed ref backend, which never emits EINVAL.

A grep for EINVAL */*c reveals that no code checks errno against EINVAL after
reading references. In addition, the refs.h file does not mention errno at all.

A grep over resolve_ref_unsafe() turned up the following callers that inspect
errno:

* sequencer.c::print_commit_summary, which uses it for die_errno

* lock_ref_oid_basic(), which only treats EISDIR and ENOTDIR specially.

The files ref backend does use EINVAL. The files backend does not call into
the generic API (refs_read_raw), but into the files-specific function
(files_read_raw_ref), which we are not changing in this commit.

As the errno sideband is unintuitive and error-prone, remove EINVAL
value, as a step towards getting rid of the errno sideband altogether.

Spotted by Ævar Arnfjörð Bjarmason <avarab@gmail.com>.

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>
2021-08-25 13:30:26 -07:00
..
debug.c refs API: remove OID argument to reflog_expire() 2021-08-25 13:27:37 -07:00
files-backend.c refs file backend: move raceproof_create_file() here 2021-08-25 13:30:26 -07:00
iterator.c use CALLOC_ARRAY 2021-03-13 16:00:09 -08:00
packed-backend.c refs API: remove OID argument to reflog_expire() 2021-08-25 13:27:37 -07:00
packed-backend.h refs/packed-backend.h: add missing declaration (hdr-check) 2018-09-20 11:50:00 -07:00
ref-cache.c refs: make explicit that ref_iterator_peel returns boolean 2021-05-20 07:54:12 +09:00
ref-cache.h refs/ref-cache.h: add missing declarations (hdr-check) 2018-09-20 11:50:00 -07:00
refs-internal.h refs: remove EINVAL errno output from specification of read_raw_ref_fn 2021-08-25 13:30:26 -07:00