Merge branch 'bf/set-head-symref'
When "git fetch $remote" notices that refs/remotes/$remote/HEAD is missing and discovers what branch the other side points with its HEAD, refs/remotes/$remote/HEAD is updated to point to it. * bf/set-head-symref: fetch set_head: handle mirrored bare repositories fetch: set remote/HEAD if it does not exist refs: add create_only option to refs_update_symref_extended refs: add TRANSACTION_CREATE_EXISTS error remote set-head: better output for --auto remote set-head: refactor for readability refs: atomically record overwritten ref in update_symref refs: standardize output of refs_read_symbolic_ref t/t5505-remote: test failure of set-head t/t5505-remote: set default branch to main
This commit is contained in:
@@ -920,8 +920,12 @@ static int reftable_be_read_symbolic_ref(struct ref_store *ref_store,
|
||||
return ret;
|
||||
|
||||
ret = reftable_backend_read_ref(be, refname, &oid, referent, &type);
|
||||
if (type != REF_ISSYMREF)
|
||||
if (ret)
|
||||
ret = -1;
|
||||
else if (type == REF_ISSYMREF)
|
||||
; /* happy */
|
||||
else
|
||||
ret = NOT_A_SYMREF;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1328,10 +1332,13 @@ static int reftable_be_transaction_prepare(struct ref_store *ref_store,
|
||||
goto done;
|
||||
}
|
||||
} else if ((u->flags & REF_HAVE_OLD) && !oideq(¤t_oid, &u->old_oid)) {
|
||||
if (is_null_oid(&u->old_oid))
|
||||
ret = TRANSACTION_NAME_CONFLICT;
|
||||
if (is_null_oid(&u->old_oid)) {
|
||||
strbuf_addf(err, _("cannot lock ref '%s': "
|
||||
"reference already exists"),
|
||||
ref_update_original_update_refname(u));
|
||||
ret = TRANSACTION_CREATE_EXISTS;
|
||||
}
|
||||
else if (is_null_oid(¤t_oid))
|
||||
strbuf_addf(err, _("cannot lock ref '%s': "
|
||||
"reference is missing but expected %s"),
|
||||
@@ -1343,7 +1350,6 @@ static int reftable_be_transaction_prepare(struct ref_store *ref_store,
|
||||
ref_update_original_update_refname(u),
|
||||
oid_to_hex(¤t_oid),
|
||||
oid_to_hex(&u->old_oid));
|
||||
ret = -1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user