{"thread":{"id":"48447","subject":"[PATCH 2/2] git-credential-netrc: accept gpg option","startedAt":"2018-05-09T21:42:20Z","lastAt":"2018-05-14T10:20:31Z","messageCount":10,"participants":["Luis Marsano","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"347137","messageId":"20180509213634.5198-3-luis.marsano@gmail.com","threadId":"48447","inReplyTo":"20180509213634.5198-1-luis.marsano@gmail.com","subject":"[PATCH 2/2] git-credential-netrc: accept gpg option","fromName":"Luis Marsano","fromEmail":"luis.marsano@gmail.com","sentAt":"2018-05-09T21:36:34Z","receivedAt":"2018-05-09T21:42:20Z","isPatch":true,"sender":{"key":"luis.marsano@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8139324?v=4"},"body":"git-credential-netrc was hardcoded to decrypt with 'gpg' regardless of the gpg.program option\nthis now uses the gpg command option if set, else, the gpg.program option set in the git repository or global configuration, else defaults to 'gpg'\nfor git-credential-netrc\n- use Git.pm for repository and global option queries\n- add -g|--gpg command option & document it in command usage\n- test repository & command options\n- support unicode\n\nSigned-off-by: Luis Marsano <luis.marsano@gmail.com>\nAcked-by: Ted Zlatanov <tzz@lifelogs.com>\n---\n contrib/credential/netrc/git-credential-netrc | 69 +++++++++++++------\n .../netrc/t-git-credential-netrc.sh           |  2 +-\n .../credential/netrc/test.command-option-gpg  |  2 +\n contrib/credential/netrc/test.git-config-gpg  |  2 +\n contrib/credential/netrc/test.netrc.gpg       |  0\n contrib/credential/netrc/test.pl              | 13 ++++\n 6 files changed, 65 insertions(+), 23 deletions(-)\n create mode 100755 contrib/credential/netrc/test.command-option-gpg\n create mode 100755 contrib/credential/netrc/test.git-config-gpg\n create mode 100644 contrib/credential/netrc/test.netrc.gpg\n\ndiff --git a/contrib/credential/netrc/git-credential-netrc b/contrib/credential/netrc/git-credential-netrc\nindex 1571a7b26..67cd689e8 100755\n--- a/contrib/credential/netrc/git-credential-netrc\n+++ b/contrib/credential/netrc/git-credential-netrc\n@@ -2,11 +2,16 @@\n \n use strict;\n use warnings;\n+use autodie;\n+use utf8;\n+use open ':encoding(UTF-8)';\n+use feature qw(unicode_strings unicode_eval);\n \n use Getopt::Long;\n use File::Basename;\n+use Git;\n \n-my $VERSION = \"0.1\";\n+my $VERSION = \"0.2\";\n \n my %options = (\n \t       help => 0,\n@@ -14,6 +19,7 @@ my %options = (\n \t       verbose => 0,\n \t       insecure => 0,\n \t       file => [],\n+\t       gpg => '',\n \n \t       # identical token maps, e.g. host -> host, will be inserted later\n \t       tmap => {\n@@ -54,6 +60,7 @@ GetOptions(\\%options,\n            \"insecure|k\",\n            \"verbose|v\",\n            \"file|f=s@\",\n+           'gpg|g:s',\n           );\n \n if ($options{help}) {\n@@ -62,27 +69,31 @@ if ($options{help}) {\n \n \tprint <<EOHIPPUS;\n \n-$0 [-f AUTHFILE1] [-f AUTHFILEN] [-d] [-v] [-k] get\n+$0 [(-f <authfile>)…] [-g <program>] [-d] [-v] [-k] get\n \n Version $VERSION by tzz\\@lifelogs.com.  License: BSD.\n \n Options:\n \n-  -f|--file AUTHFILE : specify netrc-style files.  Files with the .gpg extension\n-                       will be decrypted by GPG before parsing.  Multiple -f\n-                       arguments are OK.  They are processed in order, and the\n-                       first matching entry found is returned via the credential\n-                       helper protocol (see below).\n+  -f|--file <authfile>: specify netrc-style files.  Files with the .gpg extension\n+                        will be decrypted by GPG before parsing.  Multiple -f\n+                        arguments are OK.  They are processed in order, and the\n+                        first matching entry found is returned via the credential\n+                        helper protocol (see below).\n \n-                       When no -f option is given, .authinfo.gpg, .netrc.gpg,\n-\t\t       .authinfo, and .netrc files in your home directory are used\n-\t\t       in this order.\n+                        When no -f option is given, .authinfo.gpg, .netrc.gpg,\n+                        .authinfo, and .netrc files in your home directory are used\n+                        in this order.\n \n-  -k|--insecure      : ignore bad file ownership or permissions\n+  -g|--gpg <program>  : specify the program for GPG. By default, this is the value\n+                        of gpg.program in the git repository or global option or\n+                        gpg.\n \n-  -d|--debug         : turn on debugging (developer info)\n+  -k|--insecure       : ignore bad file ownership or permissions\n \n-  -v|--verbose       : be more verbose (show files and information found)\n+  -d|--debug          : turn on debugging (developer info)\n+\n+  -v|--verbose        : be more verbose (show files and information found)\n \n To enable this credential helper:\n \n@@ -91,15 +102,15 @@ To enable this credential helper:\n (Note that Git will prepend \"git-credential-\" to the helper name and look for it\n in the path.)\n \n-...and if you want lots of debugging info:\n+…and if you want lots of debugging info:\n \n   git config credential.helper '$shortname -f AUTHFILE -d'\n \n-...or to see the files opened and data found:\n+…or to see the files opened and data found:\n \n   git config credential.helper '$shortname -f AUTHFILE -v'\n \n-Only \"get\" mode is supported by this credential helper.  It opens every AUTHFILE\n+Only \"get\" mode is supported by this credential helper.  It opens every <authfile>\n and looks for the first entry that matches the requested search criteria:\n \n  'port|protocol':\n@@ -120,7 +131,7 @@ host=github.com\n protocol=https\n username=tzz\n \n-this credential helper will look for the first entry in every AUTHFILE that\n+this credential helper will look for the first entry in every <authfile> that\n matches\n \n machine github.com port https login tzz\n@@ -129,7 +140,7 @@ OR\n \n machine github.com protocol https login tzz\n \n-OR... etc. acceptable tokens as listed above.  Any unknown tokens are\n+OR… etc. acceptable tokens as listed above.  Any unknown tokens are\n simply ignored.\n \n Then, the helper will print out whatever tokens it got from the entry, including\n@@ -137,7 +148,7 @@ Then, the helper will print out whatever tokens it got from the entry, including\n back to \"protocol\".  Any redundant entry tokens (part of the original query) are\n skipped.\n \n-Again, note that only the first matching entry from all the AUTHFILEs, processed\n+Again, note that only the first matching entry from all the <authfile>s, processed\n in the sequence given on the command line, is used.\n \n Netrc/authinfo tokens can be quoted as 'STRING' or \"STRING\".\n@@ -152,7 +163,7 @@ EOHIPPUS\n my $mode = shift @ARGV;\n \n # Credentials must get a parameter, so die if it's missing.\n-die \"Syntax: $0 [-f AUTHFILE1] [-f AUTHFILEN] [-d] get\" unless defined $mode;\n+die \"Syntax: $0 [(-f <authfile>)…] [-d] get\" unless defined $mode;\n \n # Only support 'get' mode; with any other unsupported ones we just exit.\n exit 0 unless $mode eq 'get';\n@@ -172,6 +183,8 @@ unless (scalar @$files) {\n \t$files = $options{file} = [ map { glob $_ } @candidates ];\n }\n \n+load_config(\\%options);\n+\n my $query = read_credential_data_from_stdin();\n \n FILE:\n@@ -233,11 +246,11 @@ sub load_netrc {\n \n \tmy $io;\n \tif ($gpgmode) {\n-\t\tmy @cmd = (qw(gpg --decrypt), $file);\n+\t\tmy @cmd = ($options{'gpg'}, qw(--decrypt), $file);\n \t\tlog_verbose(\"Using GPG to open $file: [@cmd]\");\n \t\topen $io, \"-|\", @cmd;\n \t} else {\n-\t\tlog_verbose(\"Opening $file...\");\n+\t\tlog_verbose(\"Opening ${file}…\");\n \t\topen $io, '<', $file;\n \t}\n \n@@ -410,6 +423,18 @@ sub print_credential_data {\n \t\tprintf \"%s=%s\\n\", $git_token, $entry->{$git_token};\n \t}\n }\n+sub load_config {\n+\t# load settings from git config\n+\tmy $options = shift;\n+\tif ($options->{'gpg'} eq '') {\n+\t\tlocal $_ = Git->repository()->config('gpg.program');\n+\t\t# default to gpg for non-0 exit code\n+\t\t$options->{'gpg'} = defined\n+\t\t                 ? $_\n+\t\t                 : 'gpg';\n+\t}\n+\tlog_verbose(\"using $options{'gpg'} for GPG operations\");\n+}\n sub log_verbose {\n \treturn unless $options{verbose};\n \tprintf STDERR @_;\ndiff --git a/contrib/credential/netrc/t-git-credential-netrc.sh b/contrib/credential/netrc/t-git-credential-netrc.sh\nindex fa21ca240..58191a62f 100755\n--- a/contrib/credential/netrc/t-git-credential-netrc.sh\n+++ b/contrib/credential/netrc/t-git-credential-netrc.sh\n@@ -18,7 +18,7 @@\n \n \ttest_expect_success \\\n     'set up test repository' \\\n-    ':'\n+    'git config --add gpg.program test.git-config-gpg'\n \n \t# The external test will outputs its own plan\n \ttest_external_has_tap=1\ndiff --git a/contrib/credential/netrc/test.command-option-gpg b/contrib/credential/netrc/test.command-option-gpg\nnew file mode 100755\nindex 000000000..d8f1285d4\n--- /dev/null\n+++ b/contrib/credential/netrc/test.command-option-gpg\n@@ -0,0 +1,2 @@\n+#!/bin/sh\n+echo machine command-option-gpg login username password password\ndiff --git a/contrib/credential/netrc/test.git-config-gpg b/contrib/credential/netrc/test.git-config-gpg\nnew file mode 100755\nindex 000000000..65cf594c2\n--- /dev/null\n+++ b/contrib/credential/netrc/test.git-config-gpg\n@@ -0,0 +1,2 @@\n+#!/bin/sh\n+echo machine git-config-gpg login username password password\ndiff --git a/contrib/credential/netrc/test.netrc.gpg b/contrib/credential/netrc/test.netrc.gpg\nnew file mode 100644\nindex 000000000..e69de29bb\ndiff --git a/contrib/credential/netrc/test.pl b/contrib/credential/netrc/test.pl\nindex 7211b4857..3ec8934ac 100755\n--- a/contrib/credential/netrc/test.pl\n+++ b/contrib/credential/netrc/test.pl\n@@ -88,6 +88,19 @@ ok(scalar keys %$cred == 2, \"Got 2 'host:port kills host' keys\");\n is($cred->{password}, 'bobwillknow', \"Got correct 'host:port kills host' password\");\n is($cred->{username}, 'bob', \"Got correct 'host:port kills host' username\");\n \n+diag 'Testing netrc file decryption by git config gpg.program setting\\n';\n+$cred = run_credential( ['-f', $netrcGpg, 'get']\n+                      , { host => 'git-config-gpg' }\n+                      );\n+\n+ok(scalar keys %$cred == 2, 'Got keys decrypted by git config option');\n+\n+diag 'Testing netrc file decryption by gpg option\\n';\n+$cred = run_credential( ['-f', $netrcGpg, '-g', 'test.command-option-gpg', 'get']\n+                      , { host => 'command-option-gpg' }\n+                      );\n+\n+ok(scalar keys %$cred == 2, 'Got keys decrypted by command option');\n \n sub run_credential\n {\n-- \n2.17.0\n\n"},{"id":"347138","messageId":"20180509213634.5198-2-luis.marsano@gmail.com","threadId":"48447","inReplyTo":"20180509213634.5198-1-luis.marsano@gmail.com","subject":"[PATCH 1/2] git-credential-netrc: adapt to test framework for git","fromName":"Luis Marsano","fromEmail":"luis.marsano@gmail.com","sentAt":"2018-05-09T21:36:33Z","receivedAt":"2018-05-09T21:42:23Z","isPatch":true,"sender":{"key":"luis.marsano@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8139324?v=4"},"body":"until this change, git-credential-netrc did not test in a repository\nthis change reuses the main test framework, which provides such tests\nspecific changes\n- switch to Test::More module\n- use File::Basename & File::Spec::Functions\n\nSigned-off-by: Luis Marsano <luis.marsano@gmail.com>\nAcked-by: Ted Zlatanov <tzz@lifelogs.com>\n---\n contrib/credential/netrc/Makefile             |  4 +-\n .../netrc/t-git-credential-netrc.sh           | 31 ++++++++\n contrib/credential/netrc/test.pl              | 73 ++++++++++++-------\n 3 files changed, 78 insertions(+), 30 deletions(-)\n create mode 100755 contrib/credential/netrc/t-git-credential-netrc.sh\n\ndiff --git a/contrib/credential/netrc/Makefile b/contrib/credential/netrc/Makefile\nindex 51b76138a..0ffa40719 100644\n--- a/contrib/credential/netrc/Makefile\n+++ b/contrib/credential/netrc/Makefile\n@@ -1,5 +1,5 @@\n test:\n-\t./test.pl\n+\t./t-git-credential-netrc.sh\n \n testverbose:\n-\t./test.pl -d -v\n+\t./t-git-credential-netrc.sh -d -v\ndiff --git a/contrib/credential/netrc/t-git-credential-netrc.sh b/contrib/credential/netrc/t-git-credential-netrc.sh\nnew file mode 100755\nindex 000000000..fa21ca240\n--- /dev/null\n+++ b/contrib/credential/netrc/t-git-credential-netrc.sh\n@@ -0,0 +1,31 @@\n+#!/bin/sh\n+(\n+\tcd ../../../t\n+\ttest_description='git-credential-netrc'\n+\t. ./test-lib.sh\n+\n+\tif ! test_have_prereq PERL; then\n+\t\tskip_all='skipping perl interface tests, perl not available'\n+\t\ttest_done\n+\tfi\n+\n+\tperl -MTest::More -e 0 2>/dev/null || {\n+\t\tskip_all=\"Perl Test::More unavailable, skipping test\"\n+\t\ttest_done\n+\t}\n+\n+\t# set up test repository\n+\n+\ttest_expect_success \\\n+    'set up test repository' \\\n+    ':'\n+\n+\t# The external test will outputs its own plan\n+\ttest_external_has_tap=1\n+\n+\ttest_external \\\n+    'git-credential-netrc' \\\n+    perl \"$TEST_DIRECTORY\"/../contrib/credential/netrc/test.pl\n+\n+\ttest_done\n+)\ndiff --git a/contrib/credential/netrc/test.pl b/contrib/credential/netrc/test.pl\nindex 169b6463c..7211b4857 100755\n--- a/contrib/credential/netrc/test.pl\n+++ b/contrib/credential/netrc/test.pl\n@@ -1,83 +1,100 @@\n #!/usr/bin/perl\n+use lib (split(/:/, $ENV{GITPERLLIB}));\n \n use warnings;\n use strict;\n-use Test;\n+use Test::More qw(no_plan);\n+use File::Basename;\n+use File::Spec::Functions qw(:DEFAULT rel2abs);\n use IPC::Open2;\n \n-BEGIN { plan tests => 15 }\n+BEGIN {\n+\t# t-git-credential-netrc.sh kicks off our testing, so we have to go from there.\n+\tTest::More->builder->current_test(1);\n+\tTest::More->builder->no_ending(1);\n+}\n \n my @global_credential_args = @ARGV;\n-my $netrc = './test.netrc';\n-print \"# Testing insecure file, nothing should be found\\n\";\n+my $scriptDir = dirname rel2abs $0;\n+my $netrc = catfile $scriptDir, 'test.netrc';\n+my $netrcGpg = catfile $scriptDir, 'test.netrc.gpg';\n+my $gcNetrc = catfile $scriptDir, 'git-credential-netrc';\n+local $ENV{PATH} = join ':'\n+                      , $scriptDir\n+                      , $ENV{PATH}\n+                      ? $ENV{PATH}\n+                      : ();\n+\n+diag \"Testing insecure file, nothing should be found\\n\";\n chmod 0644, $netrc;\n my $cred = run_credential(['-f', $netrc, 'get'],\n \t\t\t  { host => 'github.com' });\n \n-ok(scalar keys %$cred, 0, \"Got 0 keys from insecure file\");\n+ok(scalar keys %$cred == 0, \"Got 0 keys from insecure file\");\n \n-print \"# Testing missing file, nothing should be found\\n\";\n+diag \"Testing missing file, nothing should be found\\n\";\n chmod 0644, $netrc;\n $cred = run_credential(['-f', '///nosuchfile///', 'get'],\n \t\t       { host => 'github.com' });\n \n-ok(scalar keys %$cred, 0, \"Got 0 keys from missing file\");\n+ok(scalar keys %$cred == 0, \"Got 0 keys from missing file\");\n \n chmod 0600, $netrc;\n \n-print \"# Testing with invalid data\\n\";\n+diag \"Testing with invalid data\\n\";\n $cred = run_credential(['-f', $netrc, 'get'],\n \t\t       \"bad data\");\n-ok(scalar keys %$cred, 4, \"Got first found keys with bad data\");\n+ok(scalar keys %$cred == 4, \"Got first found keys with bad data\");\n \n-print \"# Testing netrc file for a missing corovamilkbar entry\\n\";\n+diag \"Testing netrc file for a missing corovamilkbar entry\\n\";\n $cred = run_credential(['-f', $netrc, 'get'],\n \t\t       { host => 'corovamilkbar' });\n \n-ok(scalar keys %$cred, 0, \"Got no corovamilkbar keys\");\n+ok(scalar keys %$cred == 0, \"Got no corovamilkbar keys\");\n \n-print \"# Testing netrc file for a github.com entry\\n\";\n+diag \"Testing netrc file for a github.com entry\\n\";\n $cred = run_credential(['-f', $netrc, 'get'],\n \t\t       { host => 'github.com' });\n \n-ok(scalar keys %$cred, 2, \"Got 2 Github keys\");\n+ok(scalar keys %$cred == 2, \"Got 2 Github keys\");\n \n-ok($cred->{password}, 'carolknows', \"Got correct Github password\");\n-ok($cred->{username}, 'carol', \"Got correct Github username\");\n+is($cred->{password}, 'carolknows', \"Got correct Github password\");\n+is($cred->{username}, 'carol', \"Got correct Github username\");\n \n-print \"# Testing netrc file for a username-specific entry\\n\";\n+diag \"Testing netrc file for a username-specific entry\\n\";\n $cred = run_credential(['-f', $netrc, 'get'],\n \t\t       { host => 'imap', username => 'bob' });\n \n-ok(scalar keys %$cred, 2, \"Got 2 username-specific keys\");\n+ok(scalar keys %$cred == 2, \"Got 2 username-specific keys\");\n \n-ok($cred->{password}, 'bobwillknow', \"Got correct user-specific password\");\n-ok($cred->{protocol}, 'imaps', \"Got correct user-specific protocol\");\n+is($cred->{password}, 'bobwillknow', \"Got correct user-specific password\");\n+is($cred->{protocol}, 'imaps', \"Got correct user-specific protocol\");\n \n-print \"# Testing netrc file for a host:port-specific entry\\n\";\n+diag \"Testing netrc file for a host:port-specific entry\\n\";\n $cred = run_credential(['-f', $netrc, 'get'],\n \t\t       { host => 'imap2:1099' });\n \n-ok(scalar keys %$cred, 2, \"Got 2 host:port-specific keys\");\n+ok(scalar keys %$cred == 2, \"Got 2 host:port-specific keys\");\n \n-ok($cred->{password}, 'tzzknow', \"Got correct host:port-specific password\");\n-ok($cred->{username}, 'tzz', \"Got correct host:port-specific username\");\n+is($cred->{password}, 'tzzknow', \"Got correct host:port-specific password\");\n+is($cred->{username}, 'tzz', \"Got correct host:port-specific username\");\n \n-print \"# Testing netrc file that 'host:port kills host' entry\\n\";\n+diag \"Testing netrc file that 'host:port kills host' entry\\n\";\n $cred = run_credential(['-f', $netrc, 'get'],\n \t\t       { host => 'imap2' });\n \n-ok(scalar keys %$cred, 2, \"Got 2 'host:port kills host' keys\");\n+ok(scalar keys %$cred == 2, \"Got 2 'host:port kills host' keys\");\n+\n+is($cred->{password}, 'bobwillknow', \"Got correct 'host:port kills host' password\");\n+is($cred->{username}, 'bob', \"Got correct 'host:port kills host' username\");\n \n-ok($cred->{password}, 'bobwillknow', \"Got correct 'host:port kills host' password\");\n-ok($cred->{username}, 'bob', \"Got correct 'host:port kills host' username\");\n \n sub run_credential\n {\n \tmy $args = shift @_;\n \tmy $data = shift @_;\n \tmy $pid = open2(my $chld_out, my $chld_in,\n-\t\t\t'./git-credential-netrc', @global_credential_args,\n+\t\t\t$gcNetrc, @global_credential_args,\n \t\t\t@$args);\n \n \tdie \"Couldn't open pipe to netrc credential helper: $!\" unless $pid;\n-- \n2.17.0\n\n"},{"id":"347139","messageId":"20180509213634.5198-1-luis.marsano@gmail.com","threadId":"48447","inReplyTo":null,"subject":"[PATCH 0/2] Configurable GnuPG command for git-credential-netrc","fromName":"Luis Marsano","fromEmail":"luis.marsano@gmail.com","sentAt":"2018-05-09T21:36:32Z","receivedAt":"2018-05-09T21:42:24Z","isPatch":true,"sender":{"key":"luis.marsano@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8139324?v=4"},"body":"Hi everyone,\n\nShould `contrib/` area patches go here, too? Contributed Software\npage\nhttps://git.kernel.org/pub/scm/git/git.git/tree/contrib/README\nsays to forward them to \"jc\" (I'm guessing that's Junio), but I\nthink they're getting missed. Though the component author approves\n(acknowledgement below), am I missing anything for submission?\nThanks.\n\n> git-credential-netrc was hardcoded to call 'gpg' for decryption.\n> This is a problem on distributions like Debian that call modern\n> GnuPG something else, like 'gpg2'. This proposed update reuses\n> git's gpg.program configuration to customize GnuPG's name. It\n> introduces the -g|--gpg option on the git-credential-netrc\n> command to allow alternatively setting it in git's\n> credential.helper configuration. Since testing a git\n> configuration involves a temporary repository as provided by\n> git's main testing framework, a patch updating tests to reuse\n> the main framework is included, too.\n\n------- Forwarded message\nDelivered-To: luis.marsano@gmail.com\nReceived: by 10.103.152.29 with SMTP id a29csp214132vse; Fri, 20 Apr 2018\n 16:18:34 -0700 (PDT)\nReturn-Path: <ted@lifelogs.com>\nIn-Reply-To: <1524160133-8877-1-git-send-email-luis.marsano@gmail.com>\nReferences: <1524160133-8877-1-git-send-email-luis.marsano@gmail.com>\nFrom: Ted Zlatanov <tzz@lifelogs.com>\nDate: Fri, 20 Apr 2018 19:18:32 -0400\nMessage-ID: <CAMdP0d=sNtgwDnfZz88_cmAt6VYMGOozOC5q4o32R+yw+UcrAQ@mail.gmail.com>\nSubject: Re: [RFC PATCH 0/2] Configurable GnuPG command for\n git-credential-netrc\nTo: Luis Marsano <luis.marsano@gmail.com>\nStatus: OR\n\nThat looks terrific, Luis. It's a good change so I'd just go ahead\nand propose those patches. I don't see anything incorrect and\ntests are always good.\n\nTed\n\nOn Thu, Apr 19, 2018 at 1:48 PM, Luis Marsano luis.marsano@gmail.com\nwrote:\n\n> Hello Ted Zlatanov,\n\n> Thank you for git-credential-netrc. Will you please look over\n> these patches and decide if they need more work? They're also\n> available as the netrc-option branch at\n> https://github.com/lmmarsano/git This is a first contribution\n> for me, and I welcome input, suggestions, criticisms,\n> corrections. Thanks.\n\n> git-credential-netrc was hardcoded to call 'gpg' for decryption.\n> This is a problem on distributions like Debian that call modern\n> GnuPG something else, like 'gpg2'. This proposed update reuses\n> git's gpg.program configuration to customize GnuPG's name. It\n> introduces the -g|--gpg option on the git-credential-netrc\n> command to allow alternatively setting it in git's\n> credential.helper configuration. Since testing a git\n> configuration involves a temporary repository as provided by\n> git's main testing framework, a patch updating tests to reuse\n> the main framework is included, too.\n\n> Luis Marsano (2):\n> git-credential-netrc: adapt to test framework for git\n> git-credential-netrc: accept gpg option\n\n> contrib/credential/netrc/Makefile | 4 +-\n> contrib/credential/netrc/git-credential-netrc | 69 +++++++++++------\n> contrib/credential/netrc/t-git-credential-netrc.sh | 31 ++++++++\n> contrib/credential/netrc/test.command-option-gpg | 2 +\n> contrib/credential/netrc/test.git-config-gpg | 2 +\n> contrib/credential/netrc/test.netrc.gpg | 0\n> contrib/credential/netrc/test.pl | 86\n> +++++++++++++++-------\n> 7 files changed, 142 insertions(+), 52 deletions(-)\n> create mode 100755 contrib/credential/netrc/t-git-credential-netrc.sh\n> create mode 100755 contrib/credential/netrc/test.command-option-gpg\n> create mode 100755 contrib/credential/netrc/test.git-config-gpg\n> create mode 100644 contrib/credential/netrc/test.netrc.gpg\n\n> --\n> 2.7.4\n\n------- End of Forwarded message\n\nLuis Marsano (2):\n  git-credential-netrc: adapt to test framework for git\n  git-credential-netrc: accept gpg option\n\n contrib/credential/netrc/Makefile             |  4 +-\n contrib/credential/netrc/git-credential-netrc | 69 ++++++++++-----\n .../netrc/t-git-credential-netrc.sh           | 31 +++++++\n .../credential/netrc/test.command-option-gpg  |  2 +\n contrib/credential/netrc/test.git-config-gpg  |  2 +\n contrib/credential/netrc/test.netrc.gpg       |  0\n contrib/credential/netrc/test.pl              | 86 +++++++++++++------\n 7 files changed, 142 insertions(+), 52 deletions(-)\n create mode 100755 contrib/credential/netrc/t-git-credential-netrc.sh\n create mode 100755 contrib/credential/netrc/test.command-option-gpg\n create mode 100755 contrib/credential/netrc/test.git-config-gpg\n create mode 100644 contrib/credential/netrc/test.netrc.gpg\n\n-- \n2.17.0\n"},{"id":"347203","messageId":"xmqq7eobkfrc.fsf@gitster-ct.c.googlers.com","threadId":"48447","inReplyTo":"20180509213634.5198-2-luis.marsano@gmail.com","subject":"Re: [PATCH 1/2] git-credential-netrc: adapt to test framework for git","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-05-10T09:43:19Z","receivedAt":"2018-05-10T09:43:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Luis Marsano <luis.marsano@gmail.com> writes:\n\n> until this change, git-credential-netrc did not test in a repository\n> this change reuses the main test framework, which provides such tests\n> specific changes\n\nSorry, but I cannot quite parse what the above is trying to say.\n\n> - switch to Test::More module\n> - use File::Basename & File::Spec::Functions\n>\n> Signed-off-by: Luis Marsano <luis.marsano@gmail.com>\n> Acked-by: Ted Zlatanov <tzz@lifelogs.com>\n> ---\n>  contrib/credential/netrc/Makefile             |  4 +-\n>  .../netrc/t-git-credential-netrc.sh           | 31 ++++++++\n>  contrib/credential/netrc/test.pl              | 73 ++++++++++++-------\n>  3 files changed, 78 insertions(+), 30 deletions(-)\n>  create mode 100755 contrib/credential/netrc/t-git-credential-netrc.sh\n\nWill queue, but may need to make the log message\nreadable/understandable.\n\nThanks.\n"},{"id":"347205","messageId":"xmqq36yzkf3v.fsf@gitster-ct.c.googlers.com","threadId":"48447","inReplyTo":"20180509213634.5198-3-luis.marsano@gmail.com","subject":"Re: [PATCH 2/2] git-credential-netrc: accept gpg option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-05-10T09:57:24Z","receivedAt":"2018-05-10T09:57:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Luis Marsano <luis.marsano@gmail.com> writes:\n\n> git-credential-netrc was hardcoded to decrypt with 'gpg' regardless of the gpg.program option\n> this now uses the gpg command option if set, else, the gpg.program option set in the git repository or global configuration, else defaults to 'gpg'\n> for git-credential-netrc\n\nThese lines are way overlong.  Wrap at around 72-78 cols, perhaps.\nComplete each sentence with a full-stop.\n\n> - use Git.pm for repository and global option queries\n> - add -g|--gpg command option & document it in command usage\n> - test repository & command options\n> - support unicode\n\nThere are other changes that are not explained/justified here, I\nthink.\n\n - Instead of ALLCAPS as a placeholder for a command line argument in\n   the help text, use <placeholder>, because doing so is better due\n   to such and such reasons.\n\nI think it is good to consistently do so, but it is unclear why\nALLCAPS is bad and <placeholder> is better.  That needs to be\nexplained.\n\n - Replace three-dots in the help text with U+2026 to punish those\n   who are still using unicode-inapable terminal in this century.\n\nI do not think this part of the patch is a good idea at all, but\nperhaps I misunderstood the reason behind this change you had in\nmind (as you did not explain it in the proposed log message).\n\n> @@ -62,27 +69,31 @@ if ($options{help}) {\n>  \n>  \tprint <<EOHIPPUS;\n>  \n> -$0 [-f AUTHFILE1] [-f AUTHFILEN] [-d] [-v] [-k] get\n> +$0 [(-f <authfile>)…] [-g <program>] [-d] [-v] [-k] get\n\nIs this a desired change, or unwanted change left in the patch by\naccident?\n\n\n> -...and if you want lots of debugging info:\n> +…and if you want lots of debugging info:\n\nIs this a desired change, or unwanted change left in the patch by\naccident?\n\n>  \n>    git config credential.helper '$shortname -f AUTHFILE -d'\n>  \n> -...or to see the files opened and data found:\n> +…or to see the files opened and data found:\n>  \n\nDitto.\n\n>    git config credential.helper '$shortname -f AUTHFILE -v'\n>  \n> -Only \"get\" mode is supported by this credential helper.  It opens every AUTHFILE\n> +Only \"get\" mode is supported by this credential helper.  It opens every <authfile>\n>  and looks for the first entry that matches the requested search criteria:\n>  \n>   'port|protocol':\n> @@ -120,7 +131,7 @@ host=github.com\n>  protocol=https\n>  username=tzz\n>  \n> -this credential helper will look for the first entry in every AUTHFILE that\n> +this credential helper will look for the first entry in every <authfile> that\n>  matches\n>  \n>  machine github.com port https login tzz\n> @@ -129,7 +140,7 @@ OR\n>  \n>  machine github.com protocol https login tzz\n>  \n> -OR... etc. acceptable tokens as listed above.  Any unknown tokens are\n> +OR… etc. acceptable tokens as listed above.  Any unknown tokens are\n\nDitto.\n\n>  # Credentials must get a parameter, so die if it's missing.\n> -die \"Syntax: $0 [-f AUTHFILE1] [-f AUTHFILEN] [-d] get\" unless defined $mode;\n> +die \"Syntax: $0 [(-f <authfile>)…] [-d] get\" unless defined $mode;\n\nDitto.\n\n"},{"id":"347444","messageId":"20180512091728.4931-3-luis.marsano@gmail.com","threadId":"48447","inReplyTo":"20180512091728.4931-1-luis.marsano@gmail.com","subject":"[PATCH v2 2/2] git-credential-netrc: accept gpg option","fromName":"Luis Marsano","fromEmail":"luis.marsano@gmail.com","sentAt":"2018-05-12T09:17:28Z","receivedAt":"2018-05-12T09:26:26Z","isPatch":true,"sender":{"key":"luis.marsano@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8139324?v=4"},"body":"git-credential-netrc was hardcoded to decrypt with 'gpg' regardless of\nthe gpg.program option. This is a problem on distributions like Debian\nthat call modern GnuPG something else, like 'gpg2'.\nSet the command according to these settings in descending precedence\n1. the git-credential-netrc command -g|--gpg option\n2. the git gpg.program configuration option\n3. the default: 'gpg'\n\nFor conformance with Documentation/CodingGuidelines\n- use Git.pm for repository and global option queries\n- document -g|--gpg command option in command usage\n- test repository & command options\n- write documentation placeholders according to main standards\n\nSigned-off-by: Luis Marsano <luis.marsano@gmail.com>\nAcked-by: Ted Zlatanov <tzz@lifelogs.com>\n---\n contrib/credential/netrc/git-credential-netrc | 58 ++++++++++++-------\n .../netrc/t-git-credential-netrc.sh           |  2 +-\n .../credential/netrc/test.command-option-gpg  |  2 +\n contrib/credential/netrc/test.git-config-gpg  |  2 +\n contrib/credential/netrc/test.netrc.gpg       |  0\n contrib/credential/netrc/test.pl              | 22 ++++++-\n 6 files changed, 62 insertions(+), 24 deletions(-)\n create mode 100755 contrib/credential/netrc/test.command-option-gpg\n create mode 100755 contrib/credential/netrc/test.git-config-gpg\n create mode 100644 contrib/credential/netrc/test.netrc.gpg\n\ndiff --git a/contrib/credential/netrc/git-credential-netrc b/contrib/credential/netrc/git-credential-netrc\nindex 1571a7b26..0b9a94102 100755\n--- a/contrib/credential/netrc/git-credential-netrc\n+++ b/contrib/credential/netrc/git-credential-netrc\n@@ -2,11 +2,13 @@\n \n use strict;\n use warnings;\n+use autodie;\n \n use Getopt::Long;\n use File::Basename;\n+use Git;\n \n-my $VERSION = \"0.1\";\n+my $VERSION = \"0.2\";\n \n my %options = (\n \t       help => 0,\n@@ -54,6 +56,7 @@ GetOptions(\\%options,\n            \"insecure|k\",\n            \"verbose|v\",\n            \"file|f=s@\",\n+           'gpg|g:s',\n           );\n \n if ($options{help}) {\n@@ -62,27 +65,31 @@ if ($options{help}) {\n \n \tprint <<EOHIPPUS;\n \n-$0 [-f AUTHFILE1] [-f AUTHFILEN] [-d] [-v] [-k] get\n+$0 [(-f <authfile>)...] [-g <program>] [-d] [-v] [-k] get\n \n Version $VERSION by tzz\\@lifelogs.com.  License: BSD.\n \n Options:\n \n-  -f|--file AUTHFILE : specify netrc-style files.  Files with the .gpg extension\n-                       will be decrypted by GPG before parsing.  Multiple -f\n-                       arguments are OK.  They are processed in order, and the\n-                       first matching entry found is returned via the credential\n-                       helper protocol (see below).\n+  -f|--file <authfile>: specify netrc-style files.  Files with the .gpg\n+                        extension will be decrypted by GPG before parsing.\n+                        Multiple -f arguments are OK.  They are processed in\n+                        order, and the first matching entry found is returned\n+                        via the credential helper protocol (see below).\n \n-                       When no -f option is given, .authinfo.gpg, .netrc.gpg,\n-\t\t       .authinfo, and .netrc files in your home directory are used\n-\t\t       in this order.\n+                        When no -f option is given, .authinfo.gpg, .netrc.gpg,\n+                        .authinfo, and .netrc files in your home directory are\n+                        used in this order.\n \n-  -k|--insecure      : ignore bad file ownership or permissions\n+  -g|--gpg <program>  : specify the program for GPG. By default, this is the\n+                        value of gpg.program in the git repository or global\n+                        option or gpg.\n \n-  -d|--debug         : turn on debugging (developer info)\n+  -k|--insecure       : ignore bad file ownership or permissions\n \n-  -v|--verbose       : be more verbose (show files and information found)\n+  -d|--debug          : turn on debugging (developer info)\n+\n+  -v|--verbose        : be more verbose (show files and information found)\n \n To enable this credential helper:\n \n@@ -99,8 +106,9 @@ in the path.)\n \n   git config credential.helper '$shortname -f AUTHFILE -v'\n \n-Only \"get\" mode is supported by this credential helper.  It opens every AUTHFILE\n-and looks for the first entry that matches the requested search criteria:\n+Only \"get\" mode is supported by this credential helper.  It opens every\n+<authfile> and looks for the first entry that matches the requested search\n+criteria:\n \n  'port|protocol':\n    The protocol that will be used (e.g., https). (protocol=X)\n@@ -120,7 +128,7 @@ host=github.com\n protocol=https\n username=tzz\n \n-this credential helper will look for the first entry in every AUTHFILE that\n+this credential helper will look for the first entry in every <authfile> that\n matches\n \n machine github.com port https login tzz\n@@ -137,8 +145,8 @@ Then, the helper will print out whatever tokens it got from the entry, including\n back to \"protocol\".  Any redundant entry tokens (part of the original query) are\n skipped.\n \n-Again, note that only the first matching entry from all the AUTHFILEs, processed\n-in the sequence given on the command line, is used.\n+Again, note that only the first matching entry from all the <authfile>s,\n+processed in the sequence given on the command line, is used.\n \n Netrc/authinfo tokens can be quoted as 'STRING' or \"STRING\".\n \n@@ -152,7 +160,7 @@ EOHIPPUS\n my $mode = shift @ARGV;\n \n # Credentials must get a parameter, so die if it's missing.\n-die \"Syntax: $0 [-f AUTHFILE1] [-f AUTHFILEN] [-d] get\" unless defined $mode;\n+die \"Syntax: $0 [(-f <authfile>)...] [-d] get\" unless defined $mode;\n \n # Only support 'get' mode; with any other unsupported ones we just exit.\n exit 0 unless $mode eq 'get';\n@@ -172,6 +180,8 @@ unless (scalar @$files) {\n \t$files = $options{file} = [ map { glob $_ } @candidates ];\n }\n \n+load_config(\\%options);\n+\n my $query = read_credential_data_from_stdin();\n \n FILE:\n@@ -233,7 +243,7 @@ sub load_netrc {\n \n \tmy $io;\n \tif ($gpgmode) {\n-\t\tmy @cmd = (qw(gpg --decrypt), $file);\n+\t\tmy @cmd = ($options{'gpg'}, qw(--decrypt), $file);\n \t\tlog_verbose(\"Using GPG to open $file: [@cmd]\");\n \t\topen $io, \"-|\", @cmd;\n \t} else {\n@@ -410,6 +420,14 @@ sub print_credential_data {\n \t\tprintf \"%s=%s\\n\", $git_token, $entry->{$git_token};\n \t}\n }\n+sub load_config {\n+\t# load settings from git config\n+\tmy $options = shift;\n+\t# set from command argument, gpg.program option, or default to gpg\n+\t$options->{'gpg'} //= Git->repository()->config('gpg.program')\n+\t                  // 'gpg';\n+\tlog_verbose(\"using $options{'gpg'} for GPG operations\");\n+}\n sub log_verbose {\n \treturn unless $options{verbose};\n \tprintf STDERR @_;\ndiff --git a/contrib/credential/netrc/t-git-credential-netrc.sh b/contrib/credential/netrc/t-git-credential-netrc.sh\nindex efb81efed..58191a62f 100755\n--- a/contrib/credential/netrc/t-git-credential-netrc.sh\n+++ b/contrib/credential/netrc/t-git-credential-netrc.sh\n@@ -18,7 +18,7 @@\n \n \ttest_expect_success \\\n     'set up test repository' \\\n-    :\n+    'git config --add gpg.program test.git-config-gpg'\n \n \t# The external test will outputs its own plan\n \ttest_external_has_tap=1\ndiff --git a/contrib/credential/netrc/test.command-option-gpg b/contrib/credential/netrc/test.command-option-gpg\nnew file mode 100755\nindex 000000000..d8f1285d4\n--- /dev/null\n+++ b/contrib/credential/netrc/test.command-option-gpg\n@@ -0,0 +1,2 @@\n+#!/bin/sh\n+echo machine command-option-gpg login username password password\ndiff --git a/contrib/credential/netrc/test.git-config-gpg b/contrib/credential/netrc/test.git-config-gpg\nnew file mode 100755\nindex 000000000..65cf594c2\n--- /dev/null\n+++ b/contrib/credential/netrc/test.git-config-gpg\n@@ -0,0 +1,2 @@\n+#!/bin/sh\n+echo machine git-config-gpg login username password password\ndiff --git a/contrib/credential/netrc/test.netrc.gpg b/contrib/credential/netrc/test.netrc.gpg\nnew file mode 100644\nindex 000000000..e69de29bb\ndiff --git a/contrib/credential/netrc/test.pl b/contrib/credential/netrc/test.pl\nindex ea95a2c8a..1e1001030 100755\n--- a/contrib/credential/netrc/test.pl\n+++ b/contrib/credential/netrc/test.pl\n@@ -9,15 +9,18 @@ use File::Spec::Functions qw(:DEFAULT rel2abs);\n use IPC::Open2;\n \n BEGIN {\n-\t# t-git-credential-netrc.sh kicks off our testing, so we have to go from there.\n+\t# t-git-credential-netrc.sh kicks off our testing, so we have to go\n+\t# from there.\n \tTest::More->builder->current_test(1);\n \tTest::More->builder->no_ending(1);\n }\n \n my @global_credential_args = @ARGV;\n my $scriptDir = dirname rel2abs $0;\n-my $netrc = catfile $scriptDir, 'test.netrc';\n-my $gcNetrc = catfile $scriptDir, 'git-credential-netrc';\n+my ($netrc, $netrcGpg, $gcNetrc) = map { catfile $scriptDir, $_; }\n+                                       qw(test.netrc\n+                                          test.netrc.gpg\n+                                          git-credential-netrc);\n local $ENV{PATH} = join ':'\n                       , $scriptDir\n                       , $ENV{PATH}\n@@ -87,6 +90,19 @@ ok(scalar keys %$cred == 2, \"Got 2 'host:port kills host' keys\");\n is($cred->{password}, 'bobwillknow', \"Got correct 'host:port kills host' password\");\n is($cred->{username}, 'bob', \"Got correct 'host:port kills host' username\");\n \n+diag 'Testing netrc file decryption by git config gpg.program setting\\n';\n+$cred = run_credential( ['-f', $netrcGpg, 'get']\n+                      , { host => 'git-config-gpg' }\n+                      );\n+\n+ok(scalar keys %$cred == 2, 'Got keys decrypted by git config option');\n+\n+diag 'Testing netrc file decryption by gpg option\\n';\n+$cred = run_credential( ['-f', $netrcGpg, '-g', 'test.command-option-gpg', 'get']\n+                      , { host => 'command-option-gpg' }\n+                      );\n+\n+ok(scalar keys %$cred == 2, 'Got keys decrypted by command option');\n \n sub run_credential\n {\n-- \n2.17.0\n\n"},{"id":"347445","messageId":"20180512091728.4931-1-luis.marsano@gmail.com","threadId":"48447","inReplyTo":"20180509213634.5198-1-luis.marsano@gmail.com","subject":"[PATCH v2 0/2] Configurable GnuPG command for git-credential-netrc","fromName":"Luis Marsano","fromEmail":"luis.marsano@gmail.com","sentAt":"2018-05-12T09:17:26Z","receivedAt":"2018-05-12T09:26:28Z","isPatch":true,"sender":{"key":"luis.marsano@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8139324?v=4"},"body":"Updated per Junio's comments.\n- clarify commit messages\n- explain usage placeholder style as conformance with main coding style\n- drop Unicode dependence\n\nUnicode punctuation was initially included for semantics & accessibility, since assistive technology like screenreaders handle … better than ...\nHowever, character conversion between encodings is typically handled through Native Language Support such as gettext, which recommends untranslated strings in ASCII.\nTherefore, strings remain in ASCII to ease extensibility in that direction.\n\nThe following changes since commit ccdcbd54c4475c2238b310f7113ab3075b5abc9c:\n\n  The fifth batch for 2.18 (2018-05-08 15:59:49 +0900)\n\nare available in the Git repository at:\n\n  https://github.com/lmmarsano/git.git \n\nfor you to fetch changes up to 62a76a1eb7906199b731858ae2d193cfdd3176e0:\n\n  git-credential-netrc: accept gpg option (2018-05-12 03:27:45 -0400)\n\n----------------------------------------------------------------\nLuis Marsano (2):\n  git-credential-netrc: adapt to test framework for git\n  git-credential-netrc: accept gpg option\n\n contrib/credential/netrc/Makefile             |  4 +-\n contrib/credential/netrc/git-credential-netrc | 58 +++++++-----\n .../netrc/t-git-credential-netrc.sh           | 31 +++++++\n .../credential/netrc/test.command-option-gpg  |  2 +\n contrib/credential/netrc/test.git-config-gpg  |  2 +\n contrib/credential/netrc/test.netrc.gpg       |  0\n contrib/credential/netrc/test.pl              | 88 +++++++++++++------\n 7 files changed, 135 insertions(+), 50 deletions(-)\n create mode 100755 contrib/credential/netrc/t-git-credential-netrc.sh\n create mode 100755 contrib/credential/netrc/test.command-option-gpg\n create mode 100755 contrib/credential/netrc/test.git-config-gpg\n create mode 100644 contrib/credential/netrc/test.netrc.gpg\n\n-- \n2.17.0\n\n"},{"id":"347446","messageId":"20180512091728.4931-2-luis.marsano@gmail.com","threadId":"48447","inReplyTo":"20180512091728.4931-1-luis.marsano@gmail.com","subject":"[PATCH v2 1/2] git-credential-netrc: adapt to test framework for git","fromName":"Luis Marsano","fromEmail":"luis.marsano@gmail.com","sentAt":"2018-05-12T09:17:27Z","receivedAt":"2018-05-12T09:26:30Z","isPatch":true,"sender":{"key":"luis.marsano@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8139324?v=4"},"body":"git-credential-netrc tests did not run in a test repository.\nReuse the main test framework to stage a temporary repository.\nTo imitate Perl tests under t/\n- switch to Test::More module\n- use File::Basename & File::Spec::Functions\n\nSigned-off-by: Luis Marsano <luis.marsano@gmail.com>\nAcked-by: Ted Zlatanov <tzz@lifelogs.com>\n---\n contrib/credential/netrc/Makefile             |  4 +-\n .../netrc/t-git-credential-netrc.sh           | 31 ++++++++\n contrib/credential/netrc/test.pl              | 72 +++++++++++--------\n 3 files changed, 77 insertions(+), 30 deletions(-)\n create mode 100755 contrib/credential/netrc/t-git-credential-netrc.sh\n\ndiff --git a/contrib/credential/netrc/Makefile b/contrib/credential/netrc/Makefile\nindex 51b76138a..0ffa40719 100644\n--- a/contrib/credential/netrc/Makefile\n+++ b/contrib/credential/netrc/Makefile\n@@ -1,5 +1,5 @@\n test:\n-\t./test.pl\n+\t./t-git-credential-netrc.sh\n \n testverbose:\n-\t./test.pl -d -v\n+\t./t-git-credential-netrc.sh -d -v\ndiff --git a/contrib/credential/netrc/t-git-credential-netrc.sh b/contrib/credential/netrc/t-git-credential-netrc.sh\nnew file mode 100755\nindex 000000000..efb81efed\n--- /dev/null\n+++ b/contrib/credential/netrc/t-git-credential-netrc.sh\n@@ -0,0 +1,31 @@\n+#!/bin/sh\n+(\n+\tcd ../../../t\n+\ttest_description='git-credential-netrc'\n+\t. ./test-lib.sh\n+\n+\tif ! test_have_prereq PERL; then\n+\t\tskip_all='skipping perl interface tests, perl not available'\n+\t\ttest_done\n+\tfi\n+\n+\tperl -MTest::More -e 0 2>/dev/null || {\n+\t\tskip_all=\"Perl Test::More unavailable, skipping test\"\n+\t\ttest_done\n+\t}\n+\n+\t# set up test repository\n+\n+\ttest_expect_success \\\n+    'set up test repository' \\\n+    :\n+\n+\t# The external test will outputs its own plan\n+\ttest_external_has_tap=1\n+\n+\ttest_external \\\n+    'git-credential-netrc' \\\n+    perl \"$TEST_DIRECTORY\"/../contrib/credential/netrc/test.pl\n+\n+\ttest_done\n+)\ndiff --git a/contrib/credential/netrc/test.pl b/contrib/credential/netrc/test.pl\nindex 169b6463c..ea95a2c8a 100755\n--- a/contrib/credential/netrc/test.pl\n+++ b/contrib/credential/netrc/test.pl\n@@ -1,83 +1,99 @@\n #!/usr/bin/perl\n+use lib (split(/:/, $ENV{GITPERLLIB}));\n \n use warnings;\n use strict;\n-use Test;\n+use Test::More qw(no_plan);\n+use File::Basename;\n+use File::Spec::Functions qw(:DEFAULT rel2abs);\n use IPC::Open2;\n \n-BEGIN { plan tests => 15 }\n+BEGIN {\n+\t# t-git-credential-netrc.sh kicks off our testing, so we have to go from there.\n+\tTest::More->builder->current_test(1);\n+\tTest::More->builder->no_ending(1);\n+}\n \n my @global_credential_args = @ARGV;\n-my $netrc = './test.netrc';\n-print \"# Testing insecure file, nothing should be found\\n\";\n+my $scriptDir = dirname rel2abs $0;\n+my $netrc = catfile $scriptDir, 'test.netrc';\n+my $gcNetrc = catfile $scriptDir, 'git-credential-netrc';\n+local $ENV{PATH} = join ':'\n+                      , $scriptDir\n+                      , $ENV{PATH}\n+                      ? $ENV{PATH}\n+                      : ();\n+\n+diag \"Testing insecure file, nothing should be found\\n\";\n chmod 0644, $netrc;\n my $cred = run_credential(['-f', $netrc, 'get'],\n \t\t\t  { host => 'github.com' });\n \n-ok(scalar keys %$cred, 0, \"Got 0 keys from insecure file\");\n+ok(scalar keys %$cred == 0, \"Got 0 keys from insecure file\");\n \n-print \"# Testing missing file, nothing should be found\\n\";\n+diag \"Testing missing file, nothing should be found\\n\";\n chmod 0644, $netrc;\n $cred = run_credential(['-f', '///nosuchfile///', 'get'],\n \t\t       { host => 'github.com' });\n \n-ok(scalar keys %$cred, 0, \"Got 0 keys from missing file\");\n+ok(scalar keys %$cred == 0, \"Got 0 keys from missing file\");\n \n chmod 0600, $netrc;\n \n-print \"# Testing with invalid data\\n\";\n+diag \"Testing with invalid data\\n\";\n $cred = run_credential(['-f', $netrc, 'get'],\n \t\t       \"bad data\");\n-ok(scalar keys %$cred, 4, \"Got first found keys with bad data\");\n+ok(scalar keys %$cred == 4, \"Got first found keys with bad data\");\n \n-print \"# Testing netrc file for a missing corovamilkbar entry\\n\";\n+diag \"Testing netrc file for a missing corovamilkbar entry\\n\";\n $cred = run_credential(['-f', $netrc, 'get'],\n \t\t       { host => 'corovamilkbar' });\n \n-ok(scalar keys %$cred, 0, \"Got no corovamilkbar keys\");\n+ok(scalar keys %$cred == 0, \"Got no corovamilkbar keys\");\n \n-print \"# Testing netrc file for a github.com entry\\n\";\n+diag \"Testing netrc file for a github.com entry\\n\";\n $cred = run_credential(['-f', $netrc, 'get'],\n \t\t       { host => 'github.com' });\n \n-ok(scalar keys %$cred, 2, \"Got 2 Github keys\");\n+ok(scalar keys %$cred == 2, \"Got 2 Github keys\");\n \n-ok($cred->{password}, 'carolknows', \"Got correct Github password\");\n-ok($cred->{username}, 'carol', \"Got correct Github username\");\n+is($cred->{password}, 'carolknows', \"Got correct Github password\");\n+is($cred->{username}, 'carol', \"Got correct Github username\");\n \n-print \"# Testing netrc file for a username-specific entry\\n\";\n+diag \"Testing netrc file for a username-specific entry\\n\";\n $cred = run_credential(['-f', $netrc, 'get'],\n \t\t       { host => 'imap', username => 'bob' });\n \n-ok(scalar keys %$cred, 2, \"Got 2 username-specific keys\");\n+ok(scalar keys %$cred == 2, \"Got 2 username-specific keys\");\n \n-ok($cred->{password}, 'bobwillknow', \"Got correct user-specific password\");\n-ok($cred->{protocol}, 'imaps', \"Got correct user-specific protocol\");\n+is($cred->{password}, 'bobwillknow', \"Got correct user-specific password\");\n+is($cred->{protocol}, 'imaps', \"Got correct user-specific protocol\");\n \n-print \"# Testing netrc file for a host:port-specific entry\\n\";\n+diag \"Testing netrc file for a host:port-specific entry\\n\";\n $cred = run_credential(['-f', $netrc, 'get'],\n \t\t       { host => 'imap2:1099' });\n \n-ok(scalar keys %$cred, 2, \"Got 2 host:port-specific keys\");\n+ok(scalar keys %$cred == 2, \"Got 2 host:port-specific keys\");\n \n-ok($cred->{password}, 'tzzknow', \"Got correct host:port-specific password\");\n-ok($cred->{username}, 'tzz', \"Got correct host:port-specific username\");\n+is($cred->{password}, 'tzzknow', \"Got correct host:port-specific password\");\n+is($cred->{username}, 'tzz', \"Got correct host:port-specific username\");\n \n-print \"# Testing netrc file that 'host:port kills host' entry\\n\";\n+diag \"Testing netrc file that 'host:port kills host' entry\\n\";\n $cred = run_credential(['-f', $netrc, 'get'],\n \t\t       { host => 'imap2' });\n \n-ok(scalar keys %$cred, 2, \"Got 2 'host:port kills host' keys\");\n+ok(scalar keys %$cred == 2, \"Got 2 'host:port kills host' keys\");\n+\n+is($cred->{password}, 'bobwillknow', \"Got correct 'host:port kills host' password\");\n+is($cred->{username}, 'bob', \"Got correct 'host:port kills host' username\");\n \n-ok($cred->{password}, 'bobwillknow', \"Got correct 'host:port kills host' password\");\n-ok($cred->{username}, 'bob', \"Got correct 'host:port kills host' username\");\n \n sub run_credential\n {\n \tmy $args = shift @_;\n \tmy $data = shift @_;\n \tmy $pid = open2(my $chld_out, my $chld_in,\n-\t\t\t'./git-credential-netrc', @global_credential_args,\n+\t\t\t$gcNetrc, @global_credential_args,\n \t\t\t@$args);\n \n \tdie \"Couldn't open pipe to netrc credential helper: $!\" unless $pid;\n-- \n2.17.0\n\n"},{"id":"347575","messageId":"20180514054601.5805@lmm-notebook.localdomain","threadId":"48447","inReplyTo":"xmqq7eobkfrc.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH 1/2] git-credential-netrc: adapt to test framework for git","fromName":"Luis Marsano","fromEmail":"luis.marsano@gmail.com","sentAt":"2018-05-14T09:46:01Z","receivedAt":"2018-05-14T09:46:10Z","isPatch":true,"sender":{"key":"luis.marsano@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8139324?v=4"},"body":"Junio C Hamano <gitster@pobox.com> wrote:\n\n> Luis Marsano <luis.marsano@gmail.com> writes:\n> \n> > until this change, git-credential-netrc did not test in a repository\n> > this change reuses the main test framework, which provides such tests\n> > specific changes\n> \n> Sorry, but I cannot quite parse what the above is trying to say.\n> \n[⋮]\n> \n> Will queue, but may need to make the log message\n> readable/understandable.\n> \n> Thanks.\n\nThank you, the rewrite https://public-inbox.org/git/20180512091728.4931-2-luis.marsano@gmail.com/ should be more intelligible.\nI welcome further criticisms if any.\n"},{"id":"347578","messageId":"20180514062024.5819@lmm-notebook.localdomain","threadId":"48447","inReplyTo":"xmqq36yzkf3v.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH 2/2] git-credential-netrc: accept gpg option","fromName":"Luis Marsano","fromEmail":"luis.marsano@gmail.com","sentAt":"2018-05-14T10:20:24Z","receivedAt":"2018-05-14T10:20:31Z","isPatch":true,"sender":{"key":"luis.marsano@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8139324?v=4"},"body":"Junio C Hamano <gitster@pobox.com> wrote:\n\n> Luis Marsano <luis.marsano@gmail.com> writes:\n> \n> > git-credential-netrc was hardcoded to decrypt with 'gpg' regardless of the gpg.program option\n> > this now uses the gpg command option if set, else, the gpg.program option set in the git repository or global configuration, else defaults to 'gpg'\n> > for git-credential-netrc\n> \n> These lines are way overlong.  Wrap at around 72-78 cols, perhaps.\n> Complete each sentence with a full-stop.\n\nThanks, corrected this in the updated patch https://public-inbox.org/git/20180512091728.4931-3-luis.marsano@gmail.com/.\n\n> > - use Git.pm for repository and global option queries\n> > - add -g|--gpg command option & document it in command usage\n> > - test repository & command options\n> > - support unicode\n> \n> There are other changes that are not explained/justified here, I\n> think.\n> \n>  - Instead of ALLCAPS as a placeholder for a command line argument in\n>    the help text, use <placeholder>, because doing so is better due\n>    to such and such reasons.\n> \n> I think it is good to consistently do so, but it is unclear why\n> ALLCAPS is bad and <placeholder> is better.  That needs to be\n> explained.\n\nNot necessarily bad, but the reason was to conform with Documentation/CodingGuidelines.\nThe updated commit message now explains this.\n\n>  - Replace three-dots in the help text with U+2026 to punish those\n>    who are still using unicode-inapable terminal in this century.\n> \n> I do not think this part of the patch is a good idea at all, but\n> perhaps I misunderstood the reason behind this change you had in\n> mind (as you did not explain it in the proposed log message).\n\nThe original intent for this was semantics & accessibility: screenreaders more reliably interpret … than ... as ellipsis, and I imagine other assistive technology would, too.\nHowever, after research, I've learned there are better supported ways to go about it, so I'm retracting that change.\n\nThe updated patch https://public-inbox.org/git/20180512091728.4931-3-luis.marsano@gmail.com/ should reflect all corrections.\nThank you for the feedback, and please let me know of further issues.\n"}]}