git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Đoàn Trần Công Danh" <congdanhqx@gmail.com>
Cc: Hu Jialun <hujialun@comp.nus.edu.sg>,
	git@vger.kernel.org, felipe.contreras@gmail.com
Subject: Re: [PATCH] commit: remove irrelavent prompt on `--allow-empty-message`
Date: Thu, 08 Jul 2021 11:26:21 -0700	[thread overview]
Message-ID: <xmqqfswobr1u.fsf@gitster.g> (raw)
In-Reply-To: <YOciZUlWnF5ur5ec@danh.dev> ("Đoàn Trần Công Danh"'s message of "Thu, 8 Jul 2021 23:05:57 +0700")

Đoàn Trần Công Danh  <congdanhqx@gmail.com> writes:

>> In other words, which of the following 3 is the most acceptable?
>> 
>> 1. As Junio suggested, quoted above.
>
> I think this approach is the most expensive one, _() needs to query
> the gettext infrastructure, which is usually costly.
> However, I think that cost doesn't matter much since we're about to
> open an editor soon.

See note below.


>> 2.
>> status_printf(s, GIT_COLOR_NORMAL, allow_empty_message ?
>>                                    _("...") :
>> 				   _("...."), comment_line_char);
>
> install_branch_config() uses this style.
>
>> 
>> 3.
>> const char *hint_foo = allow_empty_message ?
>>                        _("...") :
>> 		       _("....");
>
> builtin/remote.c:show_local_info_item() writes:
>
> 	const char *msg;
> 	if (condition)
> 		msg = _("some message");
> 	else
> 		msg = _("other message");
>
> So, I guess it's fine either way. And people will need to see the
> patch to see which one is better.

Yeah, #1 and #3 are better than the patch posted or #2 in that by
extracting the large message body out-of-line from the code that do
use the messages, they make it simpler to follow the logic that uses
these messages.  That is

	if (cleanup_mode == CLEANUP_ALL)
		status_printf(..., hint_cleanup_all);
	else if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS)
		...;
	else /* all the rest */
		status_printf(..., hint_cleanup_space, comment_line_char);

would be far easier to follow than

	if (cleanup_mode == CLEANUP_ALL)
		status_printf(..., 
		condition 
		? large-large-message-1
		: large-large-message-1-plus-note-about-empty-message);
	else if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS)
		...;
	else /* all the rest */
		status_printf(...,
		condition
		? large-large-message-2
		: large-large-message-2-plus-note-about-empty-message,
		comment_line_char);

as the overall structure is easier to follow without the minute
detail of using slightly different messages depending on the
allow-empty setting.

By the way, if you want to avoid calling _() twice with the approach
#1, you can do

	hint_cleanup_all = N_("<cleanup and note about empty message>");
 	...

	if (condition) {
		hint_cleanup_all = N_("<cleanup without note>");
		...
	}

and use _(hint_cleanup_all) at the site that uses the message.

  reply	other threads:[~2021-07-08 18:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-06  2:24 [PATCH] commit: remove irrelavent prompt on `--allow-empty-message` Hu Jialun
2021-07-06 15:44 ` Junio C Hamano
2021-07-07  4:37   ` Felipe Contreras
2021-07-07 10:43   ` Hu Jialun
2021-07-07 16:23 ` Hu Jialun
2021-07-07 16:23   ` [PATCH v2 1/2] commit: reorganise duplicate commit prompt strings Hu Jialun
2021-07-07 16:57     ` Đoàn Trần Công Danh
2021-07-07 17:44       ` Junio C Hamano
2021-07-07 16:23   ` [PATCH v2 2/2] commit: remove irrelavent prompt on `--allow-empty-message` Hu Jialun
2021-07-07 17:42     ` Felipe Contreras
2021-07-08 15:19   ` [PATCH] " Hu Jialun
2021-07-08 16:05     ` Đoàn Trần Công Danh
2021-07-08 18:26       ` Junio C Hamano [this message]
2021-07-09 18:07   ` [PATCH v3 1/2] commit: reorganise commit hint strings Hu Jialun
2021-07-09 19:14     ` Junio C Hamano
2021-07-09 18:07   ` [PATCH v3 2/2] commit: remove irrelavent prompt on `--allow-empty-message` Hu Jialun
2021-07-09 19:14     ` Junio C Hamano
2021-07-10 17:26       ` Hu Jialun
2021-07-22 18:33       ` Hu Jialun
2021-07-22 21:18         ` Junio C Hamano

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=xmqqfswobr1u.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=congdanhqx@gmail.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=hujialun@comp.nus.edu.sg \
    /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;
as well as URLs for NNTP newsgroup(s).