Skip to content

refs: cleanup errno sideband ref related functions

Han-Wen Nienhuys via GitGitGadget git 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest6 patches 7 repliesIn review
  2. v46 patches 3 repliesSuperseded
  3. v35 patches 5 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v28 patches13 repliesSuperseded
v18 patches21 repliesSuperseded

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6refs: remove EINVAL errno output from specification of read_raw_ref_fnrefs/refs-internal.h+3 -30 replies
2/6refs/files-backend: stop setting errno from lock_ref_oid_basicrefs/files-backend.c+6 -102 replies
3/6refs: make errno output explicit for read_raw_ref_fnrefs.c refs/debug.c refs/files-backend.c +2 more+37 -281 reply
4/6refs: add failure_errno to refs_read_raw_ref() signaturerefs.c refs/files-backend.c refs/packed-backend.c +1 more+48 -332 replies
5/6refs: explicitly return failure_errno from parse_loose_ref_contentsrefs.c refs/files-backend.c refs/refs-internal.h+19 -91 reply
6/6refs: make errno output explicit for refs_resolve_ref_unsaferefs/files-backend.c refs/refs-internal.h+16 -70 replies

Reviews trailers per patch

5 of 6 patches have a Reviewed-by or Acked-by.

PatchÆvar Arnfjörð Bjarmason
1/6
2/6R-b
3/6R-b
4/6R-b
5/6R-b
6/6R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH v5 0/6] refs: cleanup errno sideband ref related functions

v5

* address Ævar's comment; punt on clearing errno.

Han-Wen Nienhuys (6):
refs: remove EINVAL errno output from specification of read_raw_ref_fn refs/files-backend: stop setting errno from lock_ref_oid_basic
refs: make errno output explicit for read_raw_ref_fn
refs: add failure_errno to refs_read_raw_ref() signature
refs: explicitly return failure_errno from parse_loose_ref_contents
refs: make errno output explicit for refs_resolve_ref_unsafe

 refs.c                | 58 ++++++++++++++++++++++-----------
 refs/debug.c          |  4 +--
 refs/files-backend.c  | 74 ++++++++++++++++++++++---------------------
 refs/packed-backend.c | 15 +++++----
 refs/refs-internal.h  | 40 +++++++++++++++--------
 5 files changed, 115 insertions(+), 76 deletions(-)

base-commit: 670b81a890388c60b7032a4f5b879f2ece8c4558
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1012%2Fhanwen%2Feinval-sideband-v5
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1012/hanwen/einval-sideband-v5
Pull-Request: https://github.com/git/git/pull/1012

Range-diff vs v4:

 1:  d6a41c3c0cb = 1:  d6a41c3c0cb refs: remove EINVAL errno output from specification of read_raw_ref_fn
 2:  ff7ea6efcba ! 2:  95025080c16 refs/files-backend: stop setting errno from lock_ref_oid_basic

@@ Commit message
documented to use and/or preserve errno)

- Reviewed-By: Ævar Arnfjörð Bjarmason <[email protected]>
+ Reviewed-by: Ævar Arnfjörð Bjarmason <[email protected]>

## refs/files-backend.c ##
@@ refs/files-backend.c: static int create_reflock(const char *path, void *cb)
3: ff5696b0875 ! 3: 7feedb97201 refs: make errno output explicit for read_raw_ref_fn
@@ Commit message
relevant.

- Reviewed-By: Ævar Arnfjörð Bjarmason <[email protected]>
+ Reviewed-by: Ævar Arnfjörð Bjarmason <[email protected]>

## refs.c ##
@@ refs.c: int refs_read_raw_ref(struct ref_store *ref_store,
4: 9c933706cb0 ! 4: ef91f5cee13 refs: add failure_errno to refs_read_raw_ref() signature

     @@ Commit message
          This lets us use the explicit errno output parameter in refs_resolve_ref_unsafe.
      
          Signed-off-by: Han-Wen Nienhuys <[email protected]>
     -    Reviewed-By: Ævar Arnfjörð Bjarmason <[email protected]>
     +    Reviewed-by: Ævar Arnfjörð Bjarmason <[email protected]>
      
       ## refs.c ##
      @@ refs.c: done:
     @@ refs.c: done:
      -int refs_read_raw_ref(struct ref_store *ref_store,
      -		      const char *refname, struct object_id *oid,
      -		      struct strbuf *referent, unsigned int *type)
     +-{
     +-	int result;
     +-	int failure_errno;
      +int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,
      +		      struct object_id *oid, struct strbuf *referent,
      +		      unsigned int *type, int *failure_errno)
     - {
     --	int result;
     --	int failure_errno;
     -+	int ignore;
     -+	if (failure_errno)
     -+		*failure_errno = 0;
     -+	else
     -+		failure_errno = &ignore;
     -+
     ++{
     ++	int unused_errno;
     ++	if (!failure_errno)
     ++		failure_errno = &unused_errno;
     ++	*failure_errno = 0;
       	if (!strcmp(refname, "FETCH_HEAD") || !strcmp(refname, "MERGE_HEAD")) {
       		return refs_read_special_head(ref_store, refname, oid, referent,
       					      type);

5: ab147afb38d ! 5: 6918c214d1b refs: explicitly return failure_errno from parse_loose_ref_contents
@@ Commit message
to create a custom error message.

- Reviewed-By: Ævar Arnfjörð Bjarmason <[email protected]>
+ Reviewed-by: Ævar Arnfjörð Bjarmason <[email protected]>

## refs.c ##
@@ refs.c: int for_each_fullref_in_prefixes(const char *namespace,
@@ refs.c: static int refs_read_special_head(struct ref_store *ref_store,
done:
strbuf_release(&full_path);
@@ refs.c: int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,
-
+ *failure_errno = 0;
if (!strcmp(refname, "FETCH_HEAD") || !strcmp(refname, "MERGE_HEAD")) {
return refs_read_special_head(ref_store, refname, oid, referent,
- type);
@@ refs/files-backend.c: stat_ref:
+ ret = parse_loose_ref_contents(buf, oid, referent, type, failure_errno);
+ errno = *failure_errno;
out:
-+ /* Collect all types of failures from errno. Many system calls in this
-+ * function can fail with ENOTDIR/EISDIR, and we want to collect all of
-+ * them.
++ /*
++ * Many system calls in this function can fail with ENOTDIR/EISDIR, and
++ * we want to collect all of them, so simply copy the error out from
++ * errno.
+ */
*failure_errno = errno;
strbuf_release(&sb_path);
6: 0526a41b4b3 ! 6: 85a14bde904 refs: make errno output explicit for refs_resolve_ref_unsafe
@@ Commit message
that needs error information to make logic decisions, so update that caller

- Reviewed-By: Ævar Arnfjörð Bjarmason <[email protected]>
+ Reviewed-by: Ævar Arnfjörð Bjarmason <[email protected]>

## refs/files-backend.c ##
@@ refs/files-backend.c: static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs,

Signature · 1 line
gitgitgadget