git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Luis Marsano" <luis.marsano@gmail.com>,
	"Ted Zlatanov" <tzz@lifelogs.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH] git-credential-netrc: remove use of "autodie"
Date: Wed, 13 Jun 2018 07:48:10 +0000	[thread overview]
Message-ID: <20180613074810.5358-1-avarab@gmail.com> (raw)
In-Reply-To: <CAHqJXRE8OKSKcck1APHAHccLZhox+tZi8nNu2RA74RErX8s3Pg@mail.gmail.com>

The "autodie" module was added in Perl 5.10.1, but our INSTALL
document says "version 5.8 or later is needed".

As discussed in <87efhfvxzu.fsf@evledraar.gmail.com> this script is in
contrib/, so we might not want to apply that policy, however in this
case "autodie" was recently added as a "gratuitous safeguard" in
786ef50a23 ("git-credential-netrc: accept gpg option",
2018-05-12) (see
<CAHqJXRE8OKSKcck1APHAHccLZhox+tZi8nNu2RA74RErX8s3Pg@mail.gmail.com>).

Looking at it more carefully the addition of "autodie" inadvertently
introduced a logic error, since having it is equivalent to this patch:

    @@ -245,10 +244,10 @@ sub load_netrc {
     	if ($gpgmode) {
     		my @cmd = ($options{'gpg'}, qw(--decrypt), $file);
     		log_verbose("Using GPG to open $file: [@cmd]");
    -		open $io, "-|", @cmd;
    +		open $io, "-|", @cmd or die "@cmd: $!";
     	} else {
     		log_verbose("Opening $file...");
    -		open $io, '<', $file;
    +		open $io, '<', $file or die "$file: $!$!;
     	}

     	# nothing to do if the open failed (we log the error later)

As shown in the context the intent of that code is not do die but to
log the error later.

Per my reading of the file this was the only thing autodie was doing
in this file (there was no other code it altered). So let's remove it,
both to fix the logic error and to get rid of the dependency.

1. <87efhfvxzu.fsf@evledraar.gmail.com>
   (https://public-inbox.org/git/87efhfvxzu.fsf@evledraar.gmail.com/)
2. <CAHqJXRE8OKSKcck1APHAHccLZhox+tZi8nNu2RA74RErX8s3Pg@mail.gmail.com>
   (https://public-inbox.org/git/CAHqJXRE8OKSKcck1APHAHccLZhox+tZi8nNu2RA74RErX8s3Pg@mail.gmail.com/)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 contrib/credential/netrc/git-credential-netrc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/contrib/credential/netrc/git-credential-netrc b/contrib/credential/netrc/git-credential-netrc
index 0b9a94102e..ebfc123ec6 100755
--- a/contrib/credential/netrc/git-credential-netrc
+++ b/contrib/credential/netrc/git-credential-netrc
@@ -2,7 +2,6 @@
 
 use strict;
 use warnings;
-use autodie;
 
 use Getopt::Long;
 use File::Basename;
-- 
2.17.0.290.gded63e768a


  reply	other threads:[~2018-06-13  7:48 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-07  5:19 [RFC PATCH 0/2] contrib/credential/netrc Makefile & test improvements Todd Zullinger
2018-06-07  5:19 ` [RFC PATCH 1/2] git-credential-netrc: make "all" default target of Makefile Todd Zullinger
2018-06-07  5:19 ` [RFC PATCH 2/2] git-credential-netrc: use in-tree Git.pm for tests Todd Zullinger
2018-06-09 21:18 ` [RFC PATCH 0/2] contrib/credential/netrc Makefile & test improvements Luis Marsano
2018-06-10  2:28   ` Todd Zullinger
2018-06-10  8:36     ` Ævar Arnfjörð Bjarmason
2018-06-13  3:08       ` Todd Zullinger
2018-06-13  6:15         ` Luis Marsano
2018-06-13  7:48           ` Ævar Arnfjörð Bjarmason [this message]
2018-06-13 16:48             ` [PATCH] git-credential-netrc: remove use of "autodie" Junio C Hamano
2018-06-13 17:26               ` Todd Zullinger
2018-06-13  3:10 ` [RFC PATCH v2 0/4] contrib/credential/netrc Makefile & test improvements Todd Zullinger
2018-06-13  6:59   ` Luis Marsano
2018-06-13  3:10 ` [RFC PATCH v2 1/4] git-credential-netrc: make "all" default target of Makefile Todd Zullinger
2018-06-13  3:10 ` [RFC PATCH v2 2/4] git-credential-netrc: minor whitespace cleanup in test script Todd Zullinger
2018-06-13  5:42   ` Eric Sunshine
2018-06-13 17:21     ` Todd Zullinger
2018-06-13 17:43       ` Eric Sunshine
2018-06-13  3:10 ` [RFC PATCH v2 3/4] git-credential-netrc: use in-tree Git.pm for tests Todd Zullinger
2018-06-13  3:10 ` [RFC PATCH v2 4/4] git-credential-netrc: fix exit status when tests fail Todd Zullinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180613074810.5358-1-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=luis.marsano@gmail.com \
    --cc=tzz@lifelogs.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).