From: Junio C Hamano <gitster@pobox.com>
To: Jiang Xin <worldhello.net@gmail.com>
Cc: Git List <git@vger.kernel.org>, avarab@gmail.com
Subject: Re: [PATCH v2] i18n: format_tracking_info "Your branch is behind" message
Date: Wed, 01 Feb 2012 17:50:29 -0800 [thread overview]
Message-ID: <7vr4yeypei.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1328146639-87863-1-git-send-email-worldhello.net@gmail.com> (Jiang Xin's message of "Thu, 2 Feb 2012 09:37:19 +0800")
Jiang Xin <worldhello.net@gmail.com> writes:
> Function format_tracking_info in remote.c is called by
> wt_status_print_tracking in wt-status.c, which will print
> branch tracking message in git-status. git-checkout also
> show these messages through it's report_tracking function.
>
> Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
> ---
> remote.c | 48 +++++++++++++++++++++++++++++++++++++-----------
> 1 files changed, 37 insertions(+), 11 deletions(-)
>
> diff --git a/remote.c b/remote.c
> index 73a38..45ac1 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -1572,19 +1572,45 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
> base = branch->merge[0]->dst;
> base = shorten_unambiguous_ref(base, 0);
> if (!num_theirs)
> - strbuf_addf(sb, "Your branch is ahead of '%s' "
> - "by %d commit%s.\n",
> - base, num_ours, (num_ours == 1) ? "" : "s");
> + strbuf_addf(sb,
> + Q_(
> + /* The singular version */
> + "Your branch is ahead of '%s' by %d commit.\n",
> + /* The plural version */
> + "Your branch is ahead of '%s' by %d commits.\n",
> + /* Give ngettext() the count */
> + num_ours),
> + base,
> + num_ours);
It may be just me, but I think
strbuf_addf(sb,
Q_("Your branch is ahead of '%s' by %d commit.\n",
"Your branch is ahead of '%s' by %d commits.\n",
num_ours),
base, num_ours);
would be far easier to read than these repetitive comments.
It allows you to see it more clearly that the two strings and one variable
are given to Q_(), and the last two, base and num_ours, are the values to
be formatted by whatever the format string Q_() would choose.
When the strings are longer, an extra indent would probably help, e.g.
strbuf_addf(sb,
Q_("Your branch is behind '%s' by %d commit, "
"and can be fast-forwarded.\n",
"Your branch is behind '%s' by %d commits, "
"and can be fast-forwarded.\n",
num_theirs),
base, num_theirs);
prev parent reply other threads:[~2012-02-02 1:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-02 1:37 [PATCH v2] i18n: format_tracking_info "Your branch is behind" message Jiang Xin
2012-02-02 1:50 ` Junio C Hamano [this message]
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=7vr4yeypei.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=worldhello.net@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;
as well as URLs for NNTP newsgroup(s).