refs: print errno for read_raw_ref if GIT_TRACE_REFS is set
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>
Han-Wen Nienhuys committed
Apr 12, 2021 at 19:32 UTC
2a2112a42913ee7397f950f3b8f9b3f3ab84a631
1 file changed
+4
-1
refs/debug.c
+4
-1
@@ -244,6 +244,7 @@ static int debug_read_raw_ref(struct ref_store *ref_store, const char *refname,
244
int res = 0;
245
246
oidcpy(oid, &null_oid);
247
+ errno = 0;
248
res = drefs->refs->be->read_raw_ref(drefs->refs, refname, oid, referent,
249
type);
250
@@ -251,7 +252,9 @@ static int debug_read_raw_ref(struct ref_store *ref_store, const char *refname,
252
trace_printf_key(&trace_refs, "read_raw_ref: %s: %s (=> %s) type %x: %d\n",
253
refname, oid_to_hex(oid), referent->buf, *type, res);
254
} else {
254
- trace_printf_key(&trace_refs, "read_raw_ref: %s: %d\n", refname, res);
255
+ trace_printf_key(&trace_refs,
256
+ "read_raw_ref: %s: %d (errno %d)\n", refname,
257
+ res, errno);
258
}
259
return res;
260
}