From: Patrick Steinhardt <ps@pks.im>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH v4 2/7] refs: specify error for regular refs with `old_target`
Date: Thu, 6 Jun 2024 13:02:28 +0200 [thread overview]
Message-ID: <ZmGXREp9Xa6qHpMC@tanuki> (raw)
In-Reply-To: <20240605102958.716432-3-knayak@gitlab.com>
[-- Attachment #1: Type: text/plain, Size: 2559 bytes --]
On Wed, Jun 05, 2024 at 12:29:53PM +0200, Karthik Nayak wrote:
> From: Karthik Nayak <karthik.188@gmail.com>
>
> When a regular reference update contains `old_target` set, we call the
s/contains/has its/
> `ref_update_check_old_target` function to check the referent value. But
> for regular refs we know that the referent value is not set and this
This is fairly technical and focussed on the implementation. Can we
maybe talk more about intent ("expected a symref, but is a direct ref")
rather than the exact implementation to make the commit message a bit
easier to understand for folks?
> simply raises a generic error which says nothing about this being a
> regular ref. Instead let's raise a more specific error when a regular
> ref update contains `old_target`.
It might be helpful to include before/after in this commit message to
show the change. Even better would be a test of course, but I think we
cannot add one at this point in time yet.
> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
> ---
> refs/files-backend.c | 13 +++++++------
> refs/reftable-backend.c | 9 +++++++++
> 2 files changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/refs/files-backend.c b/refs/files-backend.c
> index 194e74eb4d..f516d4d82f 100644
> --- a/refs/files-backend.c
> +++ b/refs/files-backend.c
> @@ -2491,14 +2491,15 @@ 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 update regular ref: '%s': "
> + "symref target '%s' set"),
> + ref_update_original_update_refname(update),
> + update->old_target);
> + ret = TRANSACTION_GENERIC_ERROR;
> + goto out;
I feel like these error messages are somewhat technical. If I were
reading it as a user, I don't think I'd understand what it is trying to
tell me. How about:
strbuf_addf(err, _("cannot lock ref '%s': %s",
"expected symref but is a direct ref"));
This also matches the other error messages we have in this function more
closely. The same is true for the equivalent in the reftable backend.
Patrick
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2024-06-06 11:02 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <https://lore.kernel.org/r/20240530120940.456817-1-knayak@gitlab.com>
2024-06-05 10:29 ` [PATCH v4 0/7] update-ref: add symref support for --stdin Karthik Nayak
2024-06-06 8:22 ` Karthik Nayak
2024-06-06 11:03 ` Karthik Nayak
2024-06-07 13:32 ` [PATCH v5 " Karthik Nayak
2024-06-07 13:32 ` [PATCH v5 1/7] refs: create and use `ref_update_expects_existing_old_ref()` Karthik Nayak
2024-06-07 13:32 ` [PATCH v5 2/7] refs: specify error for regular refs with `old_target` Karthik Nayak
2024-06-10 6:54 ` Patrick Steinhardt
2024-06-10 8:26 ` Karthik Nayak
2024-06-07 13:33 ` [PATCH v5 3/7] update-ref: add support for 'symref-verify' command Karthik Nayak
2024-06-07 13:33 ` [PATCH v5 4/7] update-ref: add support for 'symref-delete' command Karthik Nayak
2024-06-07 13:33 ` [PATCH v5 5/7] update-ref: add support for 'symref-create' command Karthik Nayak
2024-06-07 13:33 ` [PATCH v5 6/7] reftable: pick either 'oid' or 'target' for new updates Karthik Nayak
2024-06-07 13:33 ` [PATCH v5 7/7] update-ref: add support for 'symref-update' command Karthik Nayak
2024-06-05 10:29 ` [PATCH v4 1/7] refs: create and use `ref_update_expects_existing_old_ref()` Karthik Nayak
2024-06-05 10:29 ` [PATCH v4 2/7] refs: specify error for regular refs with `old_target` Karthik Nayak
2024-06-06 11:02 ` Patrick Steinhardt [this message]
2024-06-06 14:20 ` Karthik Nayak
2024-06-05 10:29 ` [PATCH v4 3/7] update-ref: add support for 'symref-verify' command Karthik Nayak
2024-06-05 10:29 ` [PATCH v4 4/7] update-ref: add support for 'symref-delete' command Karthik Nayak
2024-06-05 10:29 ` [PATCH v4 5/7] update-ref: add support for 'symref-create' command Karthik Nayak
2024-06-05 10:29 ` [PATCH v4 6/7] reftable: pick either 'oid' or 'target' for new updates Karthik Nayak
2024-06-05 10:29 ` [PATCH v4 7/7] update-ref: add support for 'symref-update' command Karthik Nayak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZmGXREp9Xa6qHpMC@tanuki \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=karthik.188@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox