aboutsummaryrefslogtreecommitdiffstats
path: root/refs.c
diff options
context:
space:
mode:
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c30
1 files changed, 8 insertions, 22 deletions
diff --git a/refs.c b/refs.c
index 0b79bdd7c3..90bcb27168 100644
--- a/refs.c
+++ b/refs.c
@@ -794,7 +794,7 @@ int refs_delete_ref(struct ref_store *refs, const char *msg,
struct ref_transaction *transaction;
struct strbuf err = STRBUF_INIT;
- transaction = ref_store_transaction_begin(refs, 0, &err);
+ transaction = ref_store_transaction_begin(refs, &err);
if (!transaction ||
ref_transaction_delete(transaction, refname, old_oid,
flags, msg, &err) ||
@@ -999,7 +999,6 @@ int read_ref_at(struct ref_store *refs, const char *refname,
}
struct ref_transaction *ref_store_transaction_begin(struct ref_store *refs,
- unsigned int flags,
struct strbuf *err)
{
struct ref_transaction *tr;
@@ -1007,13 +1006,12 @@ struct ref_transaction *ref_store_transaction_begin(struct ref_store *refs,
CALLOC_ARRAY(tr, 1);
tr->ref_store = refs;
- tr->flags = flags;
return tr;
}
struct ref_transaction *ref_transaction_begin(struct strbuf *err)
{
- return ref_store_transaction_begin(get_main_ref_store(the_repository), 0, err);
+ return ref_store_transaction_begin(get_main_ref_store(the_repository), err);
}
void ref_transaction_free(struct ref_transaction *transaction)
@@ -1111,8 +1109,10 @@ int ref_transaction_create(struct ref_transaction *transaction,
unsigned int flags, const char *msg,
struct strbuf *err)
{
- if (!new_oid || is_null_oid(new_oid))
- BUG("create called without valid new_oid");
+ if (!new_oid || is_null_oid(new_oid)) {
+ strbuf_addf(err, "'%s' has a null OID", refname);
+ return 1;
+ }
return ref_transaction_update(transaction, refname, new_oid,
null_oid(), flags, msg, err);
}
@@ -1152,7 +1152,7 @@ int refs_update_ref(struct ref_store *refs, const char *msg,
struct strbuf err = STRBUF_INIT;
int ret = 0;
- t = ref_store_transaction_begin(refs, 0, &err);
+ t = ref_store_transaction_begin(refs, &err);
if (!t ||
ref_transaction_update(t, refname, new_oid, old_oid, flags, msg,
&err) ||
@@ -1676,18 +1676,7 @@ int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,
int refs_read_symbolic_ref(struct ref_store *ref_store, const char *refname,
struct strbuf *referent)
{
- struct object_id oid;
- int ret, failure_errno = 0;
- unsigned int type = 0;
-
- if (ref_store->be->read_symbolic_ref)
- return ref_store->be->read_symbolic_ref(ref_store, refname, referent);
-
- ret = refs_read_raw_ref(ref_store, refname, &oid, referent, &type, &failure_errno);
- if (ret || !(type & REF_ISSYMREF))
- return -1;
-
- return 0;
+ return ref_store->be->read_symbolic_ref(ref_store, refname, referent);
}
const char *refs_resolve_ref_unsafe(struct ref_store *refs,
@@ -2085,9 +2074,6 @@ static int run_transaction_hook(struct ref_transaction *transaction,
const char *hook;
int ret = 0, i;
- if (transaction->flags & REF_TRANSACTION_SKIP_HOOK)
- return 0;
-
hook = find_hook("reference-transaction");
if (!hook)
return ret;