diff options
| author | Karthik Nayak <karthik.188@gmail.com> | 2024-06-07 15:32:59 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-06-07 10:25:44 -0700 |
| commit | aa6e99f1226fe46f1649f48d020011e19556e8e1 (patch) | |
| tree | 3c833c0d5dcc3d24b66d4babcdc25a65c2a42cf0 /refs/files-backend.c | |
| parent | aba381c09034c2c31f3476e8cc9a46ea6889f1d5 (diff) | |
refs: specify error for regular refs with `old_target`
When a reference update tries to update a symref, but the ref in
question is actually a regular ref, we raise an error. However the error
raised in this situation is:
verifying symref target: '<ref>': reference is missing but expected <old-target>
which is very generic and doesn't indicate the mismatch of types. Let's
make this error more specific:
cannot lock ref '<ref>': expected symref with target '<old-target>': but is a regular ref
so that users have a clearer understanding.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs/files-backend.c')
| -rw-r--r-- | refs/files-backend.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c index ef760869ca..d6f37963bc 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -2490,14 +2490,16 @@ static int lock_ref_for_update(struct files_ref_store *refs, /* * Even if the ref is a regular ref, if `old_target` is set, we - * check the referent value. Ideally `old_target` should only - * be set for symrefs, but we're strict about its usage. + * fail with an error. */ if (update->old_target) { - if (ref_update_check_old_target(referent.buf, update, err)) { - ret = TRANSACTION_GENERIC_ERROR; - goto out; - } + strbuf_addf(err, _("cannot lock ref '%s': " + "expected symref with target '%s': " + "but is a regular ref"), + ref_update_original_update_refname(update), + update->old_target); + ret = TRANSACTION_GENERIC_ERROR; + goto out; } else if (check_old_oid(update, &lock->old_oid, err)) { ret = TRANSACTION_GENERIC_ERROR; goto out; |
