Git development
 help / color / mirror / Atom feed
* [PATCH v6 13/16] i18n: send-email: mark warnings and errors for translation
From: Vasco Almeida @ 2016-11-11 12:45 UTC (permalink / raw)
  To: git
  Cc: Vasco Almeida, Jiang Xin, Ævar Arnfjörð Bjarmason,
	Jean-Noël AVILA, Jakub Narębski, David Aguilar,
	Junio C Hamano
In-Reply-To: <20161005172110.30801-1-vascomalmeida@sapo.pt>

Mark warnings, errors and other messages for translation.

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
---
 git-send-email.perl | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 06e64699b..00d234e11 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -118,20 +118,20 @@ sub format_2822_time {
 	my $localmin = $localtm[1] + $localtm[2] * 60;
 	my $gmtmin = $gmttm[1] + $gmttm[2] * 60;
 	if ($localtm[0] != $gmttm[0]) {
-		die "local zone differs from GMT by a non-minute interval\n";
+		die __("local zone differs from GMT by a non-minute interval\n");
 	}
 	if ((($gmttm[6] + 1) % 7) == $localtm[6]) {
 		$localmin += 1440;
 	} elsif ((($gmttm[6] - 1) % 7) == $localtm[6]) {
 		$localmin -= 1440;
 	} elsif ($gmttm[6] != $localtm[6]) {
-		die "local time offset greater than or equal to 24 hours\n";
+		die __("local time offset greater than or equal to 24 hours\n");
 	}
 	my $offset = $localmin - $gmtmin;
 	my $offhour = $offset / 60;
 	my $offmin = abs($offset % 60);
 	if (abs($offhour) >= 24) {
-		die ("local time offset greater than or equal to 24 hours\n");
+		die __("local time offset greater than or equal to 24 hours\n");
 	}
 
 	return sprintf("%s, %2d %s %d %02d:%02d:%02d %s%02d%02d",
@@ -199,13 +199,13 @@ sub do_edit {
 		map {
 			system('sh', '-c', $editor.' "$@"', $editor, $_);
 			if (($? & 127) || ($? >> 8)) {
-				die("the editor exited uncleanly, aborting everything");
+				die(__("the editor exited uncleanly, aborting everything"));
 			}
 		} @_;
 	} else {
 		system('sh', '-c', $editor.' "$@"', $editor, @_);
 		if (($? & 127) || ($? >> 8)) {
-			die("the editor exited uncleanly, aborting everything");
+			die(__("the editor exited uncleanly, aborting everything"));
 		}
 	}
 }
@@ -299,7 +299,7 @@ my $help;
 my $rc = GetOptions("h" => \$help,
                     "dump-aliases" => \$dump_aliases);
 usage() unless $rc;
-die "--dump-aliases incompatible with other options\n"
+die __("--dump-aliases incompatible with other options\n")
     if !$help and $dump_aliases and @ARGV;
 $rc = GetOptions(
 		    "sender|from=s" => \$sender,
@@ -362,7 +362,7 @@ unless ($rc) {
     usage();
 }
 
-die "Cannot run git format-patch from outside a repository\n"
+die __("Cannot run git format-patch from outside a repository\n")
 	if $format_patch and not $repo;
 
 # Now, let's fill any that aren't set in with defaults:
@@ -617,7 +617,7 @@ while (defined(my $f = shift @ARGV)) {
 }
 
 if (@rev_list_opts) {
-	die "Cannot run git format-patch from outside a repository\n"
+	die __("Cannot run git format-patch from outside a repository\n")
 		unless $repo;
 	push @files, $repo->command('format-patch', '-o', tempdir(CLEANUP => 1), @rev_list_opts);
 }
@@ -638,7 +638,7 @@ if (@files) {
 		print $_,"\n" for (@files);
 	}
 } else {
-	print STDERR "\nNo patch files specified!\n\n";
+	print STDERR __("\nNo patch files specified!\n\n");
 	usage();
 }
 
@@ -730,7 +730,7 @@ EOT
 			$sender = $1;
 			next;
 		} elsif (/^(?:To|Cc|Bcc):/i) {
-			print "To/Cc/Bcc fields are not interpreted yet, they have been ignored\n";
+			print __("To/Cc/Bcc fields are not interpreted yet, they have been ignored\n");
 			next;
 		}
 		print $c2 $_;
@@ -739,7 +739,7 @@ EOT
 	close $c2;
 
 	if ($summary_empty) {
-		print "Summary email is empty, skipping it\n";
+		print __("Summary email is empty, skipping it\n");
 		$compose = -1;
 	}
 } elsif ($annotate) {
@@ -1316,7 +1316,7 @@ EOF
 		$_ = ask(__("Send this email? ([y]es|[n]o|[q]uit|[a]ll): "),
 		         valid_re => qr/^(?:yes|y|no|n|quit|q|all|a)/i,
 		         default => $ask_default);
-		die "Send this email reply required" unless defined $_;
+		die __("Send this email reply required") unless defined $_;
 		if (/^n/i) {
 			return 0;
 		} elsif (/^q/i) {
@@ -1342,7 +1342,7 @@ EOF
 	} else {
 
 		if (!defined $smtp_server) {
-			die "The required SMTP server is not properly defined."
+			die __("The required SMTP server is not properly defined.")
 		}
 
 		if ($smtp_encryption eq 'ssl') {
@@ -1427,10 +1427,10 @@ EOF
 		}
 		print $header, "\n";
 		if ($smtp) {
-			print "Result: ", $smtp->code, ' ',
+			print __("Result: "), $smtp->code, ' ',
 				($smtp->message =~ /\n([^\n]+\n)$/s), "\n";
 		} else {
-			print "Result: OK\n";
+			print __("Result: OK\n");
 		}
 	}
 
@@ -1703,7 +1703,7 @@ sub apply_transfer_encoding {
 	$message = MIME::Base64::decode($message)
 		if ($from eq 'base64');
 
-	die "cannot send message as 7bit"
+	die __("cannot send message as 7bit")
 		if ($to eq '7bit' and $message =~ /[^[:ascii:]]/);
 	return $message
 		if ($to eq '7bit' or $to eq '8bit');
@@ -1711,7 +1711,7 @@ sub apply_transfer_encoding {
 		if ($to eq 'quoted-printable');
 	return MIME::Base64::encode($message, "\n")
 		if ($to eq 'base64');
-	die "invalid transfer encoding";
+	die __("invalid transfer encoding");
 }
 
 sub unique_email_list {
-- 
2.11.0.rc0.33.gec17dab


^ permalink raw reply related

* [PATCH v6 15/16] i18n: send-email: mark composing message for translation
From: Vasco Almeida @ 2016-11-11 12:45 UTC (permalink / raw)
  To: git
  Cc: Vasco Almeida, Jiang Xin, Ævar Arnfjörð Bjarmason,
	Jean-Noël AVILA, Jakub Narębski, David Aguilar,
	Junio C Hamano
In-Reply-To: <20161005172110.30801-1-vascomalmeida@sapo.pt>

When composing an e-mail, there is a message for the user whose lines
are beginning in "GIT:" that can be marked for translation.

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
---
 git-send-email.perl | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 7f3297cdf..068d60b3e 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -672,18 +672,20 @@ if ($compose) {
 	my $tpl_subject = $initial_subject || '';
 	my $tpl_reply_to = $initial_reply_to || '';
 
-	print $c <<EOT;
+	print $c <<EOT1, Git::prefix_lines("GIT: ", __ <<EOT2), <<EOT3;
 From $tpl_sender # This line is ignored.
-GIT: Lines beginning in "GIT:" will be removed.
-GIT: Consider including an overall diffstat or table of contents
-GIT: for the patch you are writing.
-GIT:
-GIT: Clear the body content if you don't wish to send a summary.
+EOT1
+Lines beginning in "GIT:" will be removed.
+Consider including an overall diffstat or table of contents
+for the patch you are writing.
+
+Clear the body content if you don't wish to send a summary.
+EOT2
 From: $tpl_sender
 Subject: $tpl_subject
 In-Reply-To: $tpl_reply_to
 
-EOT
+EOT3
 	for my $f (@files) {
 		print $c get_patch_subject($f);
 	}
-- 
2.11.0.rc0.33.gec17dab


^ permalink raw reply related

* [PATCH v6 12/16] i18n: send-email: mark strings for translation
From: Vasco Almeida @ 2016-11-11 12:45 UTC (permalink / raw)
  To: git
  Cc: Vasco Almeida, Jiang Xin, Ævar Arnfjörð Bjarmason,
	Jean-Noël AVILA, Jakub Narębski, David Aguilar,
	Junio C Hamano
In-Reply-To: <20161005172110.30801-1-vascomalmeida@sapo.pt>

Mark strings often displayed to the user for translation.

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
---
 git-send-email.perl | 54 +++++++++++++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 22 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index da81be40c..06e64699b 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -28,6 +28,7 @@ use File::Temp qw/ tempdir tempfile /;
 use File::Spec::Functions qw(catfile);
 use Error qw(:try);
 use Git;
+use Git::I18N;
 
 Getopt::Long::Configure qw/ pass_through /;
 
@@ -797,12 +798,12 @@ foreach my $f (@files) {
 }
 
 if (!defined $auto_8bit_encoding && scalar %broken_encoding) {
-	print "The following files are 8bit, but do not declare " .
-		"a Content-Transfer-Encoding.\n";
+	print __("The following files are 8bit, but do not declare " .
+		 "a Content-Transfer-Encoding.\n");
 	foreach my $f (sort keys %broken_encoding) {
 		print "    $f\n";
 	}
-	$auto_8bit_encoding = ask("Which 8bit encoding should I declare [UTF-8]? ",
+	$auto_8bit_encoding = ask(__("Which 8bit encoding should I declare [UTF-8]? "),
 				  valid_re => qr/.{4}/, confirm_only => 1,
 				  default => "UTF-8");
 }
@@ -829,7 +830,7 @@ if (defined $sender) {
 # But it's a no-op to run sanitize_address on an already sanitized address.
 $sender = sanitize_address($sender);
 
-my $to_whom = "To whom should the emails be sent (if anyone)?";
+my $to_whom = __("To whom should the emails be sent (if anyone)?");
 my $prompting = 0;
 if (!@initial_to && !defined $to_cmd) {
 	my $to = ask("$to_whom ",
@@ -859,7 +860,7 @@ sub expand_one_alias {
 
 if ($thread && !defined $initial_reply_to && $prompting) {
 	$initial_reply_to = ask(
-		"Message-ID to be used as In-Reply-To for the first email (if any)? ",
+		__("Message-ID to be used as In-Reply-To for the first email (if any)? "),
 		default => "",
 		valid_re => qr/\@.*\./, confirm_only => 1);
 }
@@ -918,7 +919,10 @@ sub validate_address {
 	my $address = shift;
 	while (!extract_valid_address($address)) {
 		print STDERR "error: unable to extract a valid address from: $address\n";
-		$_ = ask("What to do with this address? ([q]uit|[d]rop|[e]dit): ",
+		# TRANSLATORS: Make sure to include [q] [d] [e] in your
+		# translation. The program will only accept English input
+		# at this point.
+		$_ = ask(__("What to do with this address? ([q]uit|[d]rop|[e]dit): "),
 			valid_re => qr/^(?:quit|q|drop|d|edit|e)/i,
 			default => 'q');
 		if (/^d/i) {
@@ -1293,17 +1297,23 @@ Message-Id: $message_id
 		if ($needs_confirm eq "inform") {
 			$confirm_unconfigured = 0; # squelch this message for the rest of this run
 			$ask_default = "y"; # assume yes on EOF since user hasn't explicitly asked for confirmation
-			print "    The Cc list above has been expanded by additional\n";
-			print "    addresses found in the patch commit message. By default\n";
-			print "    send-email prompts before sending whenever this occurs.\n";
-			print "    This behavior is controlled by the sendemail.confirm\n";
-			print "    configuration setting.\n";
-			print "\n";
-			print "    For additional information, run 'git send-email --help'.\n";
-			print "    To retain the current behavior, but squelch this message,\n";
-			print "    run 'git config --global sendemail.confirm auto'.\n\n";
+			print __ <<EOF ;
+    The Cc list above has been expanded by additional
+    addresses found in the patch commit message. By default
+    send-email prompts before sending whenever this occurs.
+    This behavior is controlled by the sendemail.confirm
+    configuration setting.
+
+    For additional information, run 'git send-email --help'.
+    To retain the current behavior, but squelch this message,
+    run 'git config --global sendemail.confirm auto'.
+
+EOF
 		}
-		$_ = ask("Send this email? ([y]es|[n]o|[q]uit|[a]ll): ",
+		# TRANSLATORS: Make sure to include [y] [n] [q] [a] in your
+		# translation. The program will only accept English input
+		# at this point.
+		$_ = ask(__("Send this email? ([y]es|[n]o|[q]uit|[a]ll): "),
 		         valid_re => qr/^(?:yes|y|no|n|quit|q|all|a)/i,
 		         default => $ask_default);
 		die "Send this email reply required" unless defined $_;
@@ -1405,7 +1415,7 @@ Message-Id: $message_id
 	if ($quiet) {
 		printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject);
 	} else {
-		print (($dry_run ? "Dry-" : "")."OK. Log says:\n");
+		print($dry_run ? __("Dry-OK. Log says:\n") : __("OK. Log says:\n"));
 		if (!file_name_is_absolute($smtp_server)) {
 			print "Server: $smtp_server\n";
 			print "MAIL FROM:<$raw_from>\n";
@@ -1480,13 +1490,13 @@ foreach my $t (@files) {
 				$sauthor = sanitize_address($author);
 				next if $suppress_cc{'author'};
 				next if $suppress_cc{'self'} and $sauthor eq $sender;
-				printf("(mbox) Adding cc: %s from line '%s'\n",
+				printf(__("(mbox) Adding cc: %s from line '%s'\n"),
 					$1, $_) unless $quiet;
 				push @cc, $1;
 			}
 			elsif (/^To:\s+(.*)$/i) {
 				foreach my $addr (parse_address_line($1)) {
-					printf("(mbox) Adding to: %s from line '%s'\n",
+					printf(__("(mbox) Adding to: %s from line '%s'\n"),
 						$addr, $_) unless $quiet;
 					push @to, $addr;
 				}
@@ -1500,7 +1510,7 @@ foreach my $t (@files) {
 					} else {
 						next if ($suppress_cc{'cc'});
 					}
-					printf("(mbox) Adding cc: %s from line '%s'\n",
+					printf(__("(mbox) Adding cc: %s from line '%s'\n"),
 						$addr, $_) unless $quiet;
 					push @cc, $addr;
 				}
@@ -1534,7 +1544,7 @@ foreach my $t (@files) {
 			# So let's support that, too.
 			$input_format = 'lots';
 			if (@cc == 0 && !$suppress_cc{'cc'}) {
-				printf("(non-mbox) Adding cc: %s from line '%s'\n",
+				printf(__("(non-mbox) Adding cc: %s from line '%s'\n"),
 					$_, $_) unless $quiet;
 				push @cc, $_;
 			} elsif (!defined $subject) {
@@ -1557,7 +1567,7 @@ foreach my $t (@files) {
 				next if $suppress_cc{'bodycc'} and $what =~ /Cc/i;
 			}
 			push @cc, $c;
-			printf("(body) Adding cc: %s from line '%s'\n",
+			printf(__("(body) Adding cc: %s from line '%s'\n"),
 				$c, $_) unless $quiet;
 		}
 	}
-- 
2.11.0.rc0.33.gec17dab


^ permalink raw reply related

* [PATCH v6 11/16] i18n: add--interactive: mark status words for translation
From: Vasco Almeida @ 2016-11-11 12:45 UTC (permalink / raw)
  To: git
  Cc: Vasco Almeida, Jiang Xin, Ævar Arnfjörð Bjarmason,
	Jean-Noël AVILA, Jakub Narębski, David Aguilar,
	Junio C Hamano
In-Reply-To: <20161005172110.30801-1-vascomalmeida@sapo.pt>

Mark words 'nothing', 'unchanged' and 'binary' used to display what has
been staged or not, in "git add -i" status command.

Alternatively one could mark N__('nothing') no-op in order to
xgettext(1) extract the string and then trigger the translation at run
time only with __($print->{FILE}), but that has the side effect of triggering
retrieval of translations for the changes indicator too (e.g. +2/-1)
which may or may not be a problem.

To avoid that potential problem, mark only where there is certain to
trigger translation only of those words but in this case we must also
retrieve the translation for the eq tests, since the value assigned was
of the translation, not the English source.

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
---
 git-add--interactive.perl | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 5f6637bde..3a6d846da 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -295,7 +295,7 @@ sub list_modified {
 			my ($change, $bin);
 			$file = unquote_path($file);
 			if ($add eq '-' && $del eq '-') {
-				$change = 'binary';
+				$change = __('binary');
 				$bin = 1;
 			}
 			else {
@@ -304,7 +304,7 @@ sub list_modified {
 			$data{$file} = {
 				INDEX => $change,
 				BINARY => $bin,
-				FILE => 'nothing',
+				FILE => __('nothing'),
 			}
 		}
 		elsif (($adddel, $file) =
@@ -320,7 +320,7 @@ sub list_modified {
 			$file = unquote_path($file);
 			my ($change, $bin);
 			if ($add eq '-' && $del eq '-') {
-				$change = 'binary';
+				$change = __('binary');
 				$bin = 1;
 			}
 			else {
@@ -340,7 +340,7 @@ sub list_modified {
 			$file = unquote_path($2);
 			if (!exists $data{$file}) {
 				$data{$file} = +{
-					INDEX => 'unchanged',
+					INDEX => __('unchanged'),
 					BINARY => 0,
 				};
 			}
@@ -355,10 +355,10 @@ sub list_modified {
 
 		if ($only) {
 			if ($only eq 'index-only') {
-				next if ($it->{INDEX} eq 'unchanged');
+				next if ($it->{INDEX} eq __('unchanged'));
 			}
 			if ($only eq 'file-only') {
-				next if ($it->{FILE} eq 'nothing');
+				next if ($it->{FILE} eq __('nothing'));
 			}
 		}
 		push @return, +{
-- 
2.11.0.rc0.33.gec17dab


^ permalink raw reply related

* [PATCH v6 07/16] i18n: add--interactive: mark patch prompt for translation
From: Vasco Almeida @ 2016-11-11 12:45 UTC (permalink / raw)
  To: git
  Cc: Vasco Almeida, Jiang Xin, Ævar Arnfjörð Bjarmason,
	Jean-Noël AVILA, Jakub Narębski, David Aguilar,
	Junio C Hamano
In-Reply-To: <20161005172110.30801-1-vascomalmeida@sapo.pt>

Mark prompt message assembled in place for translation, unfolding each
use case for each entry in the %patch_modes hash table.

Previously, this script relied on whether $patch_mode was set to run the
command patch_update_cmd() or show status and loop the main loop. Now,
it uses $cmd to indicate we must run patch_update_cmd() and $patch_mode
is used to tell which flavor of the %patch_modes are we on.  This is
introduced in order to be able to mark and unfold the message prompt
knowing in which context we are.

The tracking of context was done previously by point %patch_mode_flavour
hash table to the correct entry of %patch_modes, focusing only on value
of %patch_modes. Now, we are also interested in the key ('staged',
'stash', 'checkout_head', ...).

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
---
 Makefile                  |  2 +-
 git-add--interactive.perl | 54 ++++++++++++++++++++++++++++++++++++++++-------
 perl/Git/I18N.pm          | 11 +++++++++-
 t/t0202/test.pl           |  5 ++++-
 4 files changed, 61 insertions(+), 11 deletions(-)

diff --git a/Makefile b/Makefile
index 328151dd6..ee89c0624 100644
--- a/Makefile
+++ b/Makefile
@@ -2114,7 +2114,7 @@ XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \
 XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell \
 	--keyword=gettextln --keyword=eval_gettextln
 XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --language=Perl \
-	--keyword=__ --keyword="__n:1,2"
+	--keyword=__ --keyword=N__ --keyword="__n:1,2"
 LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)
 LOCALIZED_SH = $(SCRIPT_SH)
 LOCALIZED_SH += git-parse-remote.sh
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index cd617837b..b7d382b10 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -93,6 +93,7 @@ sub colored {
 }
 
 # command line options
+my $cmd;
 my $patch_mode;
 my $patch_mode_revision;
 
@@ -173,7 +174,8 @@ my %patch_modes = (
 	},
 );
 
-my %patch_mode_flavour = %{$patch_modes{stage}};
+$patch_mode = 'stage';
+my %patch_mode_flavour = %{$patch_modes{$patch_mode}};
 
 sub run_cmd_pipe {
 	if ($^O eq 'MSWin32') {
@@ -1311,6 +1313,44 @@ sub display_hunks {
 	return $i;
 }
 
+my %patch_update_prompt_modes = (
+	stage => {
+		mode => N__("Stage mode change [y,n,q,a,d,/%s,?]? "),
+		deletion => N__("Stage deletion [y,n,q,a,d,/%s,?]? "),
+		hunk => N__("Stage this hunk [y,n,q,a,d,/%s,?]? "),
+	},
+	stash => {
+		mode => N__("Stash mode change [y,n,q,a,d,/%s,?]? "),
+		deletion => N__("Stash deletion [y,n,q,a,d,/%s,?]? "),
+		hunk => N__("Stash this hunk [y,n,q,a,d,/%s,?]? "),
+	},
+	reset_head => {
+		mode => N__("Unstage mode change [y,n,q,a,d,/%s,?]? "),
+		deletion => N__("Unstage deletion [y,n,q,a,d,/%s,?]? "),
+		hunk => N__("Unstage this hunk [y,n,q,a,d,/%s,?]? "),
+	},
+	reset_nothead => {
+		mode => N__("Apply mode change to index [y,n,q,a,d,/%s,?]? "),
+		deletion => N__("Apply deletion to index [y,n,q,a,d,/%s,?]? "),
+		hunk => N__("Apply this hunk to index [y,n,q,a,d,/%s,?]? "),
+	},
+	checkout_index => {
+		mode => N__("Discard mode change from worktree [y,n,q,a,d,/%s,?]? "),
+		deletion => N__("Discard deletion from worktree [y,n,q,a,d,/%s,?]? "),
+		hunk => N__("Discard this hunk from worktree [y,n,q,a,d,/%s,?]? "),
+	},
+	checkout_head => {
+		mode => N__("Discard mode change from index and worktree [y,n,q,a,d,/%s,?]? "),
+		deletion => N__("Discard deletion from index and worktree [y,n,q,a,d,/%s,?]? "),
+		hunk => N__("Discard this hunk from index and worktree [y,n,q,a,d,/%s,?]? "),
+	},
+	checkout_nothead => {
+		mode => N__("Apply mode change to index and worktree [y,n,q,a,d,/%s,?]? "),
+		deletion => N__("Apply deletion to index and worktree [y,n,q,a,d,/%s,?]? "),
+		hunk => N__("Apply this hunk to index and worktree [y,n,q,a,d,/%s,?]? "),
+	},
+);
+
 sub patch_update_file {
 	my $quit = 0;
 	my ($ix, $num);
@@ -1383,12 +1423,9 @@ sub patch_update_file {
 		for (@{$hunk[$ix]{DISPLAY}}) {
 			print;
 		}
-		print colored $prompt_color, $patch_mode_flavour{VERB},
-		  ($hunk[$ix]{TYPE} eq 'mode' ? ' mode change' :
-		   $hunk[$ix]{TYPE} eq 'deletion' ? ' deletion' :
-		   ' this hunk'),
-		  $patch_mode_flavour{TARGET},
-		  " [y,n,q,a,d,/$other,?]? ";
+		print colored $prompt_color,
+			sprintf(__($patch_update_prompt_modes{$patch_mode}{$hunk[$ix]{TYPE}}), $other);
+
 		my $line = prompt_single_character;
 		last unless defined $line;
 		if ($line) {
@@ -1644,6 +1681,7 @@ sub process_args {
 		die sprintf(__("invalid argument %s, expecting --"),
 			       $arg) unless $arg eq "--";
 		%patch_mode_flavour = %{$patch_modes{$patch_mode}};
+		$cmd = 1;
 	}
 	elsif ($arg ne "--") {
 		die sprintf(__("invalid argument %s, expecting --"), $arg);
@@ -1680,7 +1718,7 @@ sub main_loop {
 
 process_args();
 refresh();
-if ($patch_mode) {
+if ($cmd) {
 	patch_update_cmd();
 }
 else {
diff --git a/perl/Git/I18N.pm b/perl/Git/I18N.pm
index 617d8c2a1..c41425c8d 100644
--- a/perl/Git/I18N.pm
+++ b/perl/Git/I18N.pm
@@ -13,7 +13,7 @@ BEGIN {
 	}
 }
 
-our @EXPORT = qw(__ __n);
+our @EXPORT = qw(__ __n N__);
 our @EXPORT_OK = @EXPORT;
 
 sub __bootstrap_locale_messages {
@@ -54,6 +54,8 @@ BEGIN
 		*__ = sub ($) { $_[0] };
 		*__n = sub ($$$) { $_[2] == 1 ? $_[0] : $_[1] };
 	};
+
+	sub N__($) { return shift; }
 }
 
 1;
@@ -74,6 +76,7 @@ Git::I18N - Perl interface to Git's Gettext localizations
 
 	printf __n("commited %d file\n", "commited %d files\n", $files), $files;
 
+
 =head1 DESCRIPTION
 
 Git's internal Perl interface to gettext via L<Locale::Messages>. If
@@ -95,6 +98,12 @@ passthrough fallback function.
 
 L<Locale::Messages>'s ngettext function or passthrough fallback function.
 
+=head2 N__($)
+
+No-operation that only returns its argument. Use this if you want xgettext to
+extract the text to the pot template but do not want to trigger retrival of the
+translation at run time.
+
 =head1 AUTHOR
 
 E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avarab@gmail.com>
diff --git a/t/t0202/test.pl b/t/t0202/test.pl
index 4101833a8..2cbf7b959 100755
--- a/t/t0202/test.pl
+++ b/t/t0202/test.pl
@@ -4,7 +4,7 @@ use lib (split(/:/, $ENV{GITPERLLIB}));
 use strict;
 use warnings;
 use POSIX qw(:locale_h);
-use Test::More tests => 11;
+use Test::More tests => 13;
 use Git::I18N;
 
 my $has_gettext_library = $Git::I18N::__HAS_LIBRARY;
@@ -32,6 +32,7 @@ is_deeply(\@Git::I18N::EXPORT, \@Git::I18N::EXPORT_OK, "sanity: Git::I18N export
 	my %prototypes = (qw(
 		__	$
 		__n	$$$
+		N__	$
 	));
 	while (my ($sub, $proto) = each %prototypes) {
 		is(prototype(\&{"Git::I18N::$sub"}), $proto, "sanity: $sub has a $proto prototype");
@@ -55,6 +56,8 @@ is_deeply(\@Git::I18N::EXPORT, \@Git::I18N::EXPORT_OK, "sanity: Git::I18N export
 		"Get singular string through __n() in C locale");
 	is(__n($got_singular, $got_plural, 2), $expect_plural,
 		"Get plural string through __n() in C locale");
+
+	is(N__($got), $expect, "Passing a string through N__() in the C locale works");
 }
 
 # Test a basic message on different locales
-- 
2.11.0.rc0.33.gec17dab


^ permalink raw reply related

* [PATCH v6 05/16] i18n: clean.c: match string with git-add--interactive.perl
From: Vasco Almeida @ 2016-11-11 12:45 UTC (permalink / raw)
  To: git
  Cc: Vasco Almeida, Jiang Xin, Ævar Arnfjörð Bjarmason,
	Jean-Noël AVILA, Jakub Narębski, David Aguilar,
	Junio C Hamano
In-Reply-To: <20161005172110.30801-1-vascomalmeida@sapo.pt>

Change strings for help to match the ones in git-add--interactive.perl.
The strings now represent one entry to translate each rather then two
entries each different only by an ending newline character.

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
---
 builtin/clean.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/builtin/clean.c b/builtin/clean.c
index 0371010af..d6bc3aaae 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -287,11 +287,11 @@ static void pretty_print_menus(struct string_list *menu_list)
 static void prompt_help_cmd(int singleton)
 {
 	clean_print_color(CLEAN_COLOR_HELP);
-	printf_ln(singleton ?
+	printf(singleton ?
 		  _("Prompt help:\n"
 		    "1          - select a numbered item\n"
 		    "foo        - select item based on unique prefix\n"
-		    "           - (empty) select nothing") :
+		    "           - (empty) select nothing\n") :
 		  _("Prompt help:\n"
 		    "1          - select a single item\n"
 		    "3-5        - select a range of items\n"
@@ -299,7 +299,7 @@ static void prompt_help_cmd(int singleton)
 		    "foo        - select item based on unique prefix\n"
 		    "-...       - unselect specified items\n"
 		    "*          - choose all items\n"
-		    "           - (empty) finish selecting"));
+		    "           - (empty) finish selecting\n"));
 	clean_print_color(CLEAN_COLOR_RESET);
 }
 
@@ -508,7 +508,7 @@ static int parse_choice(struct menu_stuff *menu_stuff,
 		if (top <= 0 || bottom <= 0 || top > menu_stuff->nr || bottom > top ||
 		    (is_single && bottom != top)) {
 			clean_print_color(CLEAN_COLOR_ERROR);
-			printf_ln(_("Huh (%s)?"), (*ptr)->buf);
+			printf(_("Huh (%s)?\n"), (*ptr)->buf);
 			clean_print_color(CLEAN_COLOR_RESET);
 			continue;
 		}
@@ -774,7 +774,7 @@ static int ask_each_cmd(void)
 static int quit_cmd(void)
 {
 	string_list_clear(&del_list, 0);
-	printf_ln(_("Bye."));
+	printf(_("Bye.\n"));
 	return MENU_RETURN_NO_LOOP;
 }
 
-- 
2.11.0.rc0.33.gec17dab


^ permalink raw reply related

* [PATCH v6 01/16] Git.pm: add subroutines for commenting lines
From: Vasco Almeida @ 2016-11-11 12:45 UTC (permalink / raw)
  To: git
  Cc: Vasco Almeida, Jiang Xin, Ævar Arnfjörð Bjarmason,
	Jean-Noël AVILA, Jakub Narębski, David Aguilar,
	Junio C Hamano
In-Reply-To: <20161005172110.30801-1-vascomalmeida@sapo.pt>

Add subroutines prefix_lines and comment_lines.

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
---
 perl/Git.pm | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/perl/Git.pm b/perl/Git.pm
index b2732822a..69cd1ddec 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -1438,6 +1438,30 @@ sub END {
 
 } # %TEMP_* Lexical Context
 
+=item prefix_lines ( PREFIX, STRING [, STRING... ])
+
+Prefixes lines in C<STRING> with C<PREFIX>.
+
+=cut
+
+sub prefix_lines {
+	my $prefix = shift;
+	my $string = join("\n", @_);
+	$string =~ s/^/$prefix/mg;
+	return $string;
+}
+
+=item comment_lines ( STRING [, STRING... ])
+
+Comments lines following core.commentchar configuration.
+
+=cut
+
+sub comment_lines {
+	my $comment_line_char = config("core.commentchar") || '#';
+	return prefix_lines("$comment_line_char ", @_);
+}
+
 =back
 
 =head1 ERROR HANDLING
-- 
2.11.0.rc0.33.gec17dab


^ permalink raw reply related

* [PATCH] doc: fix location of 'info/' with $GIT_COMMON_DIR
From: Patrick Steinhardt @ 2016-11-11 11:23 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy, Patrick Steinhardt

With the introduction of the $GIT_COMMON_DIR variable, the
repository layout manual was changed to reflect the location for
many files in case the variable is set. While adding the new
locations, one typo snuck in regarding the location of the
'info/' folder, which is falsely claimed to reside at
"$GIT_COMMON_DIR/index".

Fix the typo to point to "$GIT_COMMON_DIR/info/" instead.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 Documentation/gitrepository-layout.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/gitrepository-layout.txt b/Documentation/gitrepository-layout.txt
index 577ee84..a5f99cb 100644
--- a/Documentation/gitrepository-layout.txt
+++ b/Documentation/gitrepository-layout.txt
@@ -177,7 +177,7 @@ sharedindex.<SHA-1>::
 info::
 	Additional information about the repository is recorded
 	in this directory. This directory is ignored if $GIT_COMMON_DIR
-	is set and "$GIT_COMMON_DIR/index" will be used instead.
+	is set and "$GIT_COMMON_DIR/info" will be used instead.
 
 info/refs::
 	This file helps dumb transports discover what refs are
-- 
2.10.2


^ permalink raw reply related

* Re: [RFC] Add way to make Git credentials accessible from clean/smudge filter
From: Lars Schneider @ 2016-11-11  9:40 UTC (permalink / raw)
  To: Jeff King; +Cc: Matthieu Moy, git, me
In-Reply-To: <20161111093122.osbdwmze5x5t742v@sigill.intra.peff.net>


On 11 Nov 2016, at 10:31, Jeff King <peff@peff.net> wrote:

> On Fri, Nov 11, 2016 at 10:28:56AM +0100, Lars Schneider wrote:
> 
>>> Yeah, that is the solution I was going to suggest. The credentials are
>>> totally orthogonal to the filters, and I would rather not shove them
>>> into the protocol. It's an extra process, but with the new multi-use
>>> smudge filter, it's one per git invocation, not one per file.
>> 
>> The trouble with "git credential" is that it works only if the credential 
>> helper is setup correctly. Although I assume that most people have setup this, 
>> I have also worked with a number of people who prefer to enter their passwords 
>> every time Git makes a network connection.
> 
> Are you sure about that? If I do:
> 
>  echo url=https://example.com/repo.git |
>  git credential fill
> 
> I get prompted for a username and password.

Hm.. either I don't understand you or I expressed myself unclear. 

Let's say a user runs:

$ git clone https://myrepo.git

If no credential helper is setup, then Git asks the user for credentials.
Afterwards Git starts downloading stuff. At some point Git will run my
smudge filter on some files and in my case the smudge filter needs the
Git credentials. AFAIK, the smudge filter has no way to get the credentials 
from Git at this point - not even by invoking "git credential". 
Is this correct?

- Lars

^ permalink raw reply

* Re: [RFC] Add way to make Git credentials accessible from clean/smudge filter
From: Jeff King @ 2016-11-11  9:31 UTC (permalink / raw)
  To: Lars Schneider; +Cc: Matthieu Moy, git, me
In-Reply-To: <77603924-3552-4146-9C9E-A106CFA96D7A@gmail.com>

On Fri, Nov 11, 2016 at 10:28:56AM +0100, Lars Schneider wrote:

> > Yeah, that is the solution I was going to suggest. The credentials are
> > totally orthogonal to the filters, and I would rather not shove them
> > into the protocol. It's an extra process, but with the new multi-use
> > smudge filter, it's one per git invocation, not one per file.
> 
> The trouble with "git credential" is that it works only if the credential 
> helper is setup correctly. Although I assume that most people have setup this, 
> I have also worked with a number of people who prefer to enter their passwords 
> every time Git makes a network connection.

Are you sure about that? If I do:

  echo url=https://example.com/repo.git |
  git credential fill

I get prompted for a username and password.

-Peff

^ permalink raw reply

* Re: [RFC] Add way to make Git credentials accessible from clean/smudge filter
From: Lars Schneider @ 2016-11-11  9:28 UTC (permalink / raw)
  To: Jeff King; +Cc: Matthieu Moy, git, me
In-Reply-To: <20161110160809.2gvf67rlnvounulf@sigill.intra.peff.net>


On 10 Nov 2016, at 17:08, Jeff King <peff@peff.net> wrote:

> On Thu, Nov 10, 2016 at 01:10:17PM +0100, Matthieu Moy wrote:
> 
>> Lars Schneider <larsxschneider@gmail.com> writes:
>> 
>>> I haven't looked at an implemenation approach at all. I wonder if this could
>>> be OK from a conceptional point of view or if there are obvious security 
>>> problems that I am missing.
>> 
>> Did you consider just running "git credential" from the filter? It may
>> not be the perfect solution, but it should work. I already used it to
>> get credential from a remote-helper (git-remote-mediawiki). When
>> prompting credentials interactively, it grabs the terminal directly, so
>> it work even if stdin/stdout are used for the protocol.
> 
> Yeah, that is the solution I was going to suggest. The credentials are
> totally orthogonal to the filters, and I would rather not shove them
> into the protocol. It's an extra process, but with the new multi-use
> smudge filter, it's one per git invocation, not one per file.

The trouble with "git credential" is that it works only if the credential 
helper is setup correctly. Although I assume that most people have setup this, 
I have also worked with a number of people who prefer to enter their passwords 
every time Git makes a network connection.

- Lars

^ permalink raw reply

* Re: [PATCH v1 2/2] travis-ci: disable GIT_TEST_HTTPD for macOS
From: Jeff King @ 2016-11-11  9:28 UTC (permalink / raw)
  To: Lars Schneider
  Cc: Junio C Hamano, Torsten Bögershausen, git, Eric Sunshine,
	hvoigt
In-Reply-To: <BAB2E4AE-7241-4991-A993-A60DBA75092B@gmail.com>

On Fri, Nov 11, 2016 at 10:13:44AM +0100, Lars Schneider wrote:

> > If you did want to have a more real-world network-based test, I think
> > the right solution is not for GitHub to set up a bunch of mock servers,
> > but to design client-side tests that hit the _real_ GitHub (or GitLab,
> > or whatever) and perform some basic operations. OTOH, people running
> > "master" (or "next", etc) are doing that implicitly every day.
> 
> That is actually a neat idea. We could setup a test repo on each of the major 
> Git hosting sites and then the TravisCI run could clone a repo and push
> changes to it. That shouldn't take long and would probably be a good real
> world test.
> 
> The credentials of these repos could be stored encrypted in Travis CI [1].
> 
> Where would such a test repo live on github.com? On github.com/git or would
> you prefer a separate organization? (no worries, I am not going to tackle this
> anytime soon -- too many things in my backlog already).

I think I'd prefer for it to live outside of the "git" organization
entirely, if only because it's credentials will be necessarily less
secure. It would be nice if people could point the suite at their own
user/repo, too, so they can run it outside of travis.

> BTW: I just noticed https://github.com/git/hello-world ... is this legitimate
> or did someone hack github.com/git? :)

Hmm. I wondered myself. There's no audit record of who created it, but
the creation timestamp is from 2008-07-23, which predates a lot of the
logging. So offhand, I'd say the likely explanation is "Scott Chacon
experimenting".

It's probably worth cleaning out now, though.

-Peff

^ permalink raw reply

* pre-rebase, post-rewrite, ...
From: Uwe Hausbrand @ 2016-11-11  9:22 UTC (permalink / raw)
  To: git

Hi all,

I am using the pre-rebase hook to generate a tag. I am using this tag
to check if my rebase lost any commits or content when i'm cleaning up
my local commit history.
What i now want to do is using a post-rebase hook to make a diff check
and remove my generated tag in case there is no difference.

I use the post-rewrite hook to make this check, but this only triggers
in case of a rewrite happening (which is understandable). But the
pre-rebase hook triggers on every git rebase call and so i generate
tags which could be removed automatically.

Is there any other hook i could use or why is there no post-rebase hook?

An older post mentions ( http://marc.info/?l=git&m=120796177421283&w=2
) point 5 which i think applies to my problem, but as i can't alias
real git commands (which is ok) i would need to use a new command.

Best regards,
Uwe

^ permalink raw reply

* Re: [PATCH v1 2/2] travis-ci: disable GIT_TEST_HTTPD for macOS
From: Lars Schneider @ 2016-11-11  9:13 UTC (permalink / raw)
  To: Jeff King
  Cc: Junio C Hamano, Torsten Bögershausen, git, Eric Sunshine,
	hvoigt
In-Reply-To: <20161111084725.jkdsdt4yslzsuh6d@sigill.intra.peff.net>


On 11 Nov 2016, at 09:47, Jeff King <peff@peff.net> wrote:

> On Fri, Nov 11, 2016 at 09:22:51AM +0100, Lars Schneider wrote:
> 
>> There would be an alternative way to approach the problem:
>> Someone (GitHub?, BitBucket?, GitLab?, ...) could setup a bunch of webservers
>> with popular configurations and a way to reset a clean test environment. Then 
>> the TravisCI client tests could go against these servers.
>> 
>> I realize that this idea is probably unrealistic because too much setup and
>> maintenance work would be required.
> 
> Yeah, it seems like it adds a lot of complexity for little gain. Plus it
> creates a network dependency on running the tests. I know you care
> mostly about Travis, but I am much more interested in all of the people
> (developers and not) who run "make test" on their own platforms.
> 
> If you did want to have a more real-world network-based test, I think
> the right solution is not for GitHub to set up a bunch of mock servers,
> but to design client-side tests that hit the _real_ GitHub (or GitLab,
> or whatever) and perform some basic operations. OTOH, people running
> "master" (or "next", etc) are doing that implicitly every day.

That is actually a neat idea. We could setup a test repo on each of the major 
Git hosting sites and then the TravisCI run could clone a repo and push
changes to it. That shouldn't take long and would probably be a good real
world test.

The credentials of these repos could be stored encrypted in Travis CI [1].

Where would such a test repo live on github.com? On github.com/git or would
you prefer a separate organization? (no worries, I am not going to tackle this
anytime soon -- too many things in my backlog already).

BTW: I just noticed https://github.com/git/hello-world ... is this legitimate
or did someone hack github.com/git? :)

Cheers,
Lars


[1] https://docs.travis-ci.com/user/environment-variables/#Defining-encrypted-variables-in-.travis.yml


^ permalink raw reply

* Re: [PATCH v7 01/17] ref-filter: implement %(if), %(then), and %(else) atoms
From: Karthik Nayak @ 2016-11-11  9:13 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jacob Keller, Git mailing list
In-Reply-To: <xmqqshqy53cj.fsf@gitster.mtv.corp.google.com>

On Fri, Nov 11, 2016 at 4:50 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Karthik Nayak <karthik.188@gmail.com> writes:
>
>>> Minor nit. I'm not sure what standard we use here at Git, but
>>> traditionally, I prefer to see { } blocks on all sections even if only
>>> one of them needs it. (That is, only drop the braces when every
>>> section is one line.) It also looks weird with a comment since it
>>> appears as multiple lines to the reader. I think the braces improve
>>> readability.
>>>
>>> I don't know whether that's Git's code base standard or not, however.
>>> It's not really worth a re-roll unless something else would need to
>>> change.
>>>
>> I believe this is the syntax followed in Git, xdiff/xmerge.c:173 and so on.
>
> That is a bad example for two reasons, if you mean this part:
>
>         if ((size = file->recs[i]->size) &&
>                         file->recs[i]->ptr[size - 1] == '\n')
>                 /* Last line; ends in LF; Is it CR/LF? */
>                 return size > 1 &&
>                         file->recs[i]->ptr[size - 2] == '\r';
> *       if (!i)
>                 /* The only line has no eol */
>                 return -1;
>         /* Determine eol from second-to-last line */
>
>
> What Jacob prefers is this:
>
> ---------------------------------------------
>         if (cond)
>                 simple;
>         else if (cond)
>                 simple;
>         else
>                 simple;
> ---------------------------------------------
>         if (cond) {
>                 simple;
>         } else if (cond) {
>                 no;
>                 longer;
>                 simple;
>         } else {
>                 simple;
>         }
> ---------------------------------------------
>
> That is, as long as all arms of if/else if/.../else cascade is
> simple, {} is used nowhere in the cascade, but once even one of them
> requires {} then all others gain {}.

I see, I mistook Jacob then.

I was talking about if we need to use {} whenever there's only a
single line of code
but followed by a comment which extends the if/else if/.../else block.

-- 
Regards,
Karthik Nayak

^ permalink raw reply

* Re: [credential.helper] unexpectedly save credential to multiple credential files
From: Qi Nark @ 2016-11-11  9:12 UTC (permalink / raw)
  To: Jeff King; +Cc: git
In-Reply-To: <20161111083649.d5newszupwyq5j6w@sigill.intra.peff.net>

On Fri, Nov 11, 2016 at 4:36 PM, Jeff King <peff@peff.net> wrote:
> On Fri, Nov 11, 2016 at 04:10:55PM +0800, Qi Nark wrote:
>
>> 1. git config --global credential.helper store
>> 2. cd to a local repository directory, git config credential.helper
>> store --file ./my_cred
>> 3. execute some git command which need credential like git ls-remote
>> 4. input my username & password, command done.
>>
>> As the result, **BOTH** the ./my_cred and ~/.git-credentials will save
>> the credentials I just input. But, shouldn't the local config override
>> the global ones, and only the ./my_cred should save it?
>
> No, that's the expected result. The set of credential helpers form a
> list, and each is run in turn. From "git help credentials":
>
>   If there are multiple instances of the credential.helper configuration
>   variable, each helper will be tried in turn, and may provide a
>   username, password, or nothing. Once Git has acquired both a username
>   and a password, no more helpers will be tried.
>
> That's talking about lookup, but the same principle applies to storage.
> But you may also find the paragraph below helpful:
>
>   If credential.helper is configured to the empty string, this resets
>   the helper list to empty (so you may override a helper set by a
>   lower-priority config file by configuring the empty-string helper,
>   followed by whatever set of helpers you would like).
>
> Note that the "reset" behavior was introduced in git v2.9.0, so you'll
> need at least that version.
>
> -Peff


Ok, that's fair enough. Thanks for your detailed explanation. The
version info is very important to me.

Thank you again.

^ permalink raw reply

* Re: [PATCH v7 01/17] ref-filter: implement %(if), %(then), and %(else) atoms
From: Karthik Nayak @ 2016-11-11  9:10 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jacob Keller, Git mailing list
In-Reply-To: <xmqqwpgb3p3g.fsf@gitster.mtv.corp.google.com>

On Fri, Nov 11, 2016 at 4:43 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Jacob Keller <jacob.keller@gmail.com> writes:
>
>> Ok, so I have only one minor nit, but otherwise this looks quite good
>> to me. A few comments explaining my understanding, but only one
>> suggested
>> change which is really a minor nit and not worth re-rolling just for it.
>
> As you didn't snip parts you didn't comment, I'll use this to add my
> own for convenience ;-)
>
>>> +if::
>>> +       Used as %(if)...%(then)...(%end) or
>>> +       %(if)...%(then)...%(else)...%(end).  If there is an atom with
>>> +       value or string literal after the %(if) then everything after
>>> +       the %(then) is printed, else if the %(else) atom is used, then
>>> +       everything after %(else) is printed. We ignore space when
>>> +       evaluating the string before %(then), this is useful when we
>>> +       use the %(HEAD) atom which prints either "*" or " " and we
>>> +       want to apply the 'if' condition only on the 'HEAD' ref.
>>> +
>>>  In addition to the above, for commit and tag objects, the header
>>>  field names (`tree`, `parent`, `object`, `type`, and `tag`) can
>>>  be used to specify the value in the header field.
>
> I see a few instances of (%end) that were meant to be %(end).
>

Will change that.

> Aren't the following two paragraphs ...
>
>>> +When a scripting language specific quoting is in effect (i.e. one of
>>> +`--shell`, `--perl`, `--python`, `--tcl` is used), except for opening
>>> +atoms, replacement from every %(atom) is quoted when and only when it
>>> +appears at the top-level (that is, when it appears outside
>>> +%($open)...%(end)).
>
>>> +When a scripting language specific quoting is in effect, everything
>>> +between a top-level opening atom and its matching %(end) is evaluated
>>> +according to the semantics of the opening atom and its result is
>>> +quoted.
>
> ... saying the same thing?
>

Yes. I'm not sure of what the context even was, but I shall remove the
first paragraph,
the second one seems to notify the same thing in simpler terms.

>
>>> +               }
>>> +       } else if (!if_then_else->condition_satisfied)
>>
>> Minor nit. I'm not sure what standard we use here at Git, but
>> traditionally, I prefer to see { } blocks on all sections even if only
>> one of them needs it. (That is, only drop the braces when every
>> section is one line.) It also looks weird with a comment since it
>> appears as multiple lines to the reader. I think the braces improve
>> readability.
>>
>> I don't know whether that's Git's code base standard or not, however.
>> It's not really worth a re-roll unless something else would need to
>> change.
>>
>
> In principle, we mimick the kernel style of using {} block even on a
> single-liner body in if/else if/else cascade when any one of them is
> not a single-liner and requires {}.  But we often ignore that when a
> truly trivial single liner follows if() even if its else clause is a
> big block, e.g.
>
>         if (cond)
>                 single;
>         else {
>                 big;
>                 block;
>         }
>
> I agree with you that this case should just use {} for the following
> paragraph, because it is technically a single-liner, but comes with
> a big comment block and is very much easier to read with {} around
> it.
>

Ah! I see, sure I'll change it :)

-- 
Regards,
Karthik Nayak

^ permalink raw reply

* Re: [PATCH v1 0/2] Fix default macOS build locally and on Travis CI
From: Lars Schneider @ 2016-11-11  9:01 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, tboegi
In-Reply-To: <xmqqwpgb58ab.fsf@gitster.mtv.corp.google.com>


On 10 Nov 2016, at 22:34, Junio C Hamano <gitster@pobox.com> wrote:

> Lars Schneider <larsxschneider@gmail.com> writes:
> 
>>> I've followed what was available at the public-inbox archive, but it
>>> is unclear what the conclusion was.  
>>> 
>>> For the first one your "how about" non-patch, to which Peff said
>>> "that's simple and good", looked good to me as well, but is it
>>> available as a final patch that I can just take and apply (otherwise
>>> I think I can do the munging myself, but I'd rather be spoon-fed
>>> when able ;-).
>> 
>> Sure! Here you go:
>> http://public-inbox.org/git/20161110111348.61580-1-larsxschneider@gmail.com/
>> 
>> 
>>> I do not have a strong opinion on the second one.  For an interim
>>> solution, disabling webserver tests certainly is expedite and safe,
>>> so I am fine taking it as-is, but I may have missed strong
>>> objections.
>> 
>> I haven't seen strong objections either. Just for reference, here is the patch:
>> http://public-inbox.org/git/20161017002550.88782-3-larsxschneider@gmail.com/
> 
> Thanks.  Picked up both of them.

Thanks! This makes "next" pass, again:
https://travis-ci.org/git/git/builds/174946111

BTW: If you want to learn about the build status of "git/git" branches on the
command line then you can use this snippet:

$ branch=next; echo "$branch: $(curl -s https://api.travis-ci.org/repos/git/git/branches/$branch | perl -lape 's/.*"state":"(\w+)".*"sha":"(\w{7}).*/$1 $2/g')"

Cheers,
Lars

^ permalink raw reply

* Re: [PATCH v1 2/2] travis-ci: disable GIT_TEST_HTTPD for macOS
From: Jeff King @ 2016-11-11  8:47 UTC (permalink / raw)
  To: Lars Schneider
  Cc: Junio C Hamano, Torsten Bögershausen, git, Eric Sunshine,
	hvoigt
In-Reply-To: <2088B631-4FE8-4232-9F3C-699122E6A7B0@gmail.com>

On Fri, Nov 11, 2016 at 09:22:51AM +0100, Lars Schneider wrote:

> There would be an alternative way to approach the problem:
> Someone (GitHub?, BitBucket?, GitLab?, ...) could setup a bunch of webservers
> with popular configurations and a way to reset a clean test environment. Then 
> the TravisCI client tests could go against these servers.
>
> I realize that this idea is probably unrealistic because too much setup and
> maintenance work would be required.

Yeah, it seems like it adds a lot of complexity for little gain. Plus it
creates a network dependency on running the tests. I know you care
mostly about Travis, but I am much more interested in all of the people
(developers and not) who run "make test" on their own platforms.

If you did want to have a more real-world network-based test, I think
the right solution is not for GitHub to set up a bunch of mock servers,
but to design client-side tests that hit the _real_ GitHub (or GitLab,
or whatever) and perform some basic operations. OTOH, people running
"master" (or "next", etc) are doing that implicitly every day.

-Peff

^ permalink raw reply

* Re: [PATCH] t6026: ensure that long-running script really is
From: Jeff King @ 2016-11-11  8:41 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Junio C Hamano, Johannes Schindelin, git, Andreas Schwab
In-Reply-To: <fbf517ad-7341-eb6d-ab38-4fe91410e57c@kdbg.org>

On Fri, Nov 11, 2016 at 07:50:14AM +0100, Johannes Sixt wrote:

> Shouldn't we then move the 'kill' out of test_when_finished and make
> it a proper condition of the test? Like this?
> 
> diff --git a/t/t6026-merge-attr.sh b/t/t6026-merge-attr.sh
> index 348d78b205..6ad8bd098a 100755
> --- a/t/t6026-merge-attr.sh
> +++ b/t/t6026-merge-attr.sh
> @@ -187,13 +187,19 @@ test_expect_success 'custom merge does not lock index' '
>  		sleep 3600 &
>  		echo $! >sleep.pid
>  	EOF
> -	test_when_finished "kill \$(cat sleep.pid)" &&
>  
>  	test_write_lines >.gitattributes \
>  		"* merge=ours" "text merge=sleep-an-hour" &&
>  	test_config merge.ours.driver true &&
>  	test_config merge.sleep-an-hour.driver ./sleep-an-hour.sh &&
> -	git merge master
> +	git merge master &&
> +
> +	# We are testing that the custom merge driver does not block
> +	# index.lock on Windows due to an inherited file handle.
> +	# To ensure that this test checks this condition, the process
> +	# must still be running at this point (and must have started
> +	# in the first place), hence, this kill must not fail:
> +	kill "$(cat sleep.pid)"
>  '

That makes it more obvious that the return value of "kill" is important,
which is good.

But the other thing the "kill" is doing is make sure we clean up after
ourselves, even if another part of the test fails. What happens if
"merge" unexpectedly fails after starting the sleep process?

I think the best compromise is a comment like the one you have here, but
around the test_when_finished call (and possibly bumping the call down
to right before "git merge master", which is where we expect the process
to start).

-Peff

^ permalink raw reply

* Re: [credential.helper] unexpectedly save credential to multiple credential files
From: Jeff King @ 2016-11-11  8:36 UTC (permalink / raw)
  To: Qi Nark; +Cc: git
In-Reply-To: <CACNr1V_fRfqvHUN=AQC8-Dj7ZAE7KXRAt+5skL3ZrcKu7SCLgA@mail.gmail.com>

On Fri, Nov 11, 2016 at 04:10:55PM +0800, Qi Nark wrote:

> 1. git config --global credential.helper store
> 2. cd to a local repository directory, git config credential.helper
> store --file ./my_cred
> 3. execute some git command which need credential like git ls-remote
> 4. input my username & password, command done.
> 
> As the result, **BOTH** the ./my_cred and ~/.git-credentials will save
> the credentials I just input. But, shouldn't the local config override
> the global ones, and only the ./my_cred should save it?

No, that's the expected result. The set of credential helpers form a
list, and each is run in turn. From "git help credentials":

  If there are multiple instances of the credential.helper configuration
  variable, each helper will be tried in turn, and may provide a
  username, password, or nothing. Once Git has acquired both a username
  and a password, no more helpers will be tried.

That's talking about lookup, but the same principle applies to storage.
But you may also find the paragraph below helpful:

  If credential.helper is configured to the empty string, this resets
  the helper list to empty (so you may override a helper set by a
  lower-priority config file by configuring the empty-string helper,
  followed by whatever set of helpers you would like).

Note that the "reset" behavior was introduced in git v2.9.0, so you'll
need at least that version.

-Peff

^ permalink raw reply

* Re: [git-for-windows] [ANNOUNCE] Prerelease: Git for Windows v2.11.0-rc0
From: Lars Schneider @ 2016-11-11  8:28 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git-for-windows, Git Mailing List, me
In-Reply-To: <alpine.DEB.2.20.1611102237230.24684@virtualbox>


On 10 Nov 2016, at 22:39, Johannes Schindelin <johannes.schindelin@gmx.de> wrote:

> Hi Lars,
> 
> On Wed, 9 Nov 2016, Lars Schneider wrote:
> 
>> On 05 Nov 2016, at 10:50, Johannes Schindelin <johannes.schindelin@gmx.de> wrote:
>> 
>>> I finally got around to rebase the Windows-specific patches (which seem to
>>> not make it upstream as fast as we get new ones) on top of upstream Git
>>> v2.11.0-rc0, and to bundle installers, portable Git and MinGit [*1*]:
>>> 
>>> https://github.com/git-for-windows/git/releases/tag/v2.11.0-rc0.windows.1
>> 
>> 
>> I tested a new feature in 2.11 on Windows today and it failed. After some 
>> confusion I realized that the feature is not on your 2.11 branch.
> 
> Oops. That must have been a major snafu on my side, very sorry for that.
> 
> I just tagged v2.11.0-rc0.windows.2 in https://github.com/dscho/git and
> will make a new prerelease tomorrow.

No worries! I am looking forward to the new release!

For some reason my own build of Git for Windows cannot use HTTPS properly.
I need to debug this further at some point.

Thanks,
Lars


^ permalink raw reply

* Re: [PATCH v1 2/2] travis-ci: disable GIT_TEST_HTTPD for macOS
From: Lars Schneider @ 2016-11-11  8:22 UTC (permalink / raw)
  To: Jeff King
  Cc: Junio C Hamano, Torsten Bögershausen, git, Eric Sunshine,
	hvoigt
In-Reply-To: <20161110161012.jube4bwbww2wa2ew@sigill.intra.peff.net>


On 10 Nov 2016, at 17:10, Jeff King <peff@peff.net> wrote:

> On Thu, Nov 10, 2016 at 12:07:14PM +0100, Lars Schneider wrote:
> 
>>> Using Apache in the tests has been the source of frequent portability
>>> problems and configuration headaches. I do wonder if we'd be better off
>>> using some small special-purpose web server (even a short perl script
>>> written around HTTP::Server::Simple or something).
>>> 
>>> On the other hand, testing against Apache approximates a more real-world
>>> case, which has value. It might be nice if our tests supported multiple
>>> web servers, but that would mean duplicating the config for each
>>> manually.
>> 
>> I agree that the real-world Apache test is more valuable and I really want
>> to keep the Linux Apache test running. However, I don't think many people
>> use macOS as Git web server and therefore I thought it is not worth the
>> effort to investigate this problem further.
> 
> IMHO, the value in the http tests is not testing the server side, but
> the client side. Without being able to set up a dummy HTTP server, we do
> not have any way to exercise the client side of git-over-http at all.
> And people on macOS _do_ use that. :)

Well, I haven't seen it from that perspective, yet, but I agree :-)


To all macOS users on the list:
Does anyone execute the tests with GIT_TEST_HTTPD enabled successfully?


There would be an alternative way to approach the problem:
Someone (GitHub?, BitBucket?, GitLab?, ...) could setup a bunch of webservers
with popular configurations and a way to reset a clean test environment. Then 
the TravisCI client tests could go against these servers.

I realize that this idea is probably unrealistic because too much setup and
maintenance work would be required.

Cheers,
Lars

^ permalink raw reply

* [credential.helper] unexpectedly save credential to multiple credential files
From: Qi Nark @ 2016-11-11  8:10 UTC (permalink / raw)
  To: git

1. git config --global credential.helper store
2. cd to a local repository directory, git config credential.helper
store --file ./my_cred
3. execute some git command which need credential like git ls-remote
4. input my username & password, command done.

As the result, **BOTH** the ./my_cred and ~/.git-credentials will save
the credentials I just input. But, shouldn't the local config override
the global ones, and only the ./my_cred should save it?

Thx.

^ permalink raw reply

* Re: [PATCH] t6026: ensure that long-running script really is
From: Johannes Sixt @ 2016-11-11  6:50 UTC (permalink / raw)
  To: Junio C Hamano, Johannes Schindelin; +Cc: git, Jeff King, Andreas Schwab
In-Reply-To: <xmqqfumy51tk.fsf@gitster.mtv.corp.google.com>

Am 11.11.2016 um 00:53 schrieb Junio C Hamano:
> Johannes Schindelin <johannes.schindelin@gmx.de> writes:
> 
>> When making sure that background tasks are cleaned up in 5babb5b
>> (t6026-merge-attr: clean up background process at end of test case,
>> 2016-09-07), we considered to let the background task sleep longer, just
>> to be certain that it will still be running when we want to kill it
>> after the test.
>>
>> Sadly, the assumption appears not to hold true that the test case passes
>> quickly enough to kill the background task within a second.
>>
>> Simply increase it to an hour. No system can be possibly slow enough to
>> make above-mentioned assumption incorrect.
>>
>> Reported by Andreas Schwab.
>>
>> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
>> ---
>> Published-As: https://github.com/dscho/git/releases/tag/t6026-sleep-v1
>> Fetch-It-Via: git fetch https://github.com/dscho/git t6026-sleep-v1
> 
> OK, I think this is a much better option.  Assuming 3600 is long
> enough for everybody (and if not, we have a bigger problem ;-),
> it will ensure that the stray process will be around when we run the
> 'git merge' test, and by not adding "|| :" after the kill, we check
> that the stray process is still there, i.e. we tested what we wanted
> to test.
> 
> Will revert the two patches that were queued previously and then
> queue this one.

Shouldn't we then move the 'kill' out of test_when_finished and make
it a proper condition of the test? Like this?

diff --git a/t/t6026-merge-attr.sh b/t/t6026-merge-attr.sh
index 348d78b205..6ad8bd098a 100755
--- a/t/t6026-merge-attr.sh
+++ b/t/t6026-merge-attr.sh
@@ -187,13 +187,19 @@ test_expect_success 'custom merge does not lock index' '
 		sleep 3600 &
 		echo $! >sleep.pid
 	EOF
-	test_when_finished "kill \$(cat sleep.pid)" &&
 
 	test_write_lines >.gitattributes \
 		"* merge=ours" "text merge=sleep-an-hour" &&
 	test_config merge.ours.driver true &&
 	test_config merge.sleep-an-hour.driver ./sleep-an-hour.sh &&
-	git merge master
+	git merge master &&
+
+	# We are testing that the custom merge driver does not block
+	# index.lock on Windows due to an inherited file handle.
+	# To ensure that this test checks this condition, the process
+	# must still be running at this point (and must have started
+	# in the first place), hence, this kill must not fail:
+	kill "$(cat sleep.pid)"
 '
 
 test_done


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox