{"thread":{"id":"29511","subject":"[PATCH v2] i18n: format_tracking_info \"Your branch is behind\" message","startedAt":"2012-02-02T01:37:19Z","lastAt":"2012-02-02T01:50:29Z","messageCount":2,"participants":["Jiang Xin","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"183528","messageId":"1328146639-87863-1-git-send-email-worldhello.net@gmail.com","threadId":"29511","inReplyTo":null,"subject":"[PATCH v2] i18n: format_tracking_info \"Your branch is behind\" message","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2012-02-02T01:37:19Z","receivedAt":"2012-02-02T01:37:19Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"Function format_tracking_info in remote.c is called by\nwt_status_print_tracking in wt-status.c, which will print\nbranch tracking message in git-status. git-checkout also\nshow these messages through it's report_tracking function.\n\nSigned-off-by: Jiang Xin <worldhello.net@gmail.com>\n---\n remote.c |   48 +++++++++++++++++++++++++++++++++++++-----------\n 1 files changed, 37 insertions(+), 11 deletions(-)\n\ndiff --git a/remote.c b/remote.c\nindex 73a38..45ac1 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1572,19 +1572,45 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)\n \tbase = branch->merge[0]->dst;\n \tbase = shorten_unambiguous_ref(base, 0);\n \tif (!num_theirs)\n-\t\tstrbuf_addf(sb, \"Your branch is ahead of '%s' \"\n-\t\t\t    \"by %d commit%s.\\n\",\n-\t\t\t    base, num_ours, (num_ours == 1) ? \"\" : \"s\");\n+\t\tstrbuf_addf(sb,\n+\t\t\tQ_(\n+\t\t\t/* The singular version */\n+\t\t\t\"Your branch is ahead of '%s' by %d commit.\\n\",\n+\t\t\t/* The plural version */\n+\t\t\t\"Your branch is ahead of '%s' by %d commits.\\n\",\n+\t\t\t/* Give ngettext() the count */\n+\t\t\tnum_ours),\n+\t\t\tbase,\n+\t\t\tnum_ours);\n \telse if (!num_ours)\n-\t\tstrbuf_addf(sb, \"Your branch is behind '%s' \"\n-\t\t\t    \"by %d commit%s, \"\n-\t\t\t    \"and can be fast-forwarded.\\n\",\n-\t\t\t    base, num_theirs, (num_theirs == 1) ? \"\" : \"s\");\n+\t\tstrbuf_addf(sb,\n+\t\t\tQ_(\n+\t\t\t/* The singular version */\n+\t\t\t\"Your branch is behind '%s' by %d commit, \"\n+\t\t\t\"and can be fast-forwarded.\\n\",\n+\t\t\t/* The plural version */\n+\t\t\t\"Your branch is behind '%s' by %d commits, \"\n+\t\t\t\"and can be fast-forwarded.\\n\",\n+\t\t\t/* Give ngettext() the count */\n+\t\t\tnum_theirs),\n+\t\t\tbase,\n+\t\t\tnum_theirs);\n \telse\n-\t\tstrbuf_addf(sb, \"Your branch and '%s' have diverged,\\n\"\n-\t\t\t    \"and have %d and %d different commit(s) each, \"\n-\t\t\t    \"respectively.\\n\",\n-\t\t\t    base, num_ours, num_theirs);\n+\t\tstrbuf_addf(sb,\n+\t\t\tQ_(\n+\t\t\t/* The singular version */\n+\t\t\t\"Your branch and '%s' have diverged,\\n\"\n+\t\t\t\"and have %d and %d different commit each, \"\n+\t\t\t\"respectively.\\n\",\n+\t\t\t/* The plural version */\n+\t\t\t\"Your branch and '%s' have diverged,\\n\"\n+\t\t\t\"and have %d and %d different commits each, \"\n+\t\t\t\"respectively.\\n\",\n+\t\t\t/* Give ngettext() the count */\n+\t\t\tnum_theirs),\n+\t\t\tbase,\n+\t\t\tnum_ours,\n+\t\t\tnum_theirs);\n \treturn 1;\n }\n \n-- \n1.7.9.109.gd927b\n"},{"id":"183532","messageId":"7vr4yeypei.fsf@alter.siamese.dyndns.org","threadId":"29511","inReplyTo":"1328146639-87863-1-git-send-email-worldhello.net@gmail.com","subject":"Re: [PATCH v2] i18n: format_tracking_info \"Your branch is behind\" message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-02T01:50:29Z","receivedAt":"2012-02-02T01:50:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jiang Xin <worldhello.net@gmail.com> writes:\n\n> Function format_tracking_info in remote.c is called by\n> wt_status_print_tracking in wt-status.c, which will print\n> branch tracking message in git-status. git-checkout also\n> show these messages through it's report_tracking function.\n>\n> Signed-off-by: Jiang Xin <worldhello.net@gmail.com>\n> ---\n>  remote.c |   48 +++++++++++++++++++++++++++++++++++++-----------\n>  1 files changed, 37 insertions(+), 11 deletions(-)\n>\n> diff --git a/remote.c b/remote.c\n> index 73a38..45ac1 100644\n> --- a/remote.c\n> +++ b/remote.c\n> @@ -1572,19 +1572,45 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)\n>  \tbase = branch->merge[0]->dst;\n>  \tbase = shorten_unambiguous_ref(base, 0);\n>  \tif (!num_theirs)\n> -\t\tstrbuf_addf(sb, \"Your branch is ahead of '%s' \"\n> -\t\t\t    \"by %d commit%s.\\n\",\n> -\t\t\t    base, num_ours, (num_ours == 1) ? \"\" : \"s\");\n> +\t\tstrbuf_addf(sb,\n> +\t\t\tQ_(\n> +\t\t\t/* The singular version */\n> +\t\t\t\"Your branch is ahead of '%s' by %d commit.\\n\",\n> +\t\t\t/* The plural version */\n> +\t\t\t\"Your branch is ahead of '%s' by %d commits.\\n\",\n> +\t\t\t/* Give ngettext() the count */\n> +\t\t\tnum_ours),\n> +\t\t\tbase,\n> +\t\t\tnum_ours);\n\nIt may be just me, but I think\n\n\t\tstrbuf_addf(sb,\n\t\t\tQ_(\"Your branch is ahead of '%s' by %d commit.\\n\",\n\t\t\t   \"Your branch is ahead of '%s' by %d commits.\\n\",\n\t\t\t   num_ours),\n                        base, num_ours);\n\nwould be far easier to read than these repetitive comments.\n\nIt allows you to see it more clearly that the two strings and one variable\nare given to Q_(), and the last two, base and num_ours, are the values to\nbe formatted by whatever the format string Q_() would choose.\n\nWhen the strings are longer, an extra indent would probably help, e.g.\n\n\t\tstrbuf_addf(sb,\n\t\t\tQ_(\"Your branch is behind '%s' by %d commit, \"\n\t\t\t\t\"and can be fast-forwarded.\\n\",\n\t\t\t   \"Your branch is behind '%s' by %d commits, \"\n\t\t\t\t\"and can be fast-forwarded.\\n\",\n\t\t\t   num_theirs),\n\t\t\tbase, num_theirs);\n"}]}