@@ -108,7 +108,7 @@ static const char *bare_ref_name(const char *ref)
static int git_reftable_read_raw_ref(struct ref_store *ref_store,
const char *refname, struct object_id *oid,
struct strbuf *referent,
- unsigned int *type);
+ unsigned int *type, int *failure_errno);
static void clear_reftable_log_record(struct reftable_log_record *log)
{
@@ -424,6 +424,7 @@ static int fixup_symrefs(struct ref_store *ref_store,
struct strbuf referent = STRBUF_INIT;
int i = 0;
int err = 0;
+ int failure_errno;
for (i = 0; i < transaction->nr; i++) {
struct ref_update *update = transaction->updates[i];
@@ -433,8 +434,8 @@ static int fixup_symrefs(struct ref_store *ref_store,
&old_oid, &referent,
/* mutate input, like
files-backend.c */
- &update->type);
- if (err < 0 && errno == ENOENT &&
+ &update->type, &failure_errno);
+ if (err < 0 && failure_errno == ENOENT &&
is_null_oid(&update->old_oid)) {
err = 0;
}
@@ -1587,30 +1588,10 @@ git_reftable_reflog_expire(struct ref_store *ref_store, const char *refname,
return err;
}
-static int reftable_error_to_errno(int err)
-{
- switch (err) {
- case REFTABLE_IO_ERROR:
- return EIO;
- case REFTABLE_FORMAT_ERROR:
- return EFAULT;
- case REFTABLE_NOT_EXIST_ERROR:
- return ENOENT;
- case REFTABLE_LOCK_ERROR:
- return EBUSY;
- case REFTABLE_API_ERROR:
- return EINVAL;
- case REFTABLE_ZLIB_ERROR:
- return EDOM;
- default:
- return ERANGE;
- }
-}
-
static int git_reftable_read_raw_ref(struct ref_store *ref_store,
const char *refname, struct object_id *oid,
struct strbuf *referent,
- unsigned int *type)
+ unsigned int *type, int *failure_errno)
{
struct git_reftable_ref_store *refs =
(struct git_reftable_ref_store *)ref_store;
@@ -1633,13 +1614,10 @@ static int git_reftable_read_raw_ref(struct ref_store *ref_store,
}
err = reftable_stack_read_ref(stack, refname, &ref);
- if (err > 0) {
- errno = ENOENT;
- err = -1;
- goto done;
- }
if (err < 0) {
- errno = reftable_error_to_errno(err);
+ goto done;
+ } else if (err) {
+ *failure_errno = ENOENT;
err = -1;
goto done;
}