From: Patrick Steinhardt <ps@pks.im>
To: "René Scharfe" <l.s.r@web.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 4/7] revision, rev-parse: factorize incompatibility messages about --exclude-hidden
Date: Wed, 6 Dec 2023 15:39:11 +0100 [thread overview]
Message-ID: <ZXCHj3hIpQb900WX@tanuki> (raw)
In-Reply-To: <389cd7b3-2350-4dc6-b282-e9d6e25fa68c@web.de>
[-- Attachment #1: Type: text/plain, Size: 3187 bytes --]
On Wed, Dec 06, 2023 at 03:21:15PM +0100, René Scharfe wrote:
> Am 06.12.23 um 14:08 schrieb Patrick Steinhardt:
> > On Wed, Dec 06, 2023 at 12:51:58PM +0100, René Scharfe wrote:
> >> Use the standard parameterized message for reporting incompatible
> >> options to report options that are not accepted in combination with
> >> --exclude-hidden. This reduces the number of strings to translate and
> >> makes the UI a bit more consistent.
> >>
> >> Signed-off-by: René Scharfe <l.s.r@web.de>
> >> ---
> >> builtin/rev-parse.c | 9 ++++++---
> >> revision.c | 18 ++++++++++++------
> >> t/t6018-rev-list-glob.sh | 6 ++----
> >> t/t6021-rev-list-exclude-hidden.sh | 4 ++--
> >> 4 files changed, 22 insertions(+), 15 deletions(-)
> >>
> >> diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
> >> index fde8861ca4..917f122440 100644
> >> --- a/builtin/rev-parse.c
> >> +++ b/builtin/rev-parse.c
> >> @@ -893,13 +893,15 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
> >> }
> >> if (opt_with_value(arg, "--branches", &arg)) {
> >> if (ref_excludes.hidden_refs_configured)
> >> - return error(_("--exclude-hidden cannot be used together with --branches"));
> >> + return error(_("options '%s' and '%s' cannot be used together"),
> >> + "--exclude-hidden", "--branches");
> >
> > The repetitive nature of this patch and subsequent ones made me wonder
> > whether it would be useful to have a function similar to the
> > `die_for_incompatible_*()` helper that knows to format this error
> > correctly.
>
> I wondered the same and experimented with a die_for_incompatible_opt2().
> It would allow the compiler to detect typos.
>
> Passing in the conditions as parameters is a bit tedious and unlike its
> for its higher-numbered siblings there is not much to win by doing that
> instead of using an if statement or two nested ones. We could pass in
> 1 if we want to integrate that function into an if cascade like above,
> but it would look a bit silly. And here we'd need a non-fatal version
> anyway.
Maybe the easiest solution would be to have `error_incompatible_usage()`
that simply wraps `error()`. You'd pass in the incompatible params and
it makes sure to format them accordingly. It could either accept two
args or even be a vararg function with sentinel `NULL`. It's not perfect
of course, but would at least ensure that we can easily convert things
over time without having to duplicate the exact message everywhere.
But ultimately I do not mind the current duplication all that much, the
patch series looks good to me even without such a new helper.
> Perhaps a build step that lists all new translatable strings would help?
> Nah, that would require building each commit.
>
> A LLM-based tool to find translatable strings with the same meaning?
> Don't know how difficult that would be.
I don't think it's a problem to not convert everything in one go. The
current series is a good step in the right direction, and any additional
instances that were missed can be fixed in follow-ups.
Patrick
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2023-12-06 14:39 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-06 11:51 [PATCH 0/7] standardize incompatibility messages René Scharfe
2023-12-06 11:51 ` [PATCH 1/7] push: use die_for_incompatible_opt4() for --delete/--tags/--all/--mirror René Scharfe
2023-12-06 11:51 ` [PATCH 2/7] repack: use die_for_incompatible_opt3() for -A/-k/--cruft René Scharfe
2023-12-06 19:18 ` Taylor Blau
2023-12-06 11:51 ` [PATCH 3/7] revision: use die_for_incompatible_opt3() for --graph/--reverse/--walk-reflogs René Scharfe
2023-12-06 13:08 ` Patrick Steinhardt
2023-12-06 13:47 ` René Scharfe
2023-12-06 17:21 ` Eric Sunshine
2023-12-06 17:29 ` René Scharfe
2023-12-06 11:51 ` [PATCH 4/7] revision, rev-parse: factorize incompatibility messages about --exclude-hidden René Scharfe
2023-12-06 13:08 ` Patrick Steinhardt
2023-12-06 14:21 ` René Scharfe
2023-12-06 14:39 ` Patrick Steinhardt [this message]
2023-12-06 17:07 ` René Scharfe
2023-12-06 19:25 ` Taylor Blau
2023-12-07 7:10 ` Patrick Steinhardt
2023-12-06 11:51 ` [PATCH 5/7] clean: factorize incompatibility message René Scharfe
2023-12-06 11:52 ` [PATCH 6/7] worktree: standardize incompatibility messages René Scharfe
2023-12-06 11:52 ` [PATCH 7/7] worktree: simplify incompatibility message for --orphan and commit-ish René Scharfe
2023-12-06 13:07 ` [PATCH 0/7] standardize incompatibility messages Patrick Steinhardt
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=ZXCHj3hIpQb900WX@tanuki \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=l.s.r@web.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.