git-commit-vandalism/refs
Han-Wen Nienhuys df3458e957 refs API: make parse_loose_ref_contents() not set errno
Change the parse_loose_ref_contents() function to stop setting "errno"
and failure, and to instead pass up a "failure_errno" via a
parameter. This requires changing its callers to do the same.

The EINVAL error from parse_loose_ref_contents is used in files-backend
to create a custom error message.

In untangling this we discovered a tricky edge case. The
refs_read_special_head() function was relying on
parse_loose_ref_contents() setting EINVAL.

By converting it to use "saved_errno" we can migrate away from "errno"
in this part of the code entirely, and do away with an existing
"save_errno" pattern, its only purpose was to not clobber the "errno"
we previously needed at the end of files_read_raw_ref().

Let's assert that we can do that by not having files_read_raw_ref()
itself operate on *failure_errno in addition to passing it on. Instead
we'll assert that if we return non-zero we actually do set errno, thus
assuring ourselves and callers that they can trust the resulting
"failure_errno".

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-10-16 11:17:02 -07:00
..
debug.c Merge branch 'hn/refs-errno-cleanup' 2021-10-03 21:49:18 -07:00
files-backend.c refs API: make parse_loose_ref_contents() not set errno 2021-10-16 11:17:02 -07:00
iterator.c use CALLOC_ARRAY 2021-03-13 16:00:09 -08:00
packed-backend.c refs API: make refs_read_raw_ref() not set errno 2021-10-16 11:17:02 -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/ref-cache.[ch]: remove "incomplete" from create_dir_entry() 2021-09-28 15:12:04 -07:00
ref-cache.h refs/ref-cache.[ch]: remove "incomplete" from create_dir_entry() 2021-09-28 15:12:04 -07:00
refs-internal.h refs API: make parse_loose_ref_contents() not set errno 2021-10-16 11:17:02 -07:00