git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 1/3] refs: remove EINVAL specification from the errno sideband in read_raw_ref_fn

From
Han-Wen Nienhuys via GitGitGadget <gitgitgadget@gmail.com>
Date
Apr 23, 2021, 15:31 UTC
Message-ID
<7e8181e77d409af7595e357ad233b7781e026b78.1619191907.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1011.v2.git.git.1619191907.gitgitgadget@gmail.com>
From: Han-Wen Nienhuys <hanwen@google.com>

A grep for EINVAL */*c reveals that no code inspects EINVAL after reading references.

The files ref backend does use EINVAL so parse_loose_ref_contents() can communicate to lock_raw_ref() about garbage following the hex SHA1, or a short read in files_read_raw_ref(), but the files backend does not call into refs_read_raw_ref(), so its EINVAL sideband error is unused.

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>
---
 refs/refs-internal.h | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index 467f4b3c936d..29728a339fed 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -617,11 +617,10 @@ typedef int reflog_expire_fn(struct ref_store *ref_store,
  * properly-formatted or even safe reference name. NEITHER INPUT NOR
  * OUTPUT REFERENCE NAMES ARE VALIDATED WITHIN THIS FUNCTION.
  *
- * Return 0 on success. If the ref doesn't exist, set errno to ENOENT
- * and return -1. If the ref exists but is neither a symbolic ref nor
- * an object ID, it is broken; set REF_ISBROKEN in type, set errno to
- * EINVAL, and return -1. If there is another error reading the ref,
- * set errno appropriately and return -1.
+ * Return 0 on success. If the ref doesn't exist, set errno to ENOENT and return
+ * -1. If the ref exists but is neither a symbolic ref nor an object ID, it is
+ * broken; set REF_ISBROKEN in type, and return -1. If there is another error
+ * reading the ref, set errno appropriately and return -1.
  *
  * Backend-specific flags might be set in type as well, regardless of
  * outcome.
-- 
gitgitgadget
Previous: Han-Wen Nienhuys via GitGitGadgetNext: Han-Wen Nienhuys via GitGitGadget
Message 5 of 11 in “refs: remove EINVAL specification from the errno sideband in read_raw_ref_fn”
  1. refs: remove EINVAL specification from the errno sideband in read_raw_ref_fnHan-Wen Nienhuys via GitGitGadget, Apr 23, 2021
  2. Jeff KingApr 23, 2021
  3. Han-Wen NienhuysApr 23, 2021
  4. 0/3 refs: cleanup errno sideband ref related functions.Han-Wen Nienhuys via GitGitGadget, Apr 23, 2021
  5. 1/3 refs: remove EINVAL specification from the errno sideband in read_raw_ref_fnHan-Wen Nienhuys via GitGitGadget, Apr 23, 2021
  6. 2/3 refs/files-backend: stop setting errno from lock_ref_oid_basicHan-Wen Nienhuys via GitGitGadget, Apr 23, 2021
  7. Junio C HamanoApr 28, 2021
  8. Han-Wen NienhuysApr 28, 2021
  9. Junio C HamanoApr 29, 2021
  10. Han-Wen NienhuysApr 29, 2021
  11. 3/3 refs: make errno output explicit for read_raw_ref_fnHan-Wen Nienhuys via GitGitGadget, Apr 23, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.