{"thread":{"id":"44461","subject":"[PATCH v6 01/16] Git.pm: add subroutines for commenting lines","startedAt":"2016-11-11T12:46:04Z","lastAt":"2016-12-13T18:16:18Z","messageCount":26,"participants":["Vasco Almeida","Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":6,"patchTotal":16},"messages":[{"id":"305771","messageId":"20161111124541.8216-2-vascomalmeida@sapo.pt","threadId":"44461","inReplyTo":"20161111124541.8216-1-vascomalmeida@sapo.pt","subject":"[PATCH v6 01/16] Git.pm: add subroutines for commenting lines","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-11-11T12:45:26Z","receivedAt":"2016-11-11T12:46:04Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Add subroutines prefix_lines and comment_lines.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n perl/Git.pm | 24 ++++++++++++++++++++++++\n 1 file changed, 24 insertions(+)\n\ndiff --git a/perl/Git.pm b/perl/Git.pm\nindex b2732822a..69cd1ddec 100644\n--- a/perl/Git.pm\n+++ b/perl/Git.pm\n@@ -1438,6 +1438,30 @@ sub END {\n \n } # %TEMP_* Lexical Context\n \n+=item prefix_lines ( PREFIX, STRING [, STRING... ])\n+\n+Prefixes lines in C<STRING> with C<PREFIX>.\n+\n+=cut\n+\n+sub prefix_lines {\n+\tmy $prefix = shift;\n+\tmy $string = join(\"\\n\", @_);\n+\t$string =~ s/^/$prefix/mg;\n+\treturn $string;\n+}\n+\n+=item comment_lines ( STRING [, STRING... ])\n+\n+Comments lines following core.commentchar configuration.\n+\n+=cut\n+\n+sub comment_lines {\n+\tmy $comment_line_char = config(\"core.commentchar\") || '#';\n+\treturn prefix_lines(\"$comment_line_char \", @_);\n+}\n+\n =back\n \n =head1 ERROR HANDLING\n-- \n2.11.0.rc0.33.gec17dab\n\n"},{"id":"305772","messageId":"20161111124541.8216-6-vascomalmeida@sapo.pt","threadId":"44461","inReplyTo":"20161111124541.8216-1-vascomalmeida@sapo.pt","subject":"[PATCH v6 05/16] i18n: clean.c: match string with git-add--interactive.perl","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-11-11T12:45:30Z","receivedAt":"2016-11-11T12:46:07Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Change strings for help to match the ones in git-add--interactive.perl.\nThe strings now represent one entry to translate each rather then two\nentries each different only by an ending newline character.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n builtin/clean.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/clean.c b/builtin/clean.c\nindex 0371010af..d6bc3aaae 100644\n--- a/builtin/clean.c\n+++ b/builtin/clean.c\n@@ -287,11 +287,11 @@ static void pretty_print_menus(struct string_list *menu_list)\n static void prompt_help_cmd(int singleton)\n {\n \tclean_print_color(CLEAN_COLOR_HELP);\n-\tprintf_ln(singleton ?\n+\tprintf(singleton ?\n \t\t  _(\"Prompt help:\\n\"\n \t\t    \"1          - select a numbered item\\n\"\n \t\t    \"foo        - select item based on unique prefix\\n\"\n-\t\t    \"           - (empty) select nothing\") :\n+\t\t    \"           - (empty) select nothing\\n\") :\n \t\t  _(\"Prompt help:\\n\"\n \t\t    \"1          - select a single item\\n\"\n \t\t    \"3-5        - select a range of items\\n\"\n@@ -299,7 +299,7 @@ static void prompt_help_cmd(int singleton)\n \t\t    \"foo        - select item based on unique prefix\\n\"\n \t\t    \"-...       - unselect specified items\\n\"\n \t\t    \"*          - choose all items\\n\"\n-\t\t    \"           - (empty) finish selecting\"));\n+\t\t    \"           - (empty) finish selecting\\n\"));\n \tclean_print_color(CLEAN_COLOR_RESET);\n }\n \n@@ -508,7 +508,7 @@ static int parse_choice(struct menu_stuff *menu_stuff,\n \t\tif (top <= 0 || bottom <= 0 || top > menu_stuff->nr || bottom > top ||\n \t\t    (is_single && bottom != top)) {\n \t\t\tclean_print_color(CLEAN_COLOR_ERROR);\n-\t\t\tprintf_ln(_(\"Huh (%s)?\"), (*ptr)->buf);\n+\t\t\tprintf(_(\"Huh (%s)?\\n\"), (*ptr)->buf);\n \t\t\tclean_print_color(CLEAN_COLOR_RESET);\n \t\t\tcontinue;\n \t\t}\n@@ -774,7 +774,7 @@ static int ask_each_cmd(void)\n static int quit_cmd(void)\n {\n \tstring_list_clear(&del_list, 0);\n-\tprintf_ln(_(\"Bye.\"));\n+\tprintf(_(\"Bye.\\n\"));\n \treturn MENU_RETURN_NO_LOOP;\n }\n \n-- \n2.11.0.rc0.33.gec17dab\n\n"},{"id":"305773","messageId":"20161111124541.8216-8-vascomalmeida@sapo.pt","threadId":"44461","inReplyTo":"20161111124541.8216-1-vascomalmeida@sapo.pt","subject":"[PATCH v6 07/16] i18n: add--interactive: mark patch prompt for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-11-11T12:45:32Z","receivedAt":"2016-11-11T12:46:11Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark prompt message assembled in place for translation, unfolding each\nuse case for each entry in the %patch_modes hash table.\n\nPreviously, this script relied on whether $patch_mode was set to run the\ncommand patch_update_cmd() or show status and loop the main loop. Now,\nit uses $cmd to indicate we must run patch_update_cmd() and $patch_mode\nis used to tell which flavor of the %patch_modes are we on.  This is\nintroduced in order to be able to mark and unfold the message prompt\nknowing in which context we are.\n\nThe tracking of context was done previously by point %patch_mode_flavour\nhash table to the correct entry of %patch_modes, focusing only on value\nof %patch_modes. Now, we are also interested in the key ('staged',\n'stash', 'checkout_head', ...).\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n Makefile                  |  2 +-\n git-add--interactive.perl | 54 ++++++++++++++++++++++++++++++++++++++++-------\n perl/Git/I18N.pm          | 11 +++++++++-\n t/t0202/test.pl           |  5 ++++-\n 4 files changed, 61 insertions(+), 11 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 328151dd6..ee89c0624 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2114,7 +2114,7 @@ XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \\\n XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell \\\n \t--keyword=gettextln --keyword=eval_gettextln\n XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --language=Perl \\\n-\t--keyword=__ --keyword=\"__n:1,2\"\n+\t--keyword=__ --keyword=N__ --keyword=\"__n:1,2\"\n LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)\n LOCALIZED_SH = $(SCRIPT_SH)\n LOCALIZED_SH += git-parse-remote.sh\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex cd617837b..b7d382b10 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -93,6 +93,7 @@ sub colored {\n }\n \n # command line options\n+my $cmd;\n my $patch_mode;\n my $patch_mode_revision;\n \n@@ -173,7 +174,8 @@ my %patch_modes = (\n \t},\n );\n \n-my %patch_mode_flavour = %{$patch_modes{stage}};\n+$patch_mode = 'stage';\n+my %patch_mode_flavour = %{$patch_modes{$patch_mode}};\n \n sub run_cmd_pipe {\n \tif ($^O eq 'MSWin32') {\n@@ -1311,6 +1313,44 @@ sub display_hunks {\n \treturn $i;\n }\n \n+my %patch_update_prompt_modes = (\n+\tstage => {\n+\t\tmode => N__(\"Stage mode change [y,n,q,a,d,/%s,?]? \"),\n+\t\tdeletion => N__(\"Stage deletion [y,n,q,a,d,/%s,?]? \"),\n+\t\thunk => N__(\"Stage this hunk [y,n,q,a,d,/%s,?]? \"),\n+\t},\n+\tstash => {\n+\t\tmode => N__(\"Stash mode change [y,n,q,a,d,/%s,?]? \"),\n+\t\tdeletion => N__(\"Stash deletion [y,n,q,a,d,/%s,?]? \"),\n+\t\thunk => N__(\"Stash this hunk [y,n,q,a,d,/%s,?]? \"),\n+\t},\n+\treset_head => {\n+\t\tmode => N__(\"Unstage mode change [y,n,q,a,d,/%s,?]? \"),\n+\t\tdeletion => N__(\"Unstage deletion [y,n,q,a,d,/%s,?]? \"),\n+\t\thunk => N__(\"Unstage this hunk [y,n,q,a,d,/%s,?]? \"),\n+\t},\n+\treset_nothead => {\n+\t\tmode => N__(\"Apply mode change to index [y,n,q,a,d,/%s,?]? \"),\n+\t\tdeletion => N__(\"Apply deletion to index [y,n,q,a,d,/%s,?]? \"),\n+\t\thunk => N__(\"Apply this hunk to index [y,n,q,a,d,/%s,?]? \"),\n+\t},\n+\tcheckout_index => {\n+\t\tmode => N__(\"Discard mode change from worktree [y,n,q,a,d,/%s,?]? \"),\n+\t\tdeletion => N__(\"Discard deletion from worktree [y,n,q,a,d,/%s,?]? \"),\n+\t\thunk => N__(\"Discard this hunk from worktree [y,n,q,a,d,/%s,?]? \"),\n+\t},\n+\tcheckout_head => {\n+\t\tmode => N__(\"Discard mode change from index and worktree [y,n,q,a,d,/%s,?]? \"),\n+\t\tdeletion => N__(\"Discard deletion from index and worktree [y,n,q,a,d,/%s,?]? \"),\n+\t\thunk => N__(\"Discard this hunk from index and worktree [y,n,q,a,d,/%s,?]? \"),\n+\t},\n+\tcheckout_nothead => {\n+\t\tmode => N__(\"Apply mode change to index and worktree [y,n,q,a,d,/%s,?]? \"),\n+\t\tdeletion => N__(\"Apply deletion to index and worktree [y,n,q,a,d,/%s,?]? \"),\n+\t\thunk => N__(\"Apply this hunk to index and worktree [y,n,q,a,d,/%s,?]? \"),\n+\t},\n+);\n+\n sub patch_update_file {\n \tmy $quit = 0;\n \tmy ($ix, $num);\n@@ -1383,12 +1423,9 @@ sub patch_update_file {\n \t\tfor (@{$hunk[$ix]{DISPLAY}}) {\n \t\t\tprint;\n \t\t}\n-\t\tprint colored $prompt_color, $patch_mode_flavour{VERB},\n-\t\t  ($hunk[$ix]{TYPE} eq 'mode' ? ' mode change' :\n-\t\t   $hunk[$ix]{TYPE} eq 'deletion' ? ' deletion' :\n-\t\t   ' this hunk'),\n-\t\t  $patch_mode_flavour{TARGET},\n-\t\t  \" [y,n,q,a,d,/$other,?]? \";\n+\t\tprint colored $prompt_color,\n+\t\t\tsprintf(__($patch_update_prompt_modes{$patch_mode}{$hunk[$ix]{TYPE}}), $other);\n+\n \t\tmy $line = prompt_single_character;\n \t\tlast unless defined $line;\n \t\tif ($line) {\n@@ -1644,6 +1681,7 @@ sub process_args {\n \t\tdie sprintf(__(\"invalid argument %s, expecting --\"),\n \t\t\t       $arg) unless $arg eq \"--\";\n \t\t%patch_mode_flavour = %{$patch_modes{$patch_mode}};\n+\t\t$cmd = 1;\n \t}\n \telsif ($arg ne \"--\") {\n \t\tdie sprintf(__(\"invalid argument %s, expecting --\"), $arg);\n@@ -1680,7 +1718,7 @@ sub main_loop {\n \n process_args();\n refresh();\n-if ($patch_mode) {\n+if ($cmd) {\n \tpatch_update_cmd();\n }\n else {\ndiff --git a/perl/Git/I18N.pm b/perl/Git/I18N.pm\nindex 617d8c2a1..c41425c8d 100644\n--- a/perl/Git/I18N.pm\n+++ b/perl/Git/I18N.pm\n@@ -13,7 +13,7 @@ BEGIN {\n \t}\n }\n \n-our @EXPORT = qw(__ __n);\n+our @EXPORT = qw(__ __n N__);\n our @EXPORT_OK = @EXPORT;\n \n sub __bootstrap_locale_messages {\n@@ -54,6 +54,8 @@ BEGIN\n \t\t*__ = sub ($) { $_[0] };\n \t\t*__n = sub ($$$) { $_[2] == 1 ? $_[0] : $_[1] };\n \t};\n+\n+\tsub N__($) { return shift; }\n }\n \n 1;\n@@ -74,6 +76,7 @@ Git::I18N - Perl interface to Git's Gettext localizations\n \n \tprintf __n(\"commited %d file\\n\", \"commited %d files\\n\", $files), $files;\n \n+\n =head1 DESCRIPTION\n \n Git's internal Perl interface to gettext via L<Locale::Messages>. If\n@@ -95,6 +98,12 @@ passthrough fallback function.\n \n L<Locale::Messages>'s ngettext function or passthrough fallback function.\n \n+=head2 N__($)\n+\n+No-operation that only returns its argument. Use this if you want xgettext to\n+extract the text to the pot template but do not want to trigger retrival of the\n+translation at run time.\n+\n =head1 AUTHOR\n \n E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avarab@gmail.com>\ndiff --git a/t/t0202/test.pl b/t/t0202/test.pl\nindex 4101833a8..2cbf7b959 100755\n--- a/t/t0202/test.pl\n+++ b/t/t0202/test.pl\n@@ -4,7 +4,7 @@ use lib (split(/:/, $ENV{GITPERLLIB}));\n use strict;\n use warnings;\n use POSIX qw(:locale_h);\n-use Test::More tests => 11;\n+use Test::More tests => 13;\n use Git::I18N;\n \n my $has_gettext_library = $Git::I18N::__HAS_LIBRARY;\n@@ -32,6 +32,7 @@ is_deeply(\\@Git::I18N::EXPORT, \\@Git::I18N::EXPORT_OK, \"sanity: Git::I18N export\n \tmy %prototypes = (qw(\n \t\t__\t$\n \t\t__n\t$$$\n+\t\tN__\t$\n \t));\n \twhile (my ($sub, $proto) = each %prototypes) {\n \t\tis(prototype(\\&{\"Git::I18N::$sub\"}), $proto, \"sanity: $sub has a $proto prototype\");\n@@ -55,6 +56,8 @@ is_deeply(\\@Git::I18N::EXPORT, \\@Git::I18N::EXPORT_OK, \"sanity: Git::I18N export\n \t\t\"Get singular string through __n() in C locale\");\n \tis(__n($got_singular, $got_plural, 2), $expect_plural,\n \t\t\"Get plural string through __n() in C locale\");\n+\n+\tis(N__($got), $expect, \"Passing a string through N__() in the C locale works\");\n }\n \n # Test a basic message on different locales\n-- \n2.11.0.rc0.33.gec17dab\n\n"},{"id":"305774","messageId":"20161111124541.8216-12-vascomalmeida@sapo.pt","threadId":"44461","inReplyTo":"20161111124541.8216-1-vascomalmeida@sapo.pt","subject":"[PATCH v6 11/16] i18n: add--interactive: mark status words for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-11-11T12:45:36Z","receivedAt":"2016-11-11T12:46:14Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark words 'nothing', 'unchanged' and 'binary' used to display what has\nbeen staged or not, in \"git add -i\" status command.\n\nAlternatively one could mark N__('nothing') no-op in order to\nxgettext(1) extract the string and then trigger the translation at run\ntime only with __($print->{FILE}), but that has the side effect of triggering\nretrieval of translations for the changes indicator too (e.g. +2/-1)\nwhich may or may not be a problem.\n\nTo avoid that potential problem, mark only where there is certain to\ntrigger translation only of those words but in this case we must also\nretrieve the translation for the eq tests, since the value assigned was\nof the translation, not the English source.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-add--interactive.perl | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 5f6637bde..3a6d846da 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -295,7 +295,7 @@ sub list_modified {\n \t\t\tmy ($change, $bin);\n \t\t\t$file = unquote_path($file);\n \t\t\tif ($add eq '-' && $del eq '-') {\n-\t\t\t\t$change = 'binary';\n+\t\t\t\t$change = __('binary');\n \t\t\t\t$bin = 1;\n \t\t\t}\n \t\t\telse {\n@@ -304,7 +304,7 @@ sub list_modified {\n \t\t\t$data{$file} = {\n \t\t\t\tINDEX => $change,\n \t\t\t\tBINARY => $bin,\n-\t\t\t\tFILE => 'nothing',\n+\t\t\t\tFILE => __('nothing'),\n \t\t\t}\n \t\t}\n \t\telsif (($adddel, $file) =\n@@ -320,7 +320,7 @@ sub list_modified {\n \t\t\t$file = unquote_path($file);\n \t\t\tmy ($change, $bin);\n \t\t\tif ($add eq '-' && $del eq '-') {\n-\t\t\t\t$change = 'binary';\n+\t\t\t\t$change = __('binary');\n \t\t\t\t$bin = 1;\n \t\t\t}\n \t\t\telse {\n@@ -340,7 +340,7 @@ sub list_modified {\n \t\t\t$file = unquote_path($2);\n \t\t\tif (!exists $data{$file}) {\n \t\t\t\t$data{$file} = +{\n-\t\t\t\t\tINDEX => 'unchanged',\n+\t\t\t\t\tINDEX => __('unchanged'),\n \t\t\t\t\tBINARY => 0,\n \t\t\t\t};\n \t\t\t}\n@@ -355,10 +355,10 @@ sub list_modified {\n \n \t\tif ($only) {\n \t\t\tif ($only eq 'index-only') {\n-\t\t\t\tnext if ($it->{INDEX} eq 'unchanged');\n+\t\t\t\tnext if ($it->{INDEX} eq __('unchanged'));\n \t\t\t}\n \t\t\tif ($only eq 'file-only') {\n-\t\t\t\tnext if ($it->{FILE} eq 'nothing');\n+\t\t\t\tnext if ($it->{FILE} eq __('nothing'));\n \t\t\t}\n \t\t}\n \t\tpush @return, +{\n-- \n2.11.0.rc0.33.gec17dab\n\n"},{"id":"305775","messageId":"20161111124541.8216-13-vascomalmeida@sapo.pt","threadId":"44461","inReplyTo":"20161111124541.8216-1-vascomalmeida@sapo.pt","subject":"[PATCH v6 12/16] i18n: send-email: mark strings for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-11-11T12:45:37Z","receivedAt":"2016-11-11T12:46:15Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark strings often displayed to the user for translation.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-send-email.perl | 54 +++++++++++++++++++++++++++++++----------------------\n 1 file changed, 32 insertions(+), 22 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex da81be40c..06e64699b 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -28,6 +28,7 @@ use File::Temp qw/ tempdir tempfile /;\n use File::Spec::Functions qw(catfile);\n use Error qw(:try);\n use Git;\n+use Git::I18N;\n \n Getopt::Long::Configure qw/ pass_through /;\n \n@@ -797,12 +798,12 @@ foreach my $f (@files) {\n }\n \n if (!defined $auto_8bit_encoding && scalar %broken_encoding) {\n-\tprint \"The following files are 8bit, but do not declare \" .\n-\t\t\"a Content-Transfer-Encoding.\\n\";\n+\tprint __(\"The following files are 8bit, but do not declare \" .\n+\t\t \"a Content-Transfer-Encoding.\\n\");\n \tforeach my $f (sort keys %broken_encoding) {\n \t\tprint \"    $f\\n\";\n \t}\n-\t$auto_8bit_encoding = ask(\"Which 8bit encoding should I declare [UTF-8]? \",\n+\t$auto_8bit_encoding = ask(__(\"Which 8bit encoding should I declare [UTF-8]? \"),\n \t\t\t\t  valid_re => qr/.{4}/, confirm_only => 1,\n \t\t\t\t  default => \"UTF-8\");\n }\n@@ -829,7 +830,7 @@ if (defined $sender) {\n # But it's a no-op to run sanitize_address on an already sanitized address.\n $sender = sanitize_address($sender);\n \n-my $to_whom = \"To whom should the emails be sent (if anyone)?\";\n+my $to_whom = __(\"To whom should the emails be sent (if anyone)?\");\n my $prompting = 0;\n if (!@initial_to && !defined $to_cmd) {\n \tmy $to = ask(\"$to_whom \",\n@@ -859,7 +860,7 @@ sub expand_one_alias {\n \n if ($thread && !defined $initial_reply_to && $prompting) {\n \t$initial_reply_to = ask(\n-\t\t\"Message-ID to be used as In-Reply-To for the first email (if any)? \",\n+\t\t__(\"Message-ID to be used as In-Reply-To for the first email (if any)? \"),\n \t\tdefault => \"\",\n \t\tvalid_re => qr/\\@.*\\./, confirm_only => 1);\n }\n@@ -918,7 +919,10 @@ sub validate_address {\n \tmy $address = shift;\n \twhile (!extract_valid_address($address)) {\n \t\tprint STDERR \"error: unable to extract a valid address from: $address\\n\";\n-\t\t$_ = ask(\"What to do with this address? ([q]uit|[d]rop|[e]dit): \",\n+\t\t# TRANSLATORS: Make sure to include [q] [d] [e] in your\n+\t\t# translation. The program will only accept English input\n+\t\t# at this point.\n+\t\t$_ = ask(__(\"What to do with this address? ([q]uit|[d]rop|[e]dit): \"),\n \t\t\tvalid_re => qr/^(?:quit|q|drop|d|edit|e)/i,\n \t\t\tdefault => 'q');\n \t\tif (/^d/i) {\n@@ -1293,17 +1297,23 @@ Message-Id: $message_id\n \t\tif ($needs_confirm eq \"inform\") {\n \t\t\t$confirm_unconfigured = 0; # squelch this message for the rest of this run\n \t\t\t$ask_default = \"y\"; # assume yes on EOF since user hasn't explicitly asked for confirmation\n-\t\t\tprint \"    The Cc list above has been expanded by additional\\n\";\n-\t\t\tprint \"    addresses found in the patch commit message. By default\\n\";\n-\t\t\tprint \"    send-email prompts before sending whenever this occurs.\\n\";\n-\t\t\tprint \"    This behavior is controlled by the sendemail.confirm\\n\";\n-\t\t\tprint \"    configuration setting.\\n\";\n-\t\t\tprint \"\\n\";\n-\t\t\tprint \"    For additional information, run 'git send-email --help'.\\n\";\n-\t\t\tprint \"    To retain the current behavior, but squelch this message,\\n\";\n-\t\t\tprint \"    run 'git config --global sendemail.confirm auto'.\\n\\n\";\n+\t\t\tprint __ <<EOF ;\n+    The Cc list above has been expanded by additional\n+    addresses found in the patch commit message. By default\n+    send-email prompts before sending whenever this occurs.\n+    This behavior is controlled by the sendemail.confirm\n+    configuration setting.\n+\n+    For additional information, run 'git send-email --help'.\n+    To retain the current behavior, but squelch this message,\n+    run 'git config --global sendemail.confirm auto'.\n+\n+EOF\n \t\t}\n-\t\t$_ = ask(\"Send this email? ([y]es|[n]o|[q]uit|[a]ll): \",\n+\t\t# TRANSLATORS: Make sure to include [y] [n] [q] [a] in your\n+\t\t# translation. The program will only accept English input\n+\t\t# at this point.\n+\t\t$_ = ask(__(\"Send this email? ([y]es|[n]o|[q]uit|[a]ll): \"),\n \t\t         valid_re => qr/^(?:yes|y|no|n|quit|q|all|a)/i,\n \t\t         default => $ask_default);\n \t\tdie \"Send this email reply required\" unless defined $_;\n@@ -1405,7 +1415,7 @@ Message-Id: $message_id\n \tif ($quiet) {\n \t\tprintf (($dry_run ? \"Dry-\" : \"\").\"Sent %s\\n\", $subject);\n \t} else {\n-\t\tprint (($dry_run ? \"Dry-\" : \"\").\"OK. Log says:\\n\");\n+\t\tprint($dry_run ? __(\"Dry-OK. Log says:\\n\") : __(\"OK. Log says:\\n\"));\n \t\tif (!file_name_is_absolute($smtp_server)) {\n \t\t\tprint \"Server: $smtp_server\\n\";\n \t\t\tprint \"MAIL FROM:<$raw_from>\\n\";\n@@ -1480,13 +1490,13 @@ foreach my $t (@files) {\n \t\t\t\t$sauthor = sanitize_address($author);\n \t\t\t\tnext if $suppress_cc{'author'};\n \t\t\t\tnext if $suppress_cc{'self'} and $sauthor eq $sender;\n-\t\t\t\tprintf(\"(mbox) Adding cc: %s from line '%s'\\n\",\n+\t\t\t\tprintf(__(\"(mbox) Adding cc: %s from line '%s'\\n\"),\n \t\t\t\t\t$1, $_) unless $quiet;\n \t\t\t\tpush @cc, $1;\n \t\t\t}\n \t\t\telsif (/^To:\\s+(.*)$/i) {\n \t\t\t\tforeach my $addr (parse_address_line($1)) {\n-\t\t\t\t\tprintf(\"(mbox) Adding to: %s from line '%s'\\n\",\n+\t\t\t\t\tprintf(__(\"(mbox) Adding to: %s from line '%s'\\n\"),\n \t\t\t\t\t\t$addr, $_) unless $quiet;\n \t\t\t\t\tpush @to, $addr;\n \t\t\t\t}\n@@ -1500,7 +1510,7 @@ foreach my $t (@files) {\n \t\t\t\t\t} else {\n \t\t\t\t\t\tnext if ($suppress_cc{'cc'});\n \t\t\t\t\t}\n-\t\t\t\t\tprintf(\"(mbox) Adding cc: %s from line '%s'\\n\",\n+\t\t\t\t\tprintf(__(\"(mbox) Adding cc: %s from line '%s'\\n\"),\n \t\t\t\t\t\t$addr, $_) unless $quiet;\n \t\t\t\t\tpush @cc, $addr;\n \t\t\t\t}\n@@ -1534,7 +1544,7 @@ foreach my $t (@files) {\n \t\t\t# So let's support that, too.\n \t\t\t$input_format = 'lots';\n \t\t\tif (@cc == 0 && !$suppress_cc{'cc'}) {\n-\t\t\t\tprintf(\"(non-mbox) Adding cc: %s from line '%s'\\n\",\n+\t\t\t\tprintf(__(\"(non-mbox) Adding cc: %s from line '%s'\\n\"),\n \t\t\t\t\t$_, $_) unless $quiet;\n \t\t\t\tpush @cc, $_;\n \t\t\t} elsif (!defined $subject) {\n@@ -1557,7 +1567,7 @@ foreach my $t (@files) {\n \t\t\t\tnext if $suppress_cc{'bodycc'} and $what =~ /Cc/i;\n \t\t\t}\n \t\t\tpush @cc, $c;\n-\t\t\tprintf(\"(body) Adding cc: %s from line '%s'\\n\",\n+\t\t\tprintf(__(\"(body) Adding cc: %s from line '%s'\\n\"),\n \t\t\t\t$c, $_) unless $quiet;\n \t\t}\n \t}\n-- \n2.11.0.rc0.33.gec17dab\n\n"},{"id":"305776","messageId":"20161111124541.8216-14-vascomalmeida@sapo.pt","threadId":"44461","inReplyTo":"20161111124541.8216-1-vascomalmeida@sapo.pt","subject":"[PATCH v6 13/16] i18n: send-email: mark warnings and errors for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-11-11T12:45:38Z","receivedAt":"2016-11-11T12:46:19Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark warnings, errors and other messages for translation.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-send-email.perl | 34 +++++++++++++++++-----------------\n 1 file changed, 17 insertions(+), 17 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 06e64699b..00d234e11 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -118,20 +118,20 @@ sub format_2822_time {\n \tmy $localmin = $localtm[1] + $localtm[2] * 60;\n \tmy $gmtmin = $gmttm[1] + $gmttm[2] * 60;\n \tif ($localtm[0] != $gmttm[0]) {\n-\t\tdie \"local zone differs from GMT by a non-minute interval\\n\";\n+\t\tdie __(\"local zone differs from GMT by a non-minute interval\\n\");\n \t}\n \tif ((($gmttm[6] + 1) % 7) == $localtm[6]) {\n \t\t$localmin += 1440;\n \t} elsif ((($gmttm[6] - 1) % 7) == $localtm[6]) {\n \t\t$localmin -= 1440;\n \t} elsif ($gmttm[6] != $localtm[6]) {\n-\t\tdie \"local time offset greater than or equal to 24 hours\\n\";\n+\t\tdie __(\"local time offset greater than or equal to 24 hours\\n\");\n \t}\n \tmy $offset = $localmin - $gmtmin;\n \tmy $offhour = $offset / 60;\n \tmy $offmin = abs($offset % 60);\n \tif (abs($offhour) >= 24) {\n-\t\tdie (\"local time offset greater than or equal to 24 hours\\n\");\n+\t\tdie __(\"local time offset greater than or equal to 24 hours\\n\");\n \t}\n \n \treturn sprintf(\"%s, %2d %s %d %02d:%02d:%02d %s%02d%02d\",\n@@ -199,13 +199,13 @@ sub do_edit {\n \t\tmap {\n \t\t\tsystem('sh', '-c', $editor.' \"$@\"', $editor, $_);\n \t\t\tif (($? & 127) || ($? >> 8)) {\n-\t\t\t\tdie(\"the editor exited uncleanly, aborting everything\");\n+\t\t\t\tdie(__(\"the editor exited uncleanly, aborting everything\"));\n \t\t\t}\n \t\t} @_;\n \t} else {\n \t\tsystem('sh', '-c', $editor.' \"$@\"', $editor, @_);\n \t\tif (($? & 127) || ($? >> 8)) {\n-\t\t\tdie(\"the editor exited uncleanly, aborting everything\");\n+\t\t\tdie(__(\"the editor exited uncleanly, aborting everything\"));\n \t\t}\n \t}\n }\n@@ -299,7 +299,7 @@ my $help;\n my $rc = GetOptions(\"h\" => \\$help,\n                     \"dump-aliases\" => \\$dump_aliases);\n usage() unless $rc;\n-die \"--dump-aliases incompatible with other options\\n\"\n+die __(\"--dump-aliases incompatible with other options\\n\")\n     if !$help and $dump_aliases and @ARGV;\n $rc = GetOptions(\n \t\t    \"sender|from=s\" => \\$sender,\n@@ -362,7 +362,7 @@ unless ($rc) {\n     usage();\n }\n \n-die \"Cannot run git format-patch from outside a repository\\n\"\n+die __(\"Cannot run git format-patch from outside a repository\\n\")\n \tif $format_patch and not $repo;\n \n # Now, let's fill any that aren't set in with defaults:\n@@ -617,7 +617,7 @@ while (defined(my $f = shift @ARGV)) {\n }\n \n if (@rev_list_opts) {\n-\tdie \"Cannot run git format-patch from outside a repository\\n\"\n+\tdie __(\"Cannot run git format-patch from outside a repository\\n\")\n \t\tunless $repo;\n \tpush @files, $repo->command('format-patch', '-o', tempdir(CLEANUP => 1), @rev_list_opts);\n }\n@@ -638,7 +638,7 @@ if (@files) {\n \t\tprint $_,\"\\n\" for (@files);\n \t}\n } else {\n-\tprint STDERR \"\\nNo patch files specified!\\n\\n\";\n+\tprint STDERR __(\"\\nNo patch files specified!\\n\\n\");\n \tusage();\n }\n \n@@ -730,7 +730,7 @@ EOT\n \t\t\t$sender = $1;\n \t\t\tnext;\n \t\t} elsif (/^(?:To|Cc|Bcc):/i) {\n-\t\t\tprint \"To/Cc/Bcc fields are not interpreted yet, they have been ignored\\n\";\n+\t\t\tprint __(\"To/Cc/Bcc fields are not interpreted yet, they have been ignored\\n\");\n \t\t\tnext;\n \t\t}\n \t\tprint $c2 $_;\n@@ -739,7 +739,7 @@ EOT\n \tclose $c2;\n \n \tif ($summary_empty) {\n-\t\tprint \"Summary email is empty, skipping it\\n\";\n+\t\tprint __(\"Summary email is empty, skipping it\\n\");\n \t\t$compose = -1;\n \t}\n } elsif ($annotate) {\n@@ -1316,7 +1316,7 @@ EOF\n \t\t$_ = ask(__(\"Send this email? ([y]es|[n]o|[q]uit|[a]ll): \"),\n \t\t         valid_re => qr/^(?:yes|y|no|n|quit|q|all|a)/i,\n \t\t         default => $ask_default);\n-\t\tdie \"Send this email reply required\" unless defined $_;\n+\t\tdie __(\"Send this email reply required\") unless defined $_;\n \t\tif (/^n/i) {\n \t\t\treturn 0;\n \t\t} elsif (/^q/i) {\n@@ -1342,7 +1342,7 @@ EOF\n \t} else {\n \n \t\tif (!defined $smtp_server) {\n-\t\t\tdie \"The required SMTP server is not properly defined.\"\n+\t\t\tdie __(\"The required SMTP server is not properly defined.\")\n \t\t}\n \n \t\tif ($smtp_encryption eq 'ssl') {\n@@ -1427,10 +1427,10 @@ EOF\n \t\t}\n \t\tprint $header, \"\\n\";\n \t\tif ($smtp) {\n-\t\t\tprint \"Result: \", $smtp->code, ' ',\n+\t\t\tprint __(\"Result: \"), $smtp->code, ' ',\n \t\t\t\t($smtp->message =~ /\\n([^\\n]+\\n)$/s), \"\\n\";\n \t\t} else {\n-\t\t\tprint \"Result: OK\\n\";\n+\t\t\tprint __(\"Result: OK\\n\");\n \t\t}\n \t}\n \n@@ -1703,7 +1703,7 @@ sub apply_transfer_encoding {\n \t$message = MIME::Base64::decode($message)\n \t\tif ($from eq 'base64');\n \n-\tdie \"cannot send message as 7bit\"\n+\tdie __(\"cannot send message as 7bit\")\n \t\tif ($to eq '7bit' and $message =~ /[^[:ascii:]]/);\n \treturn $message\n \t\tif ($to eq '7bit' or $to eq '8bit');\n@@ -1711,7 +1711,7 @@ sub apply_transfer_encoding {\n \t\tif ($to eq 'quoted-printable');\n \treturn MIME::Base64::encode($message, \"\\n\")\n \t\tif ($to eq 'base64');\n-\tdie \"invalid transfer encoding\";\n+\tdie __(\"invalid transfer encoding\");\n }\n \n sub unique_email_list {\n-- \n2.11.0.rc0.33.gec17dab\n\n"},{"id":"305777","messageId":"20161111124541.8216-16-vascomalmeida@sapo.pt","threadId":"44461","inReplyTo":"20161111124541.8216-1-vascomalmeida@sapo.pt","subject":"[PATCH v6 15/16] i18n: send-email: mark composing message for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-11-11T12:45:40Z","receivedAt":"2016-11-11T12:46:20Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"When composing an e-mail, there is a message for the user whose lines\nare beginning in \"GIT:\" that can be marked for translation.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-send-email.perl | 16 +++++++++-------\n 1 file changed, 9 insertions(+), 7 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 7f3297cdf..068d60b3e 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -672,18 +672,20 @@ if ($compose) {\n \tmy $tpl_subject = $initial_subject || '';\n \tmy $tpl_reply_to = $initial_reply_to || '';\n \n-\tprint $c <<EOT;\n+\tprint $c <<EOT1, Git::prefix_lines(\"GIT: \", __ <<EOT2), <<EOT3;\n From $tpl_sender # This line is ignored.\n-GIT: Lines beginning in \"GIT:\" will be removed.\n-GIT: Consider including an overall diffstat or table of contents\n-GIT: for the patch you are writing.\n-GIT:\n-GIT: Clear the body content if you don't wish to send a summary.\n+EOT1\n+Lines beginning in \"GIT:\" will be removed.\n+Consider including an overall diffstat or table of contents\n+for the patch you are writing.\n+\n+Clear the body content if you don't wish to send a summary.\n+EOT2\n From: $tpl_sender\n Subject: $tpl_subject\n In-Reply-To: $tpl_reply_to\n \n-EOT\n+EOT3\n \tfor my $f (@files) {\n \t\tprint $c get_patch_subject($f);\n \t}\n-- \n2.11.0.rc0.33.gec17dab\n\n"},{"id":"305778","messageId":"20161111124541.8216-9-vascomalmeida@sapo.pt","threadId":"44461","inReplyTo":"20161111124541.8216-1-vascomalmeida@sapo.pt","subject":"[PATCH v6 08/16] i18n: add--interactive: i18n of help_patch_cmd","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-11-11T12:45:33Z","receivedAt":"2016-11-11T12:46:26Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark help message of help_patch_cmd for translation.  The message must\nbe unfolded to be free of variables so we can have high quality\ntranslations.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-add--interactive.perl | 54 ++++++++++++++++++++++++++++++++++++++++-------\n 1 file changed, 46 insertions(+), 8 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex b7d382b10..045b847cf 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -1189,15 +1189,53 @@ sub edit_hunk_loop {\n \t}\n }\n \n+my %help_patch_modes = (\n+\tstage => N__(\n+\"y - stage this hunk\n+n - do not stage this hunk\n+q - quit; do not stage this hunk or any of the remaining ones\n+a - stage this hunk and all later hunks in the file\n+d - do not stage this hunk or any of the later hunks in the file\"),\n+\tstash => N__(\n+\"y - stash this hunk\n+n - do not stash this hunk\n+q - quit; do not stash this hunk or any of the remaining ones\n+a - stash this hunk and all later hunks in the file\n+d - do not stash this hunk or any of the later hunks in the file\"),\n+\treset_head => N__(\n+\"y - unstage this hunk\n+n - do not unstage this hunk\n+q - quit; do not unstage this hunk or any of the remaining ones\n+a - unstage this hunk and all later hunks in the file\n+d - do not unstage this hunk or any of the later hunks in the file\"),\n+\treset_nothead => N__(\n+\"y - apply this hunk to index\n+n - do not apply this hunk to index\n+q - quit; do not apply this hunk or any of the remaining ones\n+a - apply this hunk and all later hunks in the file\n+d - do not apply this hunk or any of the later hunks in the file\"),\n+\tcheckout_index => N__(\n+\"y - discard this hunk from worktree\n+n - do not discard this hunk from worktree\n+q - quit; do not discard this hunk or any of the remaining ones\n+a - discard this hunk and all later hunks in the file\n+d - do not discard this hunk or any of the later hunks in the file\"),\n+\tcheckout_head => N__(\n+\"y - discard this hunk from index and worktree\n+n - do not discard this hunk from index and worktree\n+q - quit; do not discard this hunk or any of the remaining ones\n+a - discard this hunk and all later hunks in the file\n+d - do not discard this hunk or any of the later hunks in the file\"),\n+\tcheckout_nothead => N__(\n+\"y - apply this hunk to index and worktree\n+n - do not apply this hunk to index and worktree\n+q - quit; do not apply this hunk or any of the remaining ones\n+a - apply this hunk and all later hunks in the file\n+d - do not apply this hunk or any of the later hunks in the file\"),\n+);\n+\n sub help_patch_cmd {\n-\tmy $verb = lc $patch_mode_flavour{VERB};\n-\tmy $target = $patch_mode_flavour{TARGET};\n-\tprint colored $help_color, <<EOF ;\n-y - $verb this hunk$target\n-n - do not $verb this hunk$target\n-q - quit; do not $verb this hunk or any of the remaining ones\n-a - $verb this hunk and all later hunks in the file\n-d - do not $verb this hunk or any of the later hunks in the file\n+\tprint colored $help_color, __($help_patch_modes{$patch_mode}), \"\\n\", __ <<EOF ;\n g - select a hunk to go to\n / - search for a hunk matching the given regex\n j - leave this hunk undecided, see next undecided hunk\n-- \n2.11.0.rc0.33.gec17dab\n\n"},{"id":"305779","messageId":"20161111124541.8216-15-vascomalmeida@sapo.pt","threadId":"44461","inReplyTo":"20161111124541.8216-1-vascomalmeida@sapo.pt","subject":"[PATCH v6 14/16] i18n: send-email: mark string with interpolation for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-11-11T12:45:39Z","receivedAt":"2016-11-11T12:46:29Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark warnings, errors and other messages that are interpolated for\ntranslation.\n\nWe call sprintf() before calling die() and in few other circumstances in\norder to replace the values on the placeholders.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-send-email.perl | 87 +++++++++++++++++++++++++++++------------------------\n 1 file changed, 47 insertions(+), 40 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 00d234e11..7f3297cdf 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -279,10 +279,13 @@ sub signal_handler {\n \t# tmp files from --compose\n \tif (defined $compose_filename) {\n \t\tif (-e $compose_filename) {\n-\t\t\tprint \"'$compose_filename' contains an intermediate version of the email you were composing.\\n\";\n+\t\t\tprintf __(\"'%s' contains an intermediate version \".\n+\t\t\t\t  \"of the email you were composing.\\n\"),\n+\t\t\t\t  $compose_filename;\n \t\t}\n \t\tif (-e ($compose_filename . \".final\")) {\n-\t\t\tprint \"'$compose_filename.final' contains the composed email.\\n\"\n+\t\t\tprintf __(\"'%s.final' contains the composed email.\\n\"),\n+\t\t\t\t  $compose_filename;\n \t\t}\n \t}\n \n@@ -431,7 +434,7 @@ $smtp_encryption = '' unless (defined $smtp_encryption);\n my(%suppress_cc);\n if (@suppress_cc) {\n \tforeach my $entry (@suppress_cc) {\n-\t\tdie \"Unknown --suppress-cc field: '$entry'\\n\"\n+\t\tdie sprintf(__(\"Unknown --suppress-cc field: '%s'\\n\"), $entry)\n \t\t\tunless $entry =~ /^(?:all|cccmd|cc|author|self|sob|body|bodycc)$/;\n \t\t$suppress_cc{$entry} = 1;\n \t}\n@@ -460,7 +463,7 @@ my $confirm_unconfigured = !defined $confirm;\n if ($confirm_unconfigured) {\n \t$confirm = scalar %suppress_cc ? 'compose' : 'auto';\n };\n-die \"Unknown --confirm setting: '$confirm'\\n\"\n+die sprintf(__(\"Unknown --confirm setting: '%s'\\n\"), $confirm)\n \tunless $confirm =~ /^(?:auto|cc|compose|always|never)/;\n \n # Debugging, print out the suppressions.\n@@ -492,16 +495,16 @@ my %aliases;\n sub parse_sendmail_alias {\n \tlocal $_ = shift;\n \tif (/\"/) {\n-\t\tprint STDERR \"warning: sendmail alias with quotes is not supported: $_\\n\";\n+\t\tprintf STDERR __(\"warning: sendmail alias with quotes is not supported: %s\\n\"), $_;\n \t} elsif (/:include:/) {\n-\t\tprint STDERR \"warning: `:include:` not supported: $_\\n\";\n+\t\tprintf STDERR __(\"warning: `:include:` not supported: %s\\n\"), $_;\n \t} elsif (/[\\/|]/) {\n-\t\tprint STDERR \"warning: `/file` or `|pipe` redirection not supported: $_\\n\";\n+\t\tprintf STDERR __(\"warning: `/file` or `|pipe` redirection not supported: %s\\n\"), $_;\n \t} elsif (/^(\\S+?)\\s*:\\s*(.+)$/) {\n \t\tmy ($alias, $addr) = ($1, $2);\n \t\t$aliases{$alias} = [ split_addrs($addr) ];\n \t} else {\n-\t\tprint STDERR \"warning: sendmail line is not recognized: $_\\n\";\n+\t\tprintf STDERR __(\"warning: sendmail line is not recognized: %s\\n\"), $_;\n \t}\n }\n \n@@ -582,11 +585,11 @@ sub is_format_patch_arg {\n \t\tif (defined($format_patch)) {\n \t\t\treturn $format_patch;\n \t\t}\n-\t\tdie(<<EOF);\n-File '$f' exists but it could also be the range of commits\n+\t\tdie sprintf(__ <<EOF, $f, $f);\n+File '%s' exists but it could also be the range of commits\n to produce patches for.  Please disambiguate by...\n \n-    * Saying \"./$f\" if you mean a file; or\n+    * Saying \"./%s\" if you mean a file; or\n     * Giving --format-patch option if you mean a range.\n EOF\n \t} catch Git::Error::Command with {\n@@ -604,7 +607,7 @@ while (defined(my $f = shift @ARGV)) {\n \t\t@ARGV = ();\n \t} elsif (-d $f and !is_format_patch_arg($f)) {\n \t\topendir my $dh, $f\n-\t\t\tor die \"Failed to opendir $f: $!\";\n+\t\t\tor die sprintf(__(\"Failed to opendir %s: %s\"), $f, $!);\n \n \t\tpush @files, grep { -f $_ } map { catfile($f, $_) }\n \t\t\t\tsort readdir $dh;\n@@ -628,7 +631,8 @@ if ($validate) {\n \tforeach my $f (@files) {\n \t\tunless (-p $f) {\n \t\t\tmy $error = validate_patch($f);\n-\t\t\t$error and die \"fatal: $f: $error\\nwarning: no patches were sent\\n\";\n+\t\t\t$error and die sprintf(__(\"fatal: %s: %s\\nwarning: no patches were sent\\n\"),\n+\t\t\t\t\t\t  $f, $error);\n \t\t}\n \t}\n }\n@@ -651,7 +655,7 @@ sub get_patch_subject {\n \t\treturn \"GIT: $1\\n\";\n \t}\n \tclose $fh;\n-\tdie \"No subject line in $fn ?\";\n+\tdie sprintf(__(\"No subject line in %s?\"), $fn);\n }\n \n if ($compose) {\n@@ -661,7 +665,7 @@ if ($compose) {\n \t\ttempfile(\".gitsendemail.msg.XXXXXX\", DIR => $repo->repo_path()) :\n \t\ttempfile(\".gitsendemail.msg.XXXXXX\", DIR => \".\"))[1];\n \topen my $c, \">\", $compose_filename\n-\t\tor die \"Failed to open for writing $compose_filename: $!\";\n+\t\tor die sprintf(__(\"Failed to open for writing %s: %s\"), $compose_filename, $!);\n \n \n \tmy $tpl_sender = $sender || $repoauthor || $repocommitter || '';\n@@ -692,10 +696,10 @@ EOT\n \t}\n \n \topen my $c2, \">\", $compose_filename . \".final\"\n-\t\tor die \"Failed to open $compose_filename.final : \" . $!;\n+\t\tor die sprintf(__(\"Failed to open %s.final: %s\"), $compose_filename, $!);\n \n \topen $c, \"<\", $compose_filename\n-\t\tor die \"Failed to open $compose_filename : \" . $!;\n+\t\tor die sprintf(__(\"Failed to open %s: %s\"), $compose_filename, $!);\n \n \tmy $need_8bit_cte = file_has_nonascii($compose_filename);\n \tmy $in_body = 0;\n@@ -769,7 +773,9 @@ sub ask {\n \t\t\treturn $resp;\n \t\t}\n \t\tif ($confirm_only) {\n-\t\t\tmy $yesno = $term->readline(\"Are you sure you want to use <$resp> [y/N]? \");\n+\t\t\tmy $yesno = $term->readline(\n+\t\t\t\t# TRANSLATORS: please keep [y/N] as is.\n+\t\t\t\tsprintf(__(\"Are you sure you want to use <%s> [y/N]? \"), $resp));\n \t\t\tif (defined $yesno && $yesno =~ /y/i) {\n \t\t\t\treturn $resp;\n \t\t\t}\n@@ -811,9 +817,9 @@ if (!defined $auto_8bit_encoding && scalar %broken_encoding) {\n if (!$force) {\n \tfor my $f (@files) {\n \t\tif (get_patch_subject($f) =~ /\\Q*** SUBJECT HERE ***\\E/) {\n-\t\t\tdie \"Refusing to send because the patch\\n\\t$f\\n\"\n+\t\t\tdie sprintf(__(\"Refusing to send because the patch\\n\\t%s\\n\"\n \t\t\t\t. \"has the template subject '*** SUBJECT HERE ***'. \"\n-\t\t\t\t. \"Pass --force if you really want to send.\\n\";\n+\t\t\t\t. \"Pass --force if you really want to send.\\n\"), $f);\n \t\t}\n \t}\n }\n@@ -848,7 +854,7 @@ my %EXPANDED_ALIASES;\n sub expand_one_alias {\n \tmy $alias = shift;\n \tif ($EXPANDED_ALIASES{$alias}) {\n-\t\tdie \"fatal: alias '$alias' expands to itself\\n\";\n+\t\tdie sprintf(__(\"fatal: alias '%s' expands to itself\\n\"), $alias);\n \t}\n \tlocal $EXPANDED_ALIASES{$alias} = 1;\n \treturn $aliases{$alias} ? expand_aliases(@{$aliases{$alias}}) : $alias;\n@@ -910,7 +916,7 @@ sub extract_valid_address {\n sub extract_valid_address_or_die {\n \tmy $address = shift;\n \t$address = extract_valid_address($address);\n-\tdie \"error: unable to extract a valid address from: $address\\n\"\n+\tdie sprintf(__(\"error: unable to extract a valid address from: %s\\n\"), $address)\n \t\tif !$address;\n \treturn $address;\n }\n@@ -918,7 +924,7 @@ sub extract_valid_address_or_die {\n sub validate_address {\n \tmy $address = shift;\n \twhile (!extract_valid_address($address)) {\n-\t\tprint STDERR \"error: unable to extract a valid address from: $address\\n\";\n+\t\tprintf STDERR __(\"error: unable to extract a valid address from: %s\\n\"), $address;\n \t\t# TRANSLATORS: Make sure to include [q] [d] [e] in your\n \t\t# translation. The program will only accept English input\n \t\t# at this point.\n@@ -1223,7 +1229,7 @@ sub ssl_verify_params {\n \t\treturn (SSL_verify_mode => SSL_VERIFY_PEER(),\n \t\t\tSSL_ca_file => $smtp_ssl_cert_path);\n \t} else {\n-\t\tdie \"CA path \\\"$smtp_ssl_cert_path\\\" does not exist\";\n+\t\tdie sprintf(__(\"CA path \\\"%s\\\" does not exist\"), $smtp_ssl_cert_path);\n \t}\n }\n \n@@ -1386,14 +1392,14 @@ EOF\n \t\t\t\t\t# supported commands\n \t\t\t\t\t$smtp->hello($smtp_domain);\n \t\t\t\t} else {\n-\t\t\t\t\tdie \"Server does not support STARTTLS! \".$smtp->message;\n+\t\t\t\t\tdie sprintf(__(\"Server does not support STARTTLS! %s\"), $smtp->message);\n \t\t\t\t}\n \t\t\t}\n \t\t}\n \n \t\tif (!$smtp) {\n-\t\t\tdie \"Unable to initialize SMTP properly. Check config and use --smtp-debug. \",\n-\t\t\t    \"VALUES: server=$smtp_server \",\n+\t\t\tdie __(\"Unable to initialize SMTP properly. Check config and use --smtp-debug.\"),\n+\t\t\t    \" VALUES: server=$smtp_server \",\n \t\t\t    \"encryption=$smtp_encryption \",\n \t\t\t    \"hello=$smtp_domain\",\n \t\t\t    defined $smtp_server_port ? \" port=$smtp_server_port\" : \"\";\n@@ -1410,10 +1416,10 @@ EOF\n \t\t\t$smtp->datasend(\"$line\") or die $smtp->message;\n \t\t}\n \t\t$smtp->dataend() or die $smtp->message;\n-\t\t$smtp->code =~ /250|200/ or die \"Failed to send $subject\\n\".$smtp->message;\n+\t\t$smtp->code =~ /250|200/ or die sprintf(__(\"Failed to send %s\\n\"), $subject).$smtp->message;\n \t}\n \tif ($quiet) {\n-\t\tprintf (($dry_run ? \"Dry-\" : \"\").\"Sent %s\\n\", $subject);\n+\t\tprintf($dry_run ? __(\"Dry-Sent %s\\n\") : __(\"Sent %s\\n\"), $subject);\n \t} else {\n \t\tprint($dry_run ? __(\"Dry-OK. Log says:\\n\") : __(\"OK. Log says:\\n\"));\n \t\tif (!file_name_is_absolute($smtp_server)) {\n@@ -1443,7 +1449,7 @@ $subject = $initial_subject;\n $message_num = 0;\n \n foreach my $t (@files) {\n-\topen my $fh, \"<\", $t or die \"can't open file $t\";\n+\topen my $fh, \"<\", $t or die sprintf(__(\"can't open file %s\"), $t);\n \n \tmy $author = undef;\n \tmy $sauthor = undef;\n@@ -1665,18 +1671,18 @@ sub recipients_cmd {\n \n \tmy @addresses = ();\n \topen my $fh, \"-|\", \"$cmd \\Q$file\\E\"\n-\t    or die \"($prefix) Could not execute '$cmd'\";\n+\t    or die sprintf(__(\"(%s) Could not execute '%s'\"), $prefix, $cmd);\n \twhile (my $address = <$fh>) {\n \t\t$address =~ s/^\\s*//g;\n \t\t$address =~ s/\\s*$//g;\n \t\t$address = sanitize_address($address);\n \t\tnext if ($address eq $sender and $suppress_cc{'self'});\n \t\tpush @addresses, $address;\n-\t\tprintf(\"($prefix) Adding %s: %s from: '%s'\\n\",\n-\t\t       $what, $address, $cmd) unless $quiet;\n+\t\tprintf(__(\"(%s) Adding %s: %s from: '%s'\\n\"),\n+\t\t       $prefix, $what, $address, $cmd) unless $quiet;\n \t\t}\n \tclose $fh\n-\t    or die \"($prefix) failed to close pipe to '$cmd'\";\n+\t    or die sprintf(__(\"(%s) failed to close pipe to '%s'\"), $prefix, $cmd);\n \treturn @addresses;\n }\n \n@@ -1730,10 +1736,10 @@ sub unique_email_list {\n sub validate_patch {\n \tmy $fn = shift;\n \topen(my $fh, '<', $fn)\n-\t\tor die \"unable to open $fn: $!\\n\";\n+\t\tor die sprintf(__(\"unable to open %s: %s\\n\"), $fn, $!);\n \twhile (my $line = <$fh>) {\n \t\tif (length($line) > 998) {\n-\t\t\treturn \"$.: patch contains a line longer than 998 characters\";\n+\t\t\treturn sprintf(__(\"%s: patch contains a line longer than 998 characters\"), $.);\n \t\t}\n \t}\n \treturn;\n@@ -1749,10 +1755,11 @@ sub handle_backup {\n \t    (substr($file, 0, $lastlen) eq $last) &&\n \t    ($suffix = substr($file, $lastlen)) !~ /^[a-z0-9]/i) {\n \t\tif (defined $known_suffix && $suffix eq $known_suffix) {\n-\t\t\tprint \"Skipping $file with backup suffix '$known_suffix'.\\n\";\n+\t\t\tprintf(__(\"Skipping %s with backup suffix '%s'.\\n\"), $file, $known_suffix);\n \t\t\t$skip = 1;\n \t\t} else {\n-\t\t\tmy $answer = ask(\"Do you really want to send $file? (y|N): \",\n+\t\t\t# TRANSLATORS: please keep \"[y|N]\" as is.\n+\t\t\tmy $answer = ask(sprintf(__(\"Do you really want to send %s? [y|N]: \"), $file),\n \t\t\t\t\t valid_re => qr/^(?:y|n)/i,\n \t\t\t\t\t default => 'n');\n \t\t\t$skip = ($answer ne 'y');\n@@ -1780,7 +1787,7 @@ sub handle_backup_files {\n sub file_has_nonascii {\n \tmy $fn = shift;\n \topen(my $fh, '<', $fn)\n-\t\tor die \"unable to open $fn: $!\\n\";\n+\t\tor die sprintf(__(\"unable to open %s: %s\\n\"), $fn, $!);\n \twhile (my $line = <$fh>) {\n \t\treturn 1 if $line =~ /[^[:ascii:]]/;\n \t}\n@@ -1790,7 +1797,7 @@ sub file_has_nonascii {\n sub body_or_subject_has_nonascii {\n \tmy $fn = shift;\n \topen(my $fh, '<', $fn)\n-\t\tor die \"unable to open $fn: $!\\n\";\n+\t\tor die sprintf(__(\"unable to open %s: %s\\n\"), $fn, $!);\n \twhile (my $line = <$fh>) {\n \t\tlast if $line =~ /^$/;\n \t\treturn 1 if $line =~ /^Subject.*[^[:ascii:]]/;\n-- \n2.11.0.rc0.33.gec17dab\n\n"},{"id":"305780","messageId":"20161111124541.8216-17-vascomalmeida@sapo.pt","threadId":"44461","inReplyTo":"20161111124541.8216-1-vascomalmeida@sapo.pt","subject":"[PATCH v6 16/16] i18n: difftool: mark warnings for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-11-11T12:45:41Z","receivedAt":"2016-11-11T12:46:30Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-difftool.perl | 22 ++++++++++++----------\n 1 file changed, 12 insertions(+), 10 deletions(-)\n\ndiff --git a/git-difftool.perl b/git-difftool.perl\nindex a5790d03a..8d3632e55 100755\n--- a/git-difftool.perl\n+++ b/git-difftool.perl\n@@ -22,6 +22,7 @@ use File::Path qw(mkpath rmtree);\n use File::Temp qw(tempdir);\n use Getopt::Long qw(:config pass_through);\n use Git;\n+use Git::I18N;\n \n sub usage\n {\n@@ -122,7 +123,7 @@ sub setup_dir_diff\n \tmy $i = 0;\n \twhile ($i < $#rawdiff) {\n \t\tif ($rawdiff[$i] =~ /^::/) {\n-\t\t\twarn << 'EOF';\n+\t\t\twarn __ <<'EOF';\n Combined diff formats ('-c' and '--cc') are not supported in\n directory diff mode ('-d' and '--dir-diff').\n EOF\n@@ -338,7 +339,7 @@ sub main\n \t\tif (length($opts{difftool_cmd}) > 0) {\n \t\t\t$ENV{GIT_DIFF_TOOL} = $opts{difftool_cmd};\n \t\t} else {\n-\t\t\tprint \"No <tool> given for --tool=<tool>\\n\";\n+\t\t\tprint __(\"No <tool> given for --tool=<tool>\\n\");\n \t\t\tusage(1);\n \t\t}\n \t}\n@@ -346,7 +347,7 @@ sub main\n \t\tif (length($opts{extcmd}) > 0) {\n \t\t\t$ENV{GIT_DIFFTOOL_EXTCMD} = $opts{extcmd};\n \t\t} else {\n-\t\t\tprint \"No <cmd> given for --extcmd=<cmd>\\n\";\n+\t\t\tprint __(\"No <cmd> given for --extcmd=<cmd>\\n\");\n \t\t\tusage(1);\n \t\t}\n \t}\n@@ -419,11 +420,11 @@ sub dir_diff\n \t\t}\n \n \t\tif (exists $wt_modified{$file} and exists $tmp_modified{$file}) {\n-\t\t\tmy $errmsg = \"warning: Both files modified: \";\n-\t\t\t$errmsg .= \"'$workdir/$file' and '$b/$file'.\\n\";\n-\t\t\t$errmsg .= \"warning: Working tree file has been left.\\n\";\n-\t\t\t$errmsg .= \"warning:\\n\";\n-\t\t\twarn $errmsg;\n+\t\t\twarn sprintf(__(\n+\t\t\t\t\"warning: Both files modified:\\n\" .\n+\t\t\t\t\"'%s/%s' and '%s/%s'.\\n\" .\n+\t\t\t\t\"warning: Working tree file has been left.\\n\" .\n+\t\t\t\t\"warning:\\n\"), $workdir, $file, $b, $file);\n \t\t\t$error = 1;\n \t\t} elsif (exists $tmp_modified{$file}) {\n \t\t\tmy $mode = stat(\"$b/$file\")->mode;\n@@ -435,8 +436,9 @@ sub dir_diff\n \t\t}\n \t}\n \tif ($error) {\n-\t\twarn \"warning: Temporary files exist in '$tmpdir'.\\n\";\n-\t\twarn \"warning: You may want to cleanup or recover these.\\n\";\n+\t\twarn sprintf(__(\n+\t\t\t\"warning: Temporary files exist in '%s'.\\n\" .\n+\t\t\t\"warning: You may want to cleanup or recover these.\\n\"), $tmpdir);\n \t\texit(1);\n \t} else {\n \t\texit_cleanup($tmpdir, $rc);\n-- \n2.11.0.rc0.33.gec17dab\n\n"},{"id":"305781","messageId":"20161111124541.8216-11-vascomalmeida@sapo.pt","threadId":"44461","inReplyTo":"20161111124541.8216-1-vascomalmeida@sapo.pt","subject":"[PATCH v6 10/16] i18n: add--interactive: remove %patch_modes entries","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-11-11T12:45:35Z","receivedAt":"2016-11-11T12:46:31Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Remove unnecessary entries from %patch_modes. After the i18n conversion,\nthese entries are not used anymore.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-add--interactive.perl | 21 ---------------------\n 1 file changed, 21 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 7d1cc5652..5f6637bde 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -106,9 +106,6 @@ my %patch_modes = (\n \t\tDIFF => 'diff-files -p',\n \t\tAPPLY => sub { apply_patch 'apply --cached', @_; },\n \t\tAPPLY_CHECK => 'apply --cached',\n-\t\tVERB => 'Stage',\n-\t\tTARGET => '',\n-\t\tPARTICIPLE => 'staging',\n \t\tFILTER => 'file-only',\n \t\tIS_REVERSE => 0,\n \t},\n@@ -116,9 +113,6 @@ my %patch_modes = (\n \t\tDIFF => 'diff-index -p HEAD',\n \t\tAPPLY => sub { apply_patch 'apply --cached', @_; },\n \t\tAPPLY_CHECK => 'apply --cached',\n-\t\tVERB => 'Stash',\n-\t\tTARGET => '',\n-\t\tPARTICIPLE => 'stashing',\n \t\tFILTER => undef,\n \t\tIS_REVERSE => 0,\n \t},\n@@ -126,9 +120,6 @@ my %patch_modes = (\n \t\tDIFF => 'diff-index -p --cached',\n \t\tAPPLY => sub { apply_patch 'apply -R --cached', @_; },\n \t\tAPPLY_CHECK => 'apply -R --cached',\n-\t\tVERB => 'Unstage',\n-\t\tTARGET => '',\n-\t\tPARTICIPLE => 'unstaging',\n \t\tFILTER => 'index-only',\n \t\tIS_REVERSE => 1,\n \t},\n@@ -136,9 +127,6 @@ my %patch_modes = (\n \t\tDIFF => 'diff-index -R -p --cached',\n \t\tAPPLY => sub { apply_patch 'apply --cached', @_; },\n \t\tAPPLY_CHECK => 'apply --cached',\n-\t\tVERB => 'Apply',\n-\t\tTARGET => ' to index',\n-\t\tPARTICIPLE => 'applying',\n \t\tFILTER => 'index-only',\n \t\tIS_REVERSE => 0,\n \t},\n@@ -146,9 +134,6 @@ my %patch_modes = (\n \t\tDIFF => 'diff-files -p',\n \t\tAPPLY => sub { apply_patch 'apply -R', @_; },\n \t\tAPPLY_CHECK => 'apply -R',\n-\t\tVERB => 'Discard',\n-\t\tTARGET => ' from worktree',\n-\t\tPARTICIPLE => 'discarding',\n \t\tFILTER => 'file-only',\n \t\tIS_REVERSE => 1,\n \t},\n@@ -156,9 +141,6 @@ my %patch_modes = (\n \t\tDIFF => 'diff-index -p',\n \t\tAPPLY => sub { apply_patch_for_checkout_commit '-R', @_ },\n \t\tAPPLY_CHECK => 'apply -R',\n-\t\tVERB => 'Discard',\n-\t\tTARGET => ' from index and worktree',\n-\t\tPARTICIPLE => 'discarding',\n \t\tFILTER => undef,\n \t\tIS_REVERSE => 1,\n \t},\n@@ -166,9 +148,6 @@ my %patch_modes = (\n \t\tDIFF => 'diff-index -R -p',\n \t\tAPPLY => sub { apply_patch_for_checkout_commit '', @_ },\n \t\tAPPLY_CHECK => 'apply',\n-\t\tVERB => 'Apply',\n-\t\tTARGET => ' to index and worktree',\n-\t\tPARTICIPLE => 'applying',\n \t\tFILTER => undef,\n \t\tIS_REVERSE => 0,\n \t},\n-- \n2.11.0.rc0.33.gec17dab\n\n"},{"id":"305782","messageId":"20161111124541.8216-10-vascomalmeida@sapo.pt","threadId":"44461","inReplyTo":"20161111124541.8216-1-vascomalmeida@sapo.pt","subject":"[PATCH v6 09/16] i18n: add--interactive: mark edit_hunk_manually message for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-11-11T12:45:34Z","receivedAt":"2016-11-11T12:46:34Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark message of edit_hunk_manually displayed in the editing file when\nuser chooses 'e' option.  The message had to be unfolded to allow\ntranslation of the $participle verb.\n\nSome messages end up being exactly the same for some use cases, but\nleft it for easier change in the future, e.g., wanting to change wording\nof one particular use case.\n\nThe comment character is now used according to the git configuration\ncore.commentchar.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-add--interactive.perl | 52 +++++++++++++++++++++++++++++++++++------------\n 1 file changed, 39 insertions(+), 13 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 045b847cf..7d1cc5652 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -1058,6 +1058,30 @@ sub color_diff {\n \t} @_;\n }\n \n+my %edit_hunk_manually_modes = (\n+\tstage => N__(\n+\"If the patch applies cleanly, the edited hunk will immediately be\n+marked for staging.\"),\n+\tstash => N__(\n+\"If the patch applies cleanly, the edited hunk will immediately be\n+marked for stashing.\"),\n+\treset_head => N__(\n+\"If the patch applies cleanly, the edited hunk will immediately be\n+marked for unstaging.\"),\n+\treset_nothead => N__(\n+\"If the patch applies cleanly, the edited hunk will immediately be\n+marked for applying.\"),\n+\tcheckout_index => N__(\n+\"If the patch applies cleanly, the edited hunk will immediately be\n+marked for discarding\"),\n+\tcheckout_head => N__(\n+\"If the patch applies cleanly, the edited hunk will immediately be\n+marked for discarding.\"),\n+\tcheckout_nothead => N__(\n+\"If the patch applies cleanly, the edited hunk will immediately be\n+marked for applying.\"),\n+);\n+\n sub edit_hunk_manually {\n \tmy ($oldtext) = @_;\n \n@@ -1065,22 +1089,24 @@ sub edit_hunk_manually {\n \tmy $fh;\n \topen $fh, '>', $hunkfile\n \t\tor die sprintf(__(\"failed to open hunk edit file for writing: %s\"), $!);\n-\tprint $fh \"# Manual hunk edit mode -- see bottom for a quick guide\\n\";\n+\tprint $fh Git::comment_lines __(\"Manual hunk edit mode -- see bottom for a quick guide.\\n\");\n \tprint $fh @$oldtext;\n-\tmy $participle = $patch_mode_flavour{PARTICIPLE};\n \tmy $is_reverse = $patch_mode_flavour{IS_REVERSE};\n \tmy ($remove_plus, $remove_minus) = $is_reverse ? ('-', '+') : ('+', '-');\n-\tprint $fh <<EOF;\n-# ---\n-# To remove '$remove_minus' lines, make them ' ' lines (context).\n-# To remove '$remove_plus' lines, delete them.\n-# Lines starting with # will be removed.\n-#\n-# If the patch applies cleanly, the edited hunk will immediately be\n-# marked for $participle. If it does not apply cleanly, you will be given\n-# an opportunity to edit again. If all lines of the hunk are removed,\n-# then the edit is aborted and the hunk is left unchanged.\n+\tmy $comment_line_char = Git::config(\"core.commentchar\") || '#';\n+\tprint $fh Git::comment_lines sprintf(__ <<EOF, $remove_minus, $remove_plus, $comment_line_char),\n+---\n+To remove '%s' lines, make them ' ' lines (context).\n+To remove '%s' lines, delete them.\n+Lines starting with %s will be removed.\n EOF\n+__($edit_hunk_manually_modes{$patch_mode}),\n+# TRANSLATORS: 'it' refers to the patch mentioned in the previous messages.\n+__ <<EOF2 ;\n+If it does not apply cleanly, you will be given an opportunity to\n+edit again.  If all lines of the hunk are removed, then the edit is\n+aborted and the hunk is left unchanged.\n+EOF2\n \tclose $fh;\n \n \tchomp(my $editor = run_cmd_pipe(qw(git var GIT_EDITOR)));\n@@ -1092,7 +1118,7 @@ EOF\n \n \topen $fh, '<', $hunkfile\n \t\tor die sprintf(__(\"failed to open hunk edit file for reading: %s\"), $!);\n-\tmy @newtext = grep { !/^#/ } <$fh>;\n+\tmy @newtext = grep { !/^$comment_line_char/ } <$fh>;\n \tclose $fh;\n \tunlink $hunkfile;\n \n-- \n2.11.0.rc0.33.gec17dab\n\n"},{"id":"305783","messageId":"20161111124541.8216-7-vascomalmeida@sapo.pt","threadId":"44461","inReplyTo":"20161111124541.8216-1-vascomalmeida@sapo.pt","subject":"[PATCH v6 06/16] i18n: add--interactive: mark plural strings","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-11-11T12:45:31Z","receivedAt":"2016-11-11T12:46:37Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark plural strings for translation.  Unfold each action case in one\nentire sentence.\n\nPass new keyword for xgettext to extract.\n\nUpdate test to include new subroutine __n() for plural strings handling.\n\nUpdate documentation to include a description of the new __n()\nsubroutine.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n Makefile                  |  3 ++-\n git-add--interactive.perl | 27 ++++++++++++++++++---------\n perl/Git/I18N.pm          | 10 +++++++++-\n t/t0202/test.pl           | 11 ++++++++++-\n 4 files changed, 39 insertions(+), 12 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 9d6c24503..328151dd6 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2113,7 +2113,8 @@ XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \\\n \t--keyword=_ --keyword=N_ --keyword=\"Q_:1,2\"\n XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell \\\n \t--keyword=gettextln --keyword=eval_gettextln\n-XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --keyword=__ --language=Perl\n+XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --language=Perl \\\n+\t--keyword=__ --keyword=\"__n:1,2\"\n LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)\n LOCALIZED_SH = $(SCRIPT_SH)\n LOCALIZED_SH += git-parse-remote.sh\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex d05ac608e..cd617837b 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -669,12 +669,18 @@ sub status_cmd {\n sub say_n_paths {\n \tmy $did = shift @_;\n \tmy $cnt = scalar @_;\n-\tprint \"$did \";\n-\tif (1 < $cnt) {\n-\t\tprint \"$cnt paths\\n\";\n-\t}\n-\telse {\n-\t\tprint \"one path\\n\";\n+\tif ($did eq 'added') {\n+\t\tprintf(__n(\"added %d path\\n\", \"added %d paths\\n\",\n+\t\t\t   $cnt), $cnt);\n+\t} elsif ($did eq 'updated') {\n+\t\tprintf(__n(\"updated %d path\\n\", \"updated %d paths\\n\",\n+\t\t\t   $cnt), $cnt);\n+\t} elsif ($did eq 'reverted') {\n+\t\tprintf(__n(\"reverted %d path\\n\", \"reverted %d paths\\n\",\n+\t\t\t   $cnt), $cnt);\n+\t} else {\n+\t\tprintf(__n(\"touched %d path\\n\", \"touched %d paths\\n\",\n+\t\t\t   $cnt), $cnt);\n \t}\n }\n \n@@ -1423,7 +1429,8 @@ sub patch_update_file {\n \t\t\t\t} elsif (0 < $response && $response <= $num) {\n \t\t\t\t\t$ix = $response - 1;\n \t\t\t\t} else {\n-\t\t\t\t\terror_msg \"Sorry, only $num hunks available.\\n\";\n+\t\t\t\t\terror_msg sprintf(__n(\"Sorry, only %d hunk available.\\n\",\n+\t\t\t\t\t\t\t      \"Sorry, only %d hunks available.\\n\", $num), $num);\n \t\t\t\t}\n \t\t\t\tnext;\n \t\t\t}\n@@ -1518,8 +1525,10 @@ sub patch_update_file {\n \t\t\telsif ($other =~ /s/ && $line =~ /^s/) {\n \t\t\t\tmy @split = split_hunk($hunk[$ix]{TEXT}, $hunk[$ix]{DISPLAY});\n \t\t\t\tif (1 < @split) {\n-\t\t\t\t\tprint colored $header_color, \"Split into \",\n-\t\t\t\t\tscalar(@split), \" hunks.\\n\";\n+\t\t\t\t\tprint colored $header_color, sprintf(\n+\t\t\t\t\t\t__n(\"Split into %d hunk.\\n\",\n+\t\t\t\t\t\t    \"Split into %d hunks.\\n\",\n+\t\t\t\t\t\t    scalar(@split)), scalar(@split));\n \t\t\t\t}\n \t\t\t\tsplice (@hunk, $ix, 1, @split);\n \t\t\t\t$num = scalar @hunk;\ndiff --git a/perl/Git/I18N.pm b/perl/Git/I18N.pm\nindex f889fd6da..617d8c2a1 100644\n--- a/perl/Git/I18N.pm\n+++ b/perl/Git/I18N.pm\n@@ -13,7 +13,7 @@ BEGIN {\n \t}\n }\n \n-our @EXPORT = qw(__);\n+our @EXPORT = qw(__ __n);\n our @EXPORT_OK = @EXPORT;\n \n sub __bootstrap_locale_messages {\n@@ -44,6 +44,7 @@ BEGIN\n \teval {\n \t\t__bootstrap_locale_messages();\n \t\t*__ = \\&Locale::Messages::gettext;\n+\t\t*__n = \\&Locale::Messages::ngettext;\n \t\t1;\n \t} or do {\n \t\t# Tell test.pl that we couldn't load the gettext library.\n@@ -51,6 +52,7 @@ BEGIN\n \n \t\t# Just a fall-through no-op\n \t\t*__ = sub ($) { $_[0] };\n+\t\t*__n = sub ($$$) { $_[2] == 1 ? $_[0] : $_[1] };\n \t};\n }\n \n@@ -70,6 +72,8 @@ Git::I18N - Perl interface to Git's Gettext localizations\n \n \tprintf __(\"The following error occurred: %s\\n\"), $error;\n \n+\tprintf __n(\"commited %d file\\n\", \"commited %d files\\n\", $files), $files;\n+\n =head1 DESCRIPTION\n \n Git's internal Perl interface to gettext via L<Locale::Messages>. If\n@@ -87,6 +91,10 @@ it.\n L<Locale::Messages>'s gettext function if all goes well, otherwise our\n passthrough fallback function.\n \n+=head2 __n($$$)\n+\n+L<Locale::Messages>'s ngettext function or passthrough fallback function.\n+\n =head1 AUTHOR\n \n E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avarab@gmail.com>\ndiff --git a/t/t0202/test.pl b/t/t0202/test.pl\nindex 2c10cb469..4101833a8 100755\n--- a/t/t0202/test.pl\n+++ b/t/t0202/test.pl\n@@ -4,7 +4,7 @@ use lib (split(/:/, $ENV{GITPERLLIB}));\n use strict;\n use warnings;\n use POSIX qw(:locale_h);\n-use Test::More tests => 8;\n+use Test::More tests => 11;\n use Git::I18N;\n \n my $has_gettext_library = $Git::I18N::__HAS_LIBRARY;\n@@ -31,6 +31,7 @@ is_deeply(\\@Git::I18N::EXPORT, \\@Git::I18N::EXPORT_OK, \"sanity: Git::I18N export\n \t# more gettext wrapper functions.\n \tmy %prototypes = (qw(\n \t\t__\t$\n+\t\t__n\t$$$\n \t));\n \twhile (my ($sub, $proto) = each %prototypes) {\n \t\tis(prototype(\\&{\"Git::I18N::$sub\"}), $proto, \"sanity: $sub has a $proto prototype\");\n@@ -46,6 +47,14 @@ is_deeply(\\@Git::I18N::EXPORT, \\@Git::I18N::EXPORT_OK, \"sanity: Git::I18N export\n \tmy ($got, $expect) = (('TEST: A Perl test string') x 2);\n \n \tis(__($got), $expect, \"Passing a string through __() in the C locale works\");\n+\n+\tmy ($got_singular, $got_plural, $expect_singular, $expect_plural) =\n+\t\t(('TEST: 1 file', 'TEST: n files') x 2);\n+\n+\tis(__n($got_singular, $got_plural, 1), $expect_singular,\n+\t\t\"Get singular string through __n() in C locale\");\n+\tis(__n($got_singular, $got_plural, 2), $expect_plural,\n+\t\t\"Get plural string through __n() in C locale\");\n }\n \n # Test a basic message on different locales\n-- \n2.11.0.rc0.33.gec17dab\n\n"},{"id":"305784","messageId":"20161111124541.8216-1-vascomalmeida@sapo.pt","threadId":"44461","inReplyTo":"20161005172110.30801-1-vascomalmeida@sapo.pt","subject":"[PATCH v6 00/16] Mark strings in Perl scripts for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-11-11T12:45:25Z","receivedAt":"2016-11-11T12:46:40Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark messages in some perl scripts for translation.\n\nChanges in this re-roll v6:\n- Change implementation of prefix_lines subroutine to allow arbitrary\n  number of strings as arguments.\n- Change a few marks for translation hopefully to be easier on the eyes.\n\nInterdiff included below.\n\n\nVasco Almeida (16):\n  Git.pm: add subroutines for commenting lines\n  i18n: add--interactive: mark strings for translation\n  i18n: add--interactive: mark simple here-documents for translation\n  i18n: add--interactive: mark strings with interpolation for\n    translation\n  i18n: clean.c: match string with git-add--interactive.perl\n  i18n: add--interactive: mark plural strings\n  i18n: add--interactive: mark patch prompt for translation\n  i18n: add--interactive: i18n of help_patch_cmd\n  i18n: add--interactive: mark edit_hunk_manually message for\n    translation\n  i18n: add--interactive: remove %patch_modes entries\n  i18n: add--interactive: mark status words for translation\n  i18n: send-email: mark strings for translation\n  i18n: send-email: mark warnings and errors for translation\n  i18n: send-email: mark string with interpolation for translation\n  i18n: send-email: mark composing message for translation\n  i18n: difftool: mark warnings for translation\n\n Makefile                  |   3 +-\n builtin/clean.c           |  10 +-\n git-add--interactive.perl | 329 ++++++++++++++++++++++++++++++----------------\n git-difftool.perl         |  22 ++--\n git-send-email.perl       | 191 +++++++++++++++------------\n perl/Git.pm               |  24 ++++\n perl/Git/I18N.pm          |  19 ++-\n t/t0202/test.pl           |  14 +-\n 8 files changed, 394 insertions(+), 218 deletions(-)\n\n-- >8 --\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 56e6889..3a6d846 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -1068,22 +1068,24 @@ sub edit_hunk_manually {\n \tmy $fh;\n \topen $fh, '>', $hunkfile\n \t\tor die sprintf(__(\"failed to open hunk edit file for writing: %s\"), $!);\n-\tprint $fh Git::comment_lines __(\"Manual hunk edit mode -- see bottom for a quick guide\\n\");\n+\tprint $fh Git::comment_lines __(\"Manual hunk edit mode -- see bottom for a quick guide.\\n\");\n \tprint $fh @$oldtext;\n \tmy $is_reverse = $patch_mode_flavour{IS_REVERSE};\n \tmy ($remove_plus, $remove_minus) = $is_reverse ? ('-', '+') : ('+', '-');\n \tmy $comment_line_char = Git::config(\"core.commentchar\") || '#';\n-\tprint $fh Git::comment_lines sprintf(__(\n-\"---\n+\tprint $fh Git::comment_lines sprintf(__ <<EOF, $remove_minus, $remove_plus, $comment_line_char),\n+---\n To remove '%s' lines, make them ' ' lines (context).\n To remove '%s' lines, delete them.\n Lines starting with %s will be removed.\n-\\n\"), $remove_minus, $remove_plus, $comment_line_char) .\n-__($edit_hunk_manually_modes{$patch_mode}) .\"\\n\". __(\n+EOF\n+__($edit_hunk_manually_modes{$patch_mode}),\n # TRANSLATORS: 'it' refers to the patch mentioned in the previous messages.\n-\"If it does not apply cleanly, you will be given an opportunity to\n+__ <<EOF2 ;\n+If it does not apply cleanly, you will be given an opportunity to\n edit again.  If all lines of the hunk are removed, then the edit is\n-aborted and the hunk is left unchanged.\\n\");\n+aborted and the hunk is left unchanged.\n+EOF2\n \tclose $fh;\n \n \tchomp(my $editor = run_cmd_pipe(qw(git var GIT_EDITOR)));\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex bbeb9fb..068d60b 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -585,12 +585,13 @@ sub is_format_patch_arg {\n \t\tif (defined($format_patch)) {\n \t\t\treturn $format_patch;\n \t\t}\n-\t\tdie sprintf(__(\n-\"File '%s' exists but it could also be the range of commits\n+\t\tdie sprintf(__ <<EOF, $f, $f);\n+File '%s' exists but it could also be the range of commits\n to produce patches for.  Please disambiguate by...\n \n-    * Saying \\\"./%s\\\" if you mean a file; or\n-    * Giving --format-patch option if you mean a range.\"), $f, $f);\n+    * Saying \"./%s\" if you mean a file; or\n+    * Giving --format-patch option if you mean a range.\n+EOF\n \t} catch Git::Error::Command with {\n \t\t# Not a valid revision.  Treat it as a filename.\n \t\treturn 0;\n@@ -654,7 +655,7 @@ sub get_patch_subject {\n \t\treturn \"GIT: $1\\n\";\n \t}\n \tclose $fh;\n-\tdie sprintf(__(\"No subject line in %s ?\"), $fn);\n+\tdie sprintf(__(\"No subject line in %s?\"), $fn);\n }\n \n if ($compose) {\n@@ -697,10 +698,10 @@ EOT3\n \t}\n \n \topen my $c2, \">\", $compose_filename . \".final\"\n-\t\tor die sprintf(__(\"Failed to open %s.final : %s\"), $compose_filename, $!);\n+\t\tor die sprintf(__(\"Failed to open %s.final: %s\"), $compose_filename, $!);\n \n \topen $c, \"<\", $compose_filename\n-\t\tor die sprintf(__(\"Failed to open %s : %s\"), $compose_filename, $!);\n+\t\tor die sprintf(__(\"Failed to open %s: %s\"), $compose_filename, $!);\n \n \tmy $need_8bit_cte = file_has_nonascii($compose_filename);\n \tmy $in_body = 0;\n@@ -1304,8 +1305,8 @@ Message-Id: $message_id\n \t\tif ($needs_confirm eq \"inform\") {\n \t\t\t$confirm_unconfigured = 0; # squelch this message for the rest of this run\n \t\t\t$ask_default = \"y\"; # assume yes on EOF since user hasn't explicitly asked for confirmation\n-\t\t\tprint __(\n-\"    The Cc list above has been expanded by additional\n+\t\t\tprint __ <<EOF ;\n+    The Cc list above has been expanded by additional\n     addresses found in the patch commit message. By default\n     send-email prompts before sending whenever this occurs.\n     This behavior is controlled by the sendemail.confirm\n@@ -1313,7 +1314,9 @@ Message-Id: $message_id\n \n     For additional information, run 'git send-email --help'.\n     To retain the current behavior, but squelch this message,\n-    run 'git config --global sendemail.confirm auto'.\"), \"\\n\\n\";\n+    run 'git config --global sendemail.confirm auto'.\n+\n+EOF\n \t\t}\n \t\t# TRANSLATORS: Make sure to include [y] [n] [q] [a] in your\n \t\t# translation. The program will only accept English input\ndiff --git a/perl/Git.pm b/perl/Git.pm\nindex 17be59f..69cd1dd 100644\n--- a/perl/Git.pm\n+++ b/perl/Git.pm\n@@ -1438,19 +1438,20 @@ sub END {\n \n } # %TEMP_* Lexical Context\n \n-=item prefix_lines ( PREFIX, STRING )\n+=item prefix_lines ( PREFIX, STRING [, STRING... ])\n \n Prefixes lines in C<STRING> with C<PREFIX>.\n \n =cut\n \n sub prefix_lines {\n-\tmy ($prefix, $string) = @_;\n+\tmy $prefix = shift;\n+\tmy $string = join(\"\\n\", @_);\n \t$string =~ s/^/$prefix/mg;\n \treturn $string;\n }\n \n-=item comment_lines ( STRING )\n+=item comment_lines ( STRING [, STRING... ])\n \n Comments lines following core.commentchar configuration.\n \n-- >8 --\n\n-- \n2.11.0.rc0.33.gec17dab\n\n"},{"id":"305785","messageId":"20161111124541.8216-5-vascomalmeida@sapo.pt","threadId":"44461","inReplyTo":"20161111124541.8216-1-vascomalmeida@sapo.pt","subject":"[PATCH v6 04/16] i18n: add--interactive: mark strings with interpolation for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-11-11T12:45:29Z","receivedAt":"2016-11-11T12:46:43Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Since at this point Git::I18N.perl lacks support for Perl i18n\nplaceholder substitution, use of sprintf following die or error_msg is\nnecessary for placeholder substitution take place.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-add--interactive.perl | 25 +++++++++++++------------\n 1 file changed, 13 insertions(+), 12 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 5800010ed..d05ac608e 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -615,12 +615,12 @@ sub list_and_choose {\n \t\t\telse {\n \t\t\t\t$bottom = $top = find_unique($choice, @stuff);\n \t\t\t\tif (!defined $bottom) {\n-\t\t\t\t\terror_msg \"Huh ($choice)?\\n\";\n+\t\t\t\t\terror_msg sprintf(__(\"Huh (%s)?\\n\"), $choice);\n \t\t\t\t\tnext TOPLOOP;\n \t\t\t\t}\n \t\t\t}\n \t\t\tif ($opts->{SINGLETON} && $bottom != $top) {\n-\t\t\t\terror_msg \"Huh ($choice)?\\n\";\n+\t\t\t\terror_msg sprintf(__(\"Huh (%s)?\\n\"), $choice);\n \t\t\t\tnext TOPLOOP;\n \t\t\t}\n \t\t\tfor ($i = $bottom-1; $i <= $top-1; $i++) {\n@@ -717,7 +717,7 @@ sub revert_cmd {\n \t\t\t\t    $_->{INDEX_ADDDEL} eq 'create') {\n \t\t\t\t\tsystem(qw(git update-index --force-remove --),\n \t\t\t\t\t       $_->{VALUE});\n-\t\t\t\t\tprint \"note: $_->{VALUE} is untracked now.\\n\";\n+\t\t\t\t\tprintf(__(\"note: %s is untracked now.\\n\"), $_->{VALUE});\n \t\t\t\t}\n \t\t\t}\n \t\t}\n@@ -1056,7 +1056,7 @@ sub edit_hunk_manually {\n \tmy $hunkfile = $repo->repo_path . \"/addp-hunk-edit.diff\";\n \tmy $fh;\n \topen $fh, '>', $hunkfile\n-\t\tor die \"failed to open hunk edit file for writing: \" . $!;\n+\t\tor die sprintf(__(\"failed to open hunk edit file for writing: %s\"), $!);\n \tprint $fh \"# Manual hunk edit mode -- see bottom for a quick guide\\n\";\n \tprint $fh @$oldtext;\n \tmy $participle = $patch_mode_flavour{PARTICIPLE};\n@@ -1083,7 +1083,7 @@ EOF\n \t}\n \n \topen $fh, '<', $hunkfile\n-\t\tor die \"failed to open hunk edit file for reading: \" . $!;\n+\t\tor die sprintf(__(\"failed to open hunk edit file for reading: %s\"), $!);\n \tmy @newtext = grep { !/^#/ } <$fh>;\n \tclose $fh;\n \tunlink $hunkfile;\n@@ -1236,7 +1236,7 @@ sub apply_patch_for_checkout_commit {\n \n sub patch_update_cmd {\n \tmy @all_mods = list_modified($patch_mode_flavour{FILTER});\n-\terror_msg \"ignoring unmerged: $_->{VALUE}\\n\"\n+\terror_msg sprintf(__(\"ignoring unmerged: %s\\n\"), $_->{VALUE})\n \t\tfor grep { $_->{UNMERGED} } @all_mods;\n \t@all_mods = grep { !$_->{UNMERGED} } @all_mods;\n \n@@ -1418,7 +1418,8 @@ sub patch_update_file {\n \t\t\t\t\tchomp $response;\n \t\t\t\t}\n \t\t\t\tif ($response !~ /^\\s*\\d+\\s*$/) {\n-\t\t\t\t\terror_msg \"Invalid number: '$response'\\n\";\n+\t\t\t\t\terror_msg sprintf(__(\"Invalid number: '%s'\\n\"),\n+\t\t\t\t\t\t\t     $response);\n \t\t\t\t} elsif (0 < $response && $response <= $num) {\n \t\t\t\t\t$ix = $response - 1;\n \t\t\t\t} else {\n@@ -1460,7 +1461,7 @@ sub patch_update_file {\n \t\t\t\tif ($@) {\n \t\t\t\t\tmy ($err,$exp) = ($@, $1);\n \t\t\t\t\t$err =~ s/ at .*git-add--interactive line \\d+, <STDIN> line \\d+.*$//;\n-\t\t\t\t\terror_msg \"Malformed search regexp $exp: $err\\n\";\n+\t\t\t\t\terror_msg sprintf(__(\"Malformed search regexp %s: %s\\n\"), $exp, $err);\n \t\t\t\t\tnext;\n \t\t\t\t}\n \t\t\t\tmy $iy = $ix;\n@@ -1625,18 +1626,18 @@ sub process_args {\n \t\t\t\t$patch_mode = $1;\n \t\t\t\t$arg = shift @ARGV or die __(\"missing --\");\n \t\t\t} else {\n-\t\t\t\tdie \"unknown --patch mode: $1\";\n+\t\t\t\tdie sprintf(__(\"unknown --patch mode: %s\"), $1);\n \t\t\t}\n \t\t} else {\n \t\t\t$patch_mode = 'stage';\n \t\t\t$arg = shift @ARGV or die __(\"missing --\");\n \t\t}\n-\t\tdie \"invalid argument $arg, expecting --\"\n-\t\t    unless $arg eq \"--\";\n+\t\tdie sprintf(__(\"invalid argument %s, expecting --\"),\n+\t\t\t       $arg) unless $arg eq \"--\";\n \t\t%patch_mode_flavour = %{$patch_modes{$patch_mode}};\n \t}\n \telsif ($arg ne \"--\") {\n-\t\tdie \"invalid argument $arg, expecting --\";\n+\t\tdie sprintf(__(\"invalid argument %s, expecting --\"), $arg);\n \t}\n }\n \n-- \n2.11.0.rc0.33.gec17dab\n\n"},{"id":"305786","messageId":"20161111124541.8216-3-vascomalmeida@sapo.pt","threadId":"44461","inReplyTo":"20161111124541.8216-1-vascomalmeida@sapo.pt","subject":"[PATCH v6 02/16] i18n: add--interactive: mark strings for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-11-11T12:45:27Z","receivedAt":"2016-11-11T12:46:44Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark simple strings (without interpolation) for translation.\n\nBrackets around first parameter of ternary operator is necessary because\notherwise xgettext fails to extract strings marked for translation from\nthe rest of the file.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-add--interactive.perl | 76 ++++++++++++++++++++++++++---------------------\n 1 file changed, 42 insertions(+), 34 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex ee3d81269..cf216ecb6 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -4,6 +4,7 @@ use 5.008;\n use strict;\n use warnings;\n use Git;\n+use Git::I18N;\n \n binmode(STDOUT, \":raw\");\n \n@@ -253,8 +254,9 @@ sub list_untracked {\n \trun_cmd_pipe(qw(git ls-files --others --exclude-standard --), @ARGV);\n }\n \n-my $status_fmt = '%12s %12s %s';\n-my $status_head = sprintf($status_fmt, 'staged', 'unstaged', 'path');\n+# TRANSLATORS: you can adjust this to align \"git add -i\" status menu\n+my $status_fmt = __('%12s %12s %s');\n+my $status_head = sprintf($status_fmt, __('staged'), __('unstaged'), __('path'));\n \n {\n \tmy $initial;\n@@ -680,7 +682,7 @@ sub update_cmd {\n \tmy @mods = list_modified('file-only');\n \treturn if (!@mods);\n \n-\tmy @update = list_and_choose({ PROMPT => 'Update',\n+\tmy @update = list_and_choose({ PROMPT => __('Update'),\n \t\t\t\t       HEADER => $status_head, },\n \t\t\t\t     @mods);\n \tif (@update) {\n@@ -692,7 +694,7 @@ sub update_cmd {\n }\n \n sub revert_cmd {\n-\tmy @update = list_and_choose({ PROMPT => 'Revert',\n+\tmy @update = list_and_choose({ PROMPT => __('Revert'),\n \t\t\t\t       HEADER => $status_head, },\n \t\t\t\t     list_modified());\n \tif (@update) {\n@@ -726,13 +728,13 @@ sub revert_cmd {\n }\n \n sub add_untracked_cmd {\n-\tmy @add = list_and_choose({ PROMPT => 'Add untracked' },\n+\tmy @add = list_and_choose({ PROMPT => __('Add untracked') },\n \t\t\t\t  list_untracked());\n \tif (@add) {\n \t\tsystem(qw(git update-index --add --), @add);\n \t\tsay_n_paths('added', @add);\n \t} else {\n-\t\tprint \"No untracked files.\\n\";\n+\t\tprint __(\"No untracked files.\\n\");\n \t}\n \tprint \"\\n\";\n }\n@@ -1166,8 +1168,14 @@ sub edit_hunk_loop {\n \t\t}\n \t\telse {\n \t\t\tprompt_yesno(\n-\t\t\t\t'Your edited hunk does not apply. Edit again '\n-\t\t\t\t. '(saying \"no\" discards!) [y/n]? '\n+\t\t\t\t# TRANSLATORS: do not translate [y/n]\n+\t\t\t\t# The program will only accept that input\n+\t\t\t\t# at this point.\n+\t\t\t\t# Consider translating (saying \"no\" discards!) as\n+\t\t\t\t# (saying \"n\" for \"no\" discards!) if the translation\n+\t\t\t\t# of the word \"no\" does not start with n.\n+\t\t\t\t__('Your edited hunk does not apply. Edit again '\n+\t\t\t\t   . '(saying \"no\" discards!) [y/n]? ')\n \t\t\t\t) or return undef;\n \t\t}\n \t}\n@@ -1213,11 +1221,11 @@ sub apply_patch_for_checkout_commit {\n \t\trun_git_apply 'apply '.$reverse, @_;\n \t\treturn 1;\n \t} elsif (!$applies_index) {\n-\t\tprint colored $error_color, \"The selected hunks do not apply to the index!\\n\";\n-\t\tif (prompt_yesno \"Apply them to the worktree anyway? \") {\n+\t\tprint colored $error_color, __(\"The selected hunks do not apply to the index!\\n\");\n+\t\tif (prompt_yesno __(\"Apply them to the worktree anyway? \")) {\n \t\t\treturn run_git_apply 'apply '.$reverse, @_;\n \t\t} else {\n-\t\t\tprint colored $error_color, \"Nothing was applied.\\n\";\n+\t\t\tprint colored $error_color, __(\"Nothing was applied.\\n\");\n \t\t\treturn 0;\n \t\t}\n \t} else {\n@@ -1237,9 +1245,9 @@ sub patch_update_cmd {\n \n \tif (!@mods) {\n \t\tif (@all_mods) {\n-\t\t\tprint STDERR \"Only binary files changed.\\n\";\n+\t\t\tprint STDERR __(\"Only binary files changed.\\n\");\n \t\t} else {\n-\t\t\tprint STDERR \"No changes.\\n\";\n+\t\t\tprint STDERR __(\"No changes.\\n\");\n \t\t}\n \t\treturn 0;\n \t}\n@@ -1247,7 +1255,7 @@ sub patch_update_cmd {\n \t\t@them = @mods;\n \t}\n \telse {\n-\t\t@them = list_and_choose({ PROMPT => 'Patch update',\n+\t\t@them = list_and_choose({ PROMPT => __('Patch update'),\n \t\t\t\t\t  HEADER => $status_head, },\n \t\t\t\t\t@mods);\n \t}\n@@ -1397,12 +1405,12 @@ sub patch_update_file {\n \t\t\t\tmy $response = $1;\n \t\t\t\tmy $no = $ix > 10 ? $ix - 10 : 0;\n \t\t\t\twhile ($response eq '') {\n-\t\t\t\t\tmy $extra = \"\";\n \t\t\t\t\t$no = display_hunks(\\@hunk, $no);\n \t\t\t\t\tif ($no < $num) {\n-\t\t\t\t\t\t$extra = \" (<ret> to see more)\";\n+\t\t\t\t\t\tprint __(\"go to which hunk (<ret> to see more)? \");\n+\t\t\t\t\t} else {\n+\t\t\t\t\t\tprint __(\"go to which hunk? \");\n \t\t\t\t\t}\n-\t\t\t\t\tprint \"go to which hunk$extra? \";\n \t\t\t\t\t$response = <STDIN>;\n \t\t\t\t\tif (!defined $response) {\n \t\t\t\t\t\t$response = '';\n@@ -1439,7 +1447,7 @@ sub patch_update_file {\n \t\t\telsif ($line =~ m|^/(.*)|) {\n \t\t\t\tmy $regex = $1;\n \t\t\t\tif ($1 eq \"\") {\n-\t\t\t\t\tprint colored $prompt_color, \"search for regex? \";\n+\t\t\t\t\tprint colored $prompt_color, __(\"search for regex? \");\n \t\t\t\t\t$regex = <STDIN>;\n \t\t\t\t\tif (defined $regex) {\n \t\t\t\t\t\tchomp $regex;\n@@ -1462,7 +1470,7 @@ sub patch_update_file {\n \t\t\t\t\t$iy++;\n \t\t\t\t\t$iy = 0 if ($iy >= $num);\n \t\t\t\t\tif ($ix == $iy) {\n-\t\t\t\t\t\terror_msg \"No hunk matches the given pattern\\n\";\n+\t\t\t\t\t\terror_msg __(\"No hunk matches the given pattern\\n\");\n \t\t\t\t\t\tlast;\n \t\t\t\t\t}\n \t\t\t\t}\n@@ -1474,7 +1482,7 @@ sub patch_update_file {\n \t\t\t\t\t$ix--;\n \t\t\t\t}\n \t\t\t\telse {\n-\t\t\t\t\terror_msg \"No previous hunk\\n\";\n+\t\t\t\t\terror_msg __(\"No previous hunk\\n\");\n \t\t\t\t}\n \t\t\t\tnext;\n \t\t\t}\n@@ -1483,7 +1491,7 @@ sub patch_update_file {\n \t\t\t\t\t$ix++;\n \t\t\t\t}\n \t\t\t\telse {\n-\t\t\t\t\terror_msg \"No next hunk\\n\";\n+\t\t\t\t\terror_msg __(\"No next hunk\\n\");\n \t\t\t\t}\n \t\t\t\tnext;\n \t\t\t}\n@@ -1496,13 +1504,13 @@ sub patch_update_file {\n \t\t\t\t\t}\n \t\t\t\t}\n \t\t\t\telse {\n-\t\t\t\t\terror_msg \"No previous hunk\\n\";\n+\t\t\t\t\terror_msg __(\"No previous hunk\\n\");\n \t\t\t\t}\n \t\t\t\tnext;\n \t\t\t}\n \t\t\telsif ($line =~ /^j/) {\n \t\t\t\tif ($other !~ /j/) {\n-\t\t\t\t\terror_msg \"No next hunk\\n\";\n+\t\t\t\t\terror_msg __(\"No next hunk\\n\");\n \t\t\t\t\tnext;\n \t\t\t\t}\n \t\t\t}\n@@ -1560,18 +1568,18 @@ sub diff_cmd {\n \tmy @mods = list_modified('index-only');\n \t@mods = grep { !($_->{BINARY}) } @mods;\n \treturn if (!@mods);\n-\tmy (@them) = list_and_choose({ PROMPT => 'Review diff',\n+\tmy (@them) = list_and_choose({ PROMPT => __('Review diff'),\n \t\t\t\t     IMMEDIATE => 1,\n \t\t\t\t     HEADER => $status_head, },\n \t\t\t\t   @mods);\n \treturn if (!@them);\n-\tmy $reference = is_initial_commit() ? get_empty_tree() : 'HEAD';\n+\tmy $reference = (is_initial_commit()) ? get_empty_tree() : 'HEAD';\n \tsystem(qw(git diff -p --cached), $reference, '--',\n \t\tmap { $_->{VALUE} } @them);\n }\n \n sub quit_cmd {\n-\tprint \"Bye.\\n\";\n+\tprint __(\"Bye.\\n\");\n \texit(0);\n }\n \n@@ -1594,32 +1602,32 @@ sub process_args {\n \t\t\tif ($1 eq 'reset') {\n \t\t\t\t$patch_mode = 'reset_head';\n \t\t\t\t$patch_mode_revision = 'HEAD';\n-\t\t\t\t$arg = shift @ARGV or die \"missing --\";\n+\t\t\t\t$arg = shift @ARGV or die __(\"missing --\");\n \t\t\t\tif ($arg ne '--') {\n \t\t\t\t\t$patch_mode_revision = $arg;\n \t\t\t\t\t$patch_mode = ($arg eq 'HEAD' ?\n \t\t\t\t\t\t       'reset_head' : 'reset_nothead');\n-\t\t\t\t\t$arg = shift @ARGV or die \"missing --\";\n+\t\t\t\t\t$arg = shift @ARGV or die __(\"missing --\");\n \t\t\t\t}\n \t\t\t} elsif ($1 eq 'checkout') {\n-\t\t\t\t$arg = shift @ARGV or die \"missing --\";\n+\t\t\t\t$arg = shift @ARGV or die __(\"missing --\");\n \t\t\t\tif ($arg eq '--') {\n \t\t\t\t\t$patch_mode = 'checkout_index';\n \t\t\t\t} else {\n \t\t\t\t\t$patch_mode_revision = $arg;\n \t\t\t\t\t$patch_mode = ($arg eq 'HEAD' ?\n \t\t\t\t\t\t       'checkout_head' : 'checkout_nothead');\n-\t\t\t\t\t$arg = shift @ARGV or die \"missing --\";\n+\t\t\t\t\t$arg = shift @ARGV or die __(\"missing --\");\n \t\t\t\t}\n \t\t\t} elsif ($1 eq 'stage' or $1 eq 'stash') {\n \t\t\t\t$patch_mode = $1;\n-\t\t\t\t$arg = shift @ARGV or die \"missing --\";\n+\t\t\t\t$arg = shift @ARGV or die __(\"missing --\");\n \t\t\t} else {\n \t\t\t\tdie \"unknown --patch mode: $1\";\n \t\t\t}\n \t\t} else {\n \t\t\t$patch_mode = 'stage';\n-\t\t\t$arg = shift @ARGV or die \"missing --\";\n+\t\t\t$arg = shift @ARGV or die __(\"missing --\");\n \t\t}\n \t\tdie \"invalid argument $arg, expecting --\"\n \t\t    unless $arg eq \"--\";\n@@ -1641,10 +1649,10 @@ sub main_loop {\n \t\t   [ 'help', \\&help_cmd, ],\n \t);\n \twhile (1) {\n-\t\tmy ($it) = list_and_choose({ PROMPT => 'What now',\n+\t\tmy ($it) = list_and_choose({ PROMPT => __('What now'),\n \t\t\t\t\t     SINGLETON => 1,\n \t\t\t\t\t     LIST_FLAT => 4,\n-\t\t\t\t\t     HEADER => '*** Commands ***',\n+\t\t\t\t\t     HEADER => __('*** Commands ***'),\n \t\t\t\t\t     ON_EOF => \\&quit_cmd,\n \t\t\t\t\t     IMMEDIATE => 1 }, @cmd);\n \t\tif ($it) {\n-- \n2.11.0.rc0.33.gec17dab\n\n"},{"id":"305787","messageId":"20161111124541.8216-4-vascomalmeida@sapo.pt","threadId":"44461","inReplyTo":"20161111124541.8216-1-vascomalmeida@sapo.pt","subject":"[PATCH v6 03/16] i18n: add--interactive: mark simple here-documents for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-11-11T12:45:28Z","receivedAt":"2016-11-11T12:46:47Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark messages in here-documents without interpolation for translation.\n\nThe here-document delimiter \\EOF, which is the same as 'EOF', indicates\nthat the text is to be treated literally without interpolation of its\ncontent.  Unfortunately xgettext is not able to extract here-documents\ndelimited with \\EOF but it is with delimiter enclosed in single quotes.\nSo change \\EOF to 'EOF', although in this case does not make\ndifference what variation of here-document to use since there is nothing\nto interpolate.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-add--interactive.perl | 8 +++++---\n 1 file changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex cf216ecb6..5800010ed 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -639,7 +639,7 @@ sub list_and_choose {\n }\n \n sub singleton_prompt_help_cmd {\n-\tprint colored $help_color, <<\\EOF ;\n+\tprint colored $help_color, __ <<'EOF' ;\n Prompt help:\n 1          - select a numbered item\n foo        - select item based on unique prefix\n@@ -648,7 +648,7 @@ EOF\n }\n \n sub prompt_help_cmd {\n-\tprint colored $help_color, <<\\EOF ;\n+\tprint colored $help_color, __ <<'EOF' ;\n Prompt help:\n 1          - select a single item\n 3-5        - select a range of items\n@@ -1584,7 +1584,9 @@ sub quit_cmd {\n }\n \n sub help_cmd {\n-\tprint colored $help_color, <<\\EOF ;\n+# TRANSLATORS: please do not translate the command names\n+# 'status', 'update', 'revert', etc.\n+\tprint colored $help_color, __ <<'EOF' ;\n status        - show paths with changes\n update        - add working tree state to the staged set of changes\n revert        - revert staged set of changes back to the HEAD version\n-- \n2.11.0.rc0.33.gec17dab\n\n"},{"id":"306300","messageId":"1479823833.1956.7.camel@sapo.pt","threadId":"44461","inReplyTo":"20161111124541.8216-2-vascomalmeida@sapo.pt","subject":"Re: [PATCH v6 01/16] Git.pm: add subroutines for commenting lines","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-11-22T14:10:33Z","receivedAt":"2016-11-22T14:10:45Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"A Sex, 11-11-2016 às 11:45 -0100, Vasco Almeida escreveu:\n> +=item comment_lines ( STRING [, STRING... ])\n> +\n> +Comments lines following core.commentchar configuration.\n> +\n> +=cut\n> +\n> +sub comment_lines {\n> +       my $comment_line_char = config(\"core.commentchar\") || '#';\n> +       return prefix_lines(\"$comment_line_char \", @_);\n> +}\n> +\n\nIn light of the recent \"Fix problems with rebase -i when\ncore.commentchar is defined\" [1], I realized that this patch does not\nhandle the 'auto' value of core.commentchat configuration variable.\n\nI propose to do the patch below in the next re-roll.\n\n[1] http://www.mail-archive.com/git@vger.kernel.org/msg107818.html\n\n-- >8 --\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 3a6d846..8d33634 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -1073,6 +1073,7 @@ sub edit_hunk_manually {\n \tmy $is_reverse = $patch_mode_flavour{IS_REVERSE};\n \tmy ($remove_plus, $remove_minus) = $is_reverse ? ('-', '+') : ('+', '-');\n \tmy $comment_line_char = Git::config(\"core.commentchar\") || '#';\n+\t$comment_line_char = '#' if ($comment_line_char eq 'auto');\n \tprint $fh Git::comment_lines sprintf(__ <<EOF, $remove_minus, $remove_plus, $comment_line_char),\n ---\n To remove '%s' lines, make them ' ' lines (context).\ndiff --git a/perl/Git.pm b/perl/Git.pm\nindex 69cd1dd..47b5899 100644\n--- a/perl/Git.pm\n+++ b/perl/Git.pm\n@@ -1459,6 +1459,7 @@ Comments lines following core.commentchar configuration.\n \n sub comment_lines {\n \tmy $comment_line_char = config(\"core.commentchar\") || '#';\n+\t$comment_line_char = '#' if ($comment_line_char eq 'auto');\n \treturn prefix_lines(\"$comment_line_char \", @_);\n }\n"},{"id":"306317","messageId":"xmqqoa17quls.fsf@gitster.mtv.corp.google.com","threadId":"44461","inReplyTo":"1479823833.1956.7.camel@sapo.pt","subject":"Re: [PATCH v6 01/16] Git.pm: add subroutines for commenting lines","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-11-22T17:42:39Z","receivedAt":"2016-11-22T17:43:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Vasco Almeida <vascomalmeida@sapo.pt> writes:\n\n> A Sex, 11-11-2016 às 11:45 -0100, Vasco Almeida escreveu:\n>> +=item comment_lines ( STRING [, STRING... ])\n>> +\n>> +Comments lines following core.commentchar configuration.\n>> +\n>> +=cut\n>> +\n>> +sub comment_lines {\n>> +       my $comment_line_char = config(\"core.commentchar\") || '#';\n>> +       return prefix_lines(\"$comment_line_char \", @_);\n>> +}\n>> +\n>\n> In light of the recent \"Fix problems with rebase -i when\n> core.commentchar is defined\" [1], I realized that this patch does not\n> handle the 'auto' value of core.commentchat configuration variable.\n>\n> I propose to do the patch below in the next re-roll.\n>\n> [1] http://www.mail-archive.com/git@vger.kernel.org/msg107818.html\n\nThe incremental update below looks sensible.  We'd also want to\nprotect this codepath from a misconfigured two-or-more byte sequence\nin core.commentchar, I would suspect, to be consistent.\n\n> -- >8 --\n> diff --git a/git-add--interactive.perl b/git-add--interactive.perl\n> index 3a6d846..8d33634 100755\n> --- a/git-add--interactive.perl\n> +++ b/git-add--interactive.perl\n> @@ -1073,6 +1073,7 @@ sub edit_hunk_manually {\n>  \tmy $is_reverse = $patch_mode_flavour{IS_REVERSE};\n>  \tmy ($remove_plus, $remove_minus) = $is_reverse ? ('-', '+') : ('+', '-');\n>  \tmy $comment_line_char = Git::config(\"core.commentchar\") || '#';\n> +\t$comment_line_char = '#' if ($comment_line_char eq 'auto');\n>  \tprint $fh Git::comment_lines sprintf(__ <<EOF, $remove_minus, $remove_plus, $comment_line_char),\n>  ---\n>  To remove '%s' lines, make them ' ' lines (context).\n> diff --git a/perl/Git.pm b/perl/Git.pm\n> index 69cd1dd..47b5899 100644\n> --- a/perl/Git.pm\n> +++ b/perl/Git.pm\n> @@ -1459,6 +1459,7 @@ Comments lines following core.commentchar configuration.\n>  \n>  sub comment_lines {\n>  \tmy $comment_line_char = config(\"core.commentchar\") || '#';\n> +\t$comment_line_char = '#' if ($comment_line_char eq 'auto');\n>  \treturn prefix_lines(\"$comment_line_char \", @_);\n>  }\n"},{"id":"307368","messageId":"1481303956.4934.8.camel@sapo.pt","threadId":"44461","inReplyTo":"xmqqoa17quls.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v6 01/16] Git.pm: add subroutines for commenting lines","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-12-09T17:19:16Z","receivedAt":"2016-12-09T17:19:24Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"A Ter, 22-11-2016 às 09:42 -0800, Junio C Hamano escreveu:\n> The incremental update below looks sensible.  We'd also want to\n> protect this codepath from a misconfigured two-or-more byte sequence\n> in core.commentchar, I would suspect, to be consistent.\n\nAre the below changes alright for what you propose? It just checks if\nthe length of core.commentchar's value is 1, otherwise use '#' as the\ncomment_line_char.\nAs a note, when I set core.commentchar with \"git config\ncore.commentChar 'batata'\", I get the following error message when I\nissue \"git add -i\":\n\nerror: core.commentChar should only be one character\nfatal: bad config variable 'core.commentchar' in file '.git/config' at line 6\n\n-- >8 --\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 3a6d846..4e0ab5a 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -1072,7 +1072,7 @@ sub edit_hunk_manually {\n \tprint $fh @$oldtext;\n \tmy $is_reverse = $patch_mode_flavour{IS_REVERSE};\n \tmy ($remove_plus, $remove_minus) = $is_reverse ? ('-', '+') : ('+', '-');\n-\tmy $comment_line_char = Git::config(\"core.commentchar\") || '#';\n+\tmy $comment_line_char = Git::get_comment_line_char;\n \tprint $fh Git::comment_lines sprintf(__ <<EOF, $remove_minus, $remove_plus, $comment_line_char),\n ---\n To remove '%s' lines, make them ' ' lines (context).\ndiff --git a/perl/Git.pm b/perl/Git.pm\nindex 69cd1dd..e4da913 100644\n--- a/perl/Git.pm\n+++ b/perl/Git.pm\n@@ -1451,6 +1451,20 @@ sub prefix_lines {\n \treturn $string;\n }\n \n+=item get_comment_line_char ( )\n+\n+Gets the core.commentchar configuration value.\n+The value fallbacks to # if core.commentchar is set to 'auto'.\n+\n+=cut\n+\n+sub get_comment_line_char {\n+\tmy $comment_line_char = config(\"core.commentchar\") || '#';\n+\t$comment_line_char = '#' if ($comment_line_char eq 'auto');\n+\t$comment_line_char = '#' if (length($comment_line_char) != 1);\n+\treturn $comment_line_char;\n+}\n+\n =item comment_lines ( STRING [, STRING... ])\n \n Comments lines following core.commentchar configuration.\n@@ -1458,7 +1472,7 @@ Comments lines following core.commentchar configuration.\n =cut\n \n sub comment_lines {\n-\tmy $comment_line_char = config(\"core.commentchar\") || '#';\n+\tmy $comment_line_char = get_comment_line_char;\n \treturn prefix_lines(\"$comment_line_char \", @_);\n }\n \n"},{"id":"307370","messageId":"alpine.DEB.2.20.1612091832310.23160@virtualbox","threadId":"44461","inReplyTo":"1481303956.4934.8.camel@sapo.pt","subject":"Re: [PATCH v6 01/16] Git.pm: add subroutines for commenting lines","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-12-09T17:32:53Z","receivedAt":"2016-12-09T17:33:10Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Vasco,\n\nOn Fri, 9 Dec 2016, Vasco Almeida wrote:\n\n> A Ter, 22-11-2016 às 09:42 -0800, Junio C Hamano escreveu:\n> > The incremental update below looks sensible.  We'd also want to\n> > protect this codepath from a misconfigured two-or-more byte sequence\n> > in core.commentchar, I would suspect, to be consistent.\n> \n> Are the below changes alright for what you propose? It just checks if\n> the length of core.commentchar's value is 1, otherwise use '#' as the\n> comment_line_char.\n> As a note, when I set core.commentchar with \"git config\n> core.commentChar 'batata'\", I get the following error message when I\n> issue \"git add -i\":\n> \n> error: core.commentChar should only be one character\n> fatal: bad config variable 'core.commentchar' in file '.git/config' at line 6\n\nThis is exactly the same issue I fixed for rebase -i recently.\n\nGood eyes,\nDscho"},{"id":"307398","messageId":"xmqqk2b8rbbb.fsf@gitster.mtv.corp.google.com","threadId":"44461","inReplyTo":"alpine.DEB.2.20.1612091832310.23160@virtualbox","subject":"Re: [PATCH v6 01/16] Git.pm: add subroutines for commenting lines","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-12-09T22:23:52Z","receivedAt":"2016-12-09T22:24:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> Hi Vasco,\n>\n> On Fri, 9 Dec 2016, Vasco Almeida wrote:\n>\n>> A Ter, 22-11-2016 às 09:42 -0800, Junio C Hamano escreveu:\n>> > The incremental update below looks sensible. We'd also want to\n>> > protect this codepath from a misconfigured two-or-more byte sequence\n>> > in core.commentchar, I would suspect, to be consistent.\n>> \n>> Are the below changes alright for what you propose? It just checks if\n>> the length of core.commentchar's value is 1, otherwise use '#' as the\n>> comment_line_char.\n>> As a note, when I set core.commentchar with \"git config\n>> core.commentChar 'batata'\", I get the following error message when I\n>> issue \"git add -i\":\n>> \n>> error: core.commentChar should only be one character\n>> fatal: bad config variable 'core.commentchar' in file '.git/config' at line 6\n>\n> This is exactly the same issue I fixed for rebase -i recently.\n\nYes, but the patch we see here punts \"core.commentChar is not a\nsingle-byte single-letter--panic!\" case differently.  I think you\ndid \"just take the first one\" in \"rebase -i\", which I think is more\nin line with the rest of the system, and this addition to Git.pm\nshould do the same, I think.\n"},{"id":"307428","messageId":"1481364496.1993.14.camel@sapo.pt","threadId":"44461","inReplyTo":"xmqqk2b8rbbb.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v6 01/16] Git.pm: add subroutines for commenting lines","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-12-10T10:08:16Z","receivedAt":"2016-12-10T10:08:26Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"A Sex, 09-12-2016 às 14:23 -0800, Junio C Hamano escreveu:\n> > This is exactly the same issue I fixed for rebase -i recently.\n> \n> Yes, but the patch we see here punts \"core.commentChar is not a\n> single-byte single-letter--panic!\" case differently.  I think you\n> did \"just take the first one\" in \"rebase -i\", which I think is more\n> in line with the rest of the system, and this addition to Git.pm\n> should do the same, I think.\n\nI hope the changes below are in line with the rest of the system. If\nso, I will send a new re-roll with them.\n\nI wonder why this is important when Git errors out when\ncore.commentChar is set to more than 1 characters or 0 characters. Is\nit just to be consistent with \"rebase -i\" changes introduced\nby Johannes Schindelin?\n\nI am not sure what does \"if (length($comment_line_char) != 1)\" check.\nWhether it checks single-byte or single-letter or both...\n\n-- >8 --\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 3a6d846..4e0ab5a 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -1072,7 +1072,7 @@ sub edit_hunk_manually {\n \tprint $fh @$oldtext;\n \tmy $is_reverse = $patch_mode_flavour{IS_REVERSE};\n \tmy ($remove_plus, $remove_minus) = $is_reverse ? ('-', '+') :\n('+', '-');\n-\tmy $comment_line_char = Git::config(\"core.commentchar\") ||\n'#';\n+\tmy $comment_line_char = Git::get_comment_line_char;\n \tprint $fh Git::comment_lines sprintf(__ <<EOF, $remove_minus,\n$remove_plus, $comment_line_char),\n ---\n To remove '%s' lines, make them ' ' lines (context).\ndiff --git a/perl/Git.pm b/perl/Git.pm\nindex 69cd1dd..3211650 100644\n--- a/perl/Git.pm\n+++ b/perl/Git.pm\n@@ -1451,6 +1451,23 @@ sub prefix_lines {\n \treturn $string;\n }\n \n+=item get_comment_line_char ( )\n+\n+Gets the core.commentchar configuration value.\n+The value falls-back to # if core.commentchar is set to 'auto'.\n+\n+=cut\n+\n+sub get_comment_line_char {\n+\tmy $comment_line_char = config(\"core.commentchar\") || '#';\n+\t$comment_line_char = '#' if ($comment_line_char eq 'auto');\n+\tif (length($comment_line_char) != 1) {\n+\t\t# use first character\n+\t\t$comment_line_char = substr($comment_line_char, 0, 1);\n+\t}\n+\treturn $comment_line_char;\n+}\n+\n =item comment_lines ( STRING [, STRING... ])\n \n Comments lines following core.commentchar configuration.\n@@ -1458,7 +1475,7 @@ Comments lines following core.commentchar\nconfiguration.\n =cut\n \n sub comment_lines {\n-\tmy $comment_line_char = config(\"core.commentchar\") || '#';\n+\tmy $comment_line_char = get_comment_line_char;\n \treturn prefix_lines(\"$comment_line_char \", @_);\n }\n \n"},{"id":"307456","messageId":"xmqqy3zno2qv.fsf@gitster.mtv.corp.google.com","threadId":"44461","inReplyTo":"1481364496.1993.14.camel@sapo.pt","subject":"Re: [PATCH v6 01/16] Git.pm: add subroutines for commenting lines","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-12-10T22:09:28Z","receivedAt":"2016-12-10T22:09:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Vasco Almeida <vascomalmeida@sapo.pt> writes:\n\n> I wonder why this is important when Git errors out when\n> core.commentChar is set to more than 1 characters or 0 characters.\n\nI think it should be consistent with the way core.commentchar is\ntreated in the rest of the system, namely this bit from config.c:\n\n\tif (!strcmp(var, \"core.commentchar\")) {\n\t\tif (!value)\n\t\t\treturn config_error_nonbool(var);\n\t\telse if (!strcasecmp(value, \"auto\"))\n\t\t\tauto_comment_line_char = 1;\n\t\telse if (value[0] && !value[1]) {\n\t\t\tcomment_line_char = value[0];\n\t\t\tauto_comment_line_char = 0;\n\t\t} else\n\t\t\treturn error(\"core.commentChar should only be one character\");\n\t\treturn 0;\n\t}\n\nAnd I think I misread this piece of code.  \n\nWe only update comment_line_char from the default \"#\" when the\nconfigured value is a single-byte character and we ignore incorrect\nvalues in the configuration file.  So I think the patch you sent is\ncorrect after all.\n"},{"id":"307585","messageId":"1481627820.2041.21.camel@sapo.pt","threadId":"44461","inReplyTo":"xmqqy3zno2qv.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v6 01/16] Git.pm: add subroutines for commenting lines","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-12-13T11:17:00Z","receivedAt":"2016-12-13T11:17:09Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"A Sáb, 10-12-2016 às 14:09 -0800, Junio C Hamano escreveu:\n> We only update comment_line_char from the default \"#\" when the\n> configured value is a single-byte character and we ignore incorrect\n> values in the configuration file.  So I think the patch you sent is\n> correct after all.\n\nI am still not sure what version do we prefer.\n\nCheck whether core.commentchar is a single character. If not, use '#'\nas the $comment_line_char.\n\n+sub get_comment_line_char {\n+       my $comment_line_char = config(\"core.commentchar\") || '#';\n+       $comment_line_char = '#' if ($comment_line_char eq 'auto');\n+       $comment_line_char = '#' if (length($comment_line_char) != 1);\n+       return $comment_line_char;\n+}\n\nCheck whether core.commentchar is a single character. If not, use the\nfirst character of the core.commentchar value, mirroring the \"rebase\n-i\" behavior introduced recently.\n\n+sub get_comment_line_char {\n+       my $comment_line_char = config(\"core.commentchar\") || '#';\n+       $comment_line_char = '#' if ($comment_line_char eq 'auto');\n+       if (length($comment_line_char) != 1) {\n+               # use first character\n+               $comment_line_char = substr($comment_line_char, 0, 1);\n+       }\n+       return $comment_line_char;\n+}\n\nOr akin to what I had in the first patch related to handling 'auto'\nvalue of core.commentchar configuration variable:\n\n+sub get_comment_line_char {\n+       my $comment_line_char = config(\"core.commentchar\") || '#';\n+       $comment_line_char = '#' if ($comment_line_char eq 'auto');\n+       return $comment_line_char;\n+}\n\nWhich assumes that the value of core.commentchar configuration variable\nis either 'auto' or one single character, or the variable is not\ndefined.\n"},{"id":"307649","messageId":"xmqqinqn4rwu.fsf@gitster.mtv.corp.google.com","threadId":"44461","inReplyTo":"1481627820.2041.21.camel@sapo.pt","subject":"Re: [PATCH v6 01/16] Git.pm: add subroutines for commenting lines","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-12-13T18:15:13Z","receivedAt":"2016-12-13T18:16:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Vasco Almeida <vascomalmeida@sapo.pt> writes:\n\n>> We only update comment_line_char from the default \"#\" when the\n>> configured value is a single-byte character and we ignore incorrect\n>> values in the configuration file. So I think the patch you sent is\n>> correct after all.\n>\n> I am still not sure what version do we prefer.\n>\n> Check whether core.commentchar is a single character. If not, use '#'\n> as the $comment_line_char.\n\nThis, plus special casing \"auto\".\n\nPicking the first byte is inconsistent with the current practice\n(the paragraph you quoted above), I think.\n"}]}