* This backend uses the following flags in `ref_update::flags` for
* internal bookkeeping purposes. Their numerical values must not
* conflict with REF_NO_DEREF, REF_FORCE_CREATE_REFLOG, REF_HAVE_NEW,
- * REF_HAVE_OLD, or REF_ISPRUNING, which are also stored in
+ * REF_HAVE_OLD, or REF_IS_PRUNING, which are also stored in
* `ref_update::flags`.
*/
* Used as a flag in ref_update::flags when a loose ref is being
* pruned. This flag must only be used when REF_NO_DEREF is set.
*/
-#define REF_ISPRUNING (1 << 4)
+#define REF_IS_PRUNING (1 << 4)
/*
* Flag passed to lock_ref_sha1_basic() telling it to tolerate broken
} else if (is_null_oid(&oid)) {
/*
* It is so astronomically unlikely
- * that NULL_SHA1 is the SHA-1 of an
+ * that null_oid is the OID of an
* actual object that we consider its
* appearance in a loose reference
* file to be repo corruption
* are passed to refs_verify_refname_available() for this check.
*
* If mustexist is not set and the reference is not found or is
- * broken, lock the reference anyway but clear sha1.
+ * broken, lock the reference anyway but clear old_oid.
*
* Return 0 on success. On failure, write an error message to err and
* return TRANSACTION_NAME_CONFLICT or TRANSACTION_GENERIC_ERROR.
goto cleanup;
ref_transaction_add_update(
transaction, r->name,
- REF_NO_DEREF | REF_HAVE_NEW | REF_HAVE_OLD | REF_ISPRUNING,
+ REF_NO_DEREF | REF_HAVE_NEW | REF_HAVE_OLD | REF_IS_PRUNING,
&null_oid, &r->oid, NULL);
if (ref_transaction_commit(transaction, &err))
goto cleanup;
}
/*
- * Write sha1 into the open lockfile, then close the lockfile. On
- * errors, rollback the lockfile, fill in *err and
- * return -1.
+ * Write oid into the open lockfile, then close the lockfile. On
+ * errors, rollback the lockfile, fill in *err and return -1.
*/
static int write_ref_to_lockfile(struct ref_lock *lock,
const struct object_id *oid, struct strbuf *err)
struct ref_update *new_update;
if ((update->flags & REF_LOG_ONLY) ||
- (update->flags & REF_ISPRUNING) ||
+ (update->flags & REF_IS_PRUNING) ||
(update->flags & REF_UPDATE_VIA_HEAD))
return 0;
/*
* Change the symbolic ref update to log only. Also, it
- * doesn't need to check its old SHA-1 value, as that will be
+ * doesn't need to check its old OID value, as that will be
* done when new_update is processed.
*/
update->flags |= REF_LOG_ONLY | REF_NO_DEREF;
* Prepare for carrying out update:
* - Lock the reference referred to by update.
* - Read the reference under lock.
- * - Check that its old SHA-1 value (if specified) is correct, and in
+ * - Check that its old OID value (if specified) is correct, and in
* any case record it in update->lock->old_oid for later use when
* writing the reflog.
* - If it is a symref update without REF_NO_DEREF, split it up into a
/*
* We won't be reading the referent as part of
* the transaction, so we have to read it here
- * to record and possibly check old_sha1:
+ * to record and possibly check old_oid:
*/
if (refs_read_ref_full(&refs->base,
referent.buf, 0,
/*
* Create a new update for the reference this
* symref is pointing at. Also, we will record
- * and verify old_sha1 for this update as part
+ * and verify old_oid for this update as part
* of processing the split-off update, so we
* don't have to do it here.
*/
/*
* If this update is happening indirectly because of a
- * symref update, record the old SHA-1 in the parent
+ * symref update, record the old OID in the parent
* update:
*/
for (parent_update = update->parent_update;
* split_symref_update() or split_head_update(), those
* functions will check that the new updates don't have the
* same refname as any existing ones.) Also fail if any of the
- * updates use REF_ISPRUNING without REF_NO_DEREF.
+ * updates use REF_IS_PRUNING without REF_NO_DEREF.
*/
for (i = 0; i < transaction->nr; i++) {
struct ref_update *update = transaction->updates[i];
struct string_list_item *item =
string_list_append(&affected_refnames, update->refname);
- if ((update->flags & REF_ISPRUNING) &&
+ if ((update->flags & REF_IS_PRUNING) &&
!(update->flags & REF_NO_DEREF))
- BUG("REF_ISPRUNING set without REF_NO_DEREF");
+ BUG("REF_IS_PRUNING set without REF_NO_DEREF");
/*
* We store a pointer to update in item->util, but at
if (update->flags & REF_DELETING &&
!(update->flags & REF_LOG_ONLY) &&
- !(update->flags & REF_ISPRUNING)) {
+ !(update->flags & REF_IS_PRUNING)) {
/*
* This reference has to be deleted from
* packed-refs if it exists there.
goto cleanup;
}
backend_data->packed_refs_locked = 1;
- ret = ref_transaction_prepare(packed_transaction, err);
+
+ if (is_packed_transaction_needed(refs->packed_ref_store,
+ packed_transaction)) {
+ ret = ref_transaction_prepare(packed_transaction, err);
+ } else {
+ /*
+ * We can skip rewriting the `packed-refs`
+ * file. But we do need to leave it locked, so
+ * that somebody else doesn't pack a reference
+ * that we are trying to delete.
+ */
+ if (ref_transaction_abort(packed_transaction, err)) {
+ ret = TRANSACTION_GENERIC_ERROR;
+ goto cleanup;
+ }
+ backend_data->packed_transaction = NULL;
+ }
}
cleanup:
struct ref_update *update = transaction->updates[i];
if (update->flags & REF_DELETING &&
!(update->flags & REF_LOG_ONLY) &&
- !(update->flags & REF_ISPRUNING)) {
+ !(update->flags & REF_IS_PRUNING)) {
strbuf_reset(&sb);
files_reflog_path(refs, &sb, update->refname);
if (!unlink_or_warn(sb.buf))