Merge branch 'kn/update-ref-symref'
"git update-ref --stdin" learned to handle transactional updates of symbolic-refs. * kn/update-ref-symref: update-ref: add support for 'symref-update' command reftable: pick either 'oid' or 'target' for new updates update-ref: add support for 'symref-create' command update-ref: add support for 'symref-delete' command update-ref: add support for 'symref-verify' command refs: specify error for regular refs with `old_target` refs: create and use `ref_update_expects_existing_old_ref()`
This commit is contained in:
@ -934,7 +934,7 @@ static int reftable_be_transaction_prepare(struct ref_store *ref_store,
|
||||
¤t_oid, &referent, &u->type);
|
||||
if (ret < 0)
|
||||
goto done;
|
||||
if (ret > 0 && (!(u->flags & REF_HAVE_OLD) || is_null_oid(&u->old_oid))) {
|
||||
if (ret > 0 && !ref_update_expects_existing_old_ref(u)) {
|
||||
/*
|
||||
* The reference does not exist, and we either have no
|
||||
* old object ID or expect the reference to not exist.
|
||||
@ -1005,8 +1005,9 @@ static int reftable_be_transaction_prepare(struct ref_store *ref_store,
|
||||
*/
|
||||
new_update = ref_transaction_add_update(
|
||||
transaction, referent.buf, new_flags,
|
||||
&u->new_oid, &u->old_oid, u->new_target,
|
||||
u->old_target, u->msg);
|
||||
u->new_target ? NULL : &u->new_oid,
|
||||
u->old_target ? NULL : &u->old_oid,
|
||||
u->new_target, u->old_target, u->msg);
|
||||
|
||||
new_update->parent_update = u;
|
||||
|
||||
@ -1038,6 +1039,16 @@ static int reftable_be_transaction_prepare(struct ref_store *ref_store,
|
||||
* backend returns, which keeps our tests happy.
|
||||
*/
|
||||
if (u->old_target) {
|
||||
if (!(u->type & REF_ISSYMREF)) {
|
||||
strbuf_addf(err, _("cannot lock ref '%s': "
|
||||
"expected symref with target '%s': "
|
||||
"but is a regular ref"),
|
||||
ref_update_original_update_refname(u),
|
||||
u->old_target);
|
||||
ret = -1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (ref_update_check_old_target(referent.buf, u, err)) {
|
||||
ret = -1;
|
||||
goto done;
|
||||
|
Reference in New Issue
Block a user