]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs: print errno for read_raw_ref if GIT_TRACE_REFS is set
authorHan-Wen Nienhuys <hanwen@google.com>
Mon, 12 Apr 2021 19:32:34 +0000 (19:32 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 12 Apr 2021 21:42:37 +0000 (14:42 -0700)
The ref backend API uses errno as a sideband error channel.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs/debug.c

index 922e64fa6ad91bef44aa714e479c9281dce4b6c9..576bf98e74aeb746c0b174eb1eb033e9d2082a77 100644 (file)
@@ -244,6 +244,7 @@ static int debug_read_raw_ref(struct ref_store *ref_store, const char *refname,
        int res = 0;
 
        oidcpy(oid, &null_oid);
+       errno = 0;
        res = drefs->refs->be->read_raw_ref(drefs->refs, refname, oid, referent,
                                            type);
 
@@ -251,7 +252,9 @@ static int debug_read_raw_ref(struct ref_store *ref_store, const char *refname,
                trace_printf_key(&trace_refs, "read_raw_ref: %s: %s (=> %s) type %x: %d\n",
                        refname, oid_to_hex(oid), referent->buf, *type, res);
        } else {
-               trace_printf_key(&trace_refs, "read_raw_ref: %s: %d\n", refname, res);
+               trace_printf_key(&trace_refs,
+                                "read_raw_ref: %s: %d (errno %d)\n", refname,
+                                res, errno);
        }
        return res;
 }