diff mbox series

[v4,05/11] i18n: tag.c factorize i18n strings

Message ID a9d8a50d66676ea10292e8319e3eacbf7bcd83f5.1641143746.git.gitgitgadget@gmail.com (mailing list archive)
State Superseded
Headers show
Series Factorization of messages with similar meaning | expand

Commit Message

Jean-Noël Avila Jan. 2, 2022, 5:15 p.m. UTC
From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= <jn.avila@free.fr>

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
---
 builtin/tag.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

Comments

René Scharfe Jan. 2, 2022, 5:37 p.m. UTC | #1
Am 02.01.22 um 18:15 schrieb Jean-Noël Avila via GitGitGadget:
> From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= <jn.avila@free.fr>
>
> Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
> ---
>  builtin/tag.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/builtin/tag.c b/builtin/tag.c
> index dfdcfd37956..82e09c1b83d 100644
> --- a/builtin/tag.c
> +++ b/builtin/tag.c
> @@ -483,6 +483,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
>  		OPT_END()
>  	};
>  	int ret = 0;
> +	const char *only_in_list = NULL;
>
>  	setup_ref_filter_porcelain_msg();
>
> @@ -542,15 +543,17 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
>  		goto cleanup;
>  	}
>  	if (filter.lines != -1)
> -		die(_("-n option is only allowed in list mode"));
> -	if (filter.with_commit)
> -		die(_("--contains option is only allowed in list mode"));
> -	if (filter.no_commit)
> -		die(_("--no-contains option is only allowed in list mode"));
> -	if (filter.points_at.nr)
> -		die(_("--points-at option is only allowed in list mode"));
> +		only_in_list = "-n";
> +	else if (filter.with_commit)
> +		only_in_list = "--contains";
> +	else if (filter.no_commit)
> +		only_in_list = "--no-contains";
> +	else if (filter.points_at.nr)
> +		only_in_list = "--points-at";
> +	if (only_in_list)
> +		die(_("the '%s' option is only allowed in list mode"), only_in_list);
>  	if (filter.reachable_from || filter.unreachable_from)
> -		die(_("--merged and --no-merged options are only allowed in list mode"));
> +		die(_("'--merged' and '--no-merged' options are only allowed in list mode"));

What I meant in my earlier reply was: Shouldn't --merged and --no-merged
be handled like the other options that require list mode?

	else if (filter.reachable_from)
		only_in_list = "--merged";
	else if (filter.unreachable_from)
		only_in_list = "--no-merged";

>  	if (cmdmode == 'd') {
>  		ret = delete_tags(argv);
>  		goto cleanup;
Jean-Noël Avila Jan. 2, 2022, 8:29 p.m. UTC | #2
On Sunday, 2 January 2022 18:37:02 CET René Scharfe wrote:
> Am 02.01.22 um 18:15 schrieb Jean-Noël Avila via GitGitGadget:
> > From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= <jn.avila@free.fr>
> >
> > Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
> > ---
> >  builtin/tag.c | 19 +++++++++++--------
> >  1 file changed, 11 insertions(+), 8 deletions(-)
> >
> > diff --git a/builtin/tag.c b/builtin/tag.c
> > index dfdcfd37956..82e09c1b83d 100644
> > --- a/builtin/tag.c
> > +++ b/builtin/tag.c
> > @@ -483,6 +483,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
> >  		OPT_END()
> >  	};
> >  	int ret = 0;
> > +	const char *only_in_list = NULL;
> >
> >  	setup_ref_filter_porcelain_msg();
> >
> > @@ -542,15 +543,17 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
> >  		goto cleanup;
> >  	}
> >  	if (filter.lines != -1)
> > -		die(_("-n option is only allowed in list mode"));
> > -	if (filter.with_commit)
> > -		die(_("--contains option is only allowed in list mode"));
> > -	if (filter.no_commit)
> > -		die(_("--no-contains option is only allowed in list mode"));
> > -	if (filter.points_at.nr)
> > -		die(_("--points-at option is only allowed in list mode"));
> > +		only_in_list = "-n";
> > +	else if (filter.with_commit)
> > +		only_in_list = "--contains";
> > +	else if (filter.no_commit)
> > +		only_in_list = "--no-contains";
> > +	else if (filter.points_at.nr)
> > +		only_in_list = "--points-at";
> > +	if (only_in_list)
> > +		die(_("the '%s' option is only allowed in list mode"), only_in_list);
> >  	if (filter.reachable_from || filter.unreachable_from)
> > -		die(_("--merged and --no-merged options are only allowed in list mode"));
> > +		die(_("'--merged' and '--no-merged' options are only allowed in list mode"));
> 
> What I meant in my earlier reply was: Shouldn't --merged and --no-merged
> be handled like the other options that require list mode?
> 
> 	else if (filter.reachable_from)
> 		only_in_list = "--merged";
> 	else if (filter.unreachable_from)
> 		only_in_list = "--no-merged";
> 

Oh. That's neat! Sorry for having missed that.
diff mbox series

Patch

diff --git a/builtin/tag.c b/builtin/tag.c
index dfdcfd37956..82e09c1b83d 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -483,6 +483,7 @@  int cmd_tag(int argc, const char **argv, const char *prefix)
 		OPT_END()
 	};
 	int ret = 0;
+	const char *only_in_list = NULL;
 
 	setup_ref_filter_porcelain_msg();
 
@@ -542,15 +543,17 @@  int cmd_tag(int argc, const char **argv, const char *prefix)
 		goto cleanup;
 	}
 	if (filter.lines != -1)
-		die(_("-n option is only allowed in list mode"));
-	if (filter.with_commit)
-		die(_("--contains option is only allowed in list mode"));
-	if (filter.no_commit)
-		die(_("--no-contains option is only allowed in list mode"));
-	if (filter.points_at.nr)
-		die(_("--points-at option is only allowed in list mode"));
+		only_in_list = "-n";
+	else if (filter.with_commit)
+		only_in_list = "--contains";
+	else if (filter.no_commit)
+		only_in_list = "--no-contains";
+	else if (filter.points_at.nr)
+		only_in_list = "--points-at";
+	if (only_in_list)
+		die(_("the '%s' option is only allowed in list mode"), only_in_list);
 	if (filter.reachable_from || filter.unreachable_from)
-		die(_("--merged and --no-merged options are only allowed in list mode"));
+		die(_("'--merged' and '--no-merged' options are only allowed in list mode"));
 	if (cmdmode == 'd') {
 		ret = delete_tags(argv);
 		goto cleanup;