From patchwork Mon Dec 16 21:32:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11295323 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CED98109A for ; Mon, 16 Dec 2019 21:32:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ABA6224676 for ; Mon, 16 Dec 2019 21:32:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hA4LiBTN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727523AbfLPVb7 (ORCPT ); Mon, 16 Dec 2019 16:31:59 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:46110 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727119AbfLPVb6 (ORCPT ); Mon, 16 Dec 2019 16:31:58 -0500 Received: by mail-pj1-f65.google.com with SMTP id z21so3565673pjq.13 for ; Mon, 16 Dec 2019 13:31:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jyrqU080wLyAttD8V6qJSDhw6F6mFHPu94fY43EnDAY=; b=hA4LiBTNL9ic4iYPruYF7ufXp13QNuq7UMbIjJ6DGIi9DAKRuHlliRwdEsc3mi+jhM ErOSzTqA5TF210Zoc3lBqe7grVwiInLJMbM7ii9RWdPDeJOviZZcMxb+r7S9RvE7osno v5MLxWYKFXrg33D4odb0GnKL3Q1PpweKEiRd6ESumPPhNUY/NbE9tpj6FPGG771oOwxz +8fpTE+9Lym0DmiziXSUkodSkg6iprENGiIZ8nI7s14T2PDOBGQiiJxb7wQp72oRbXhg k1MQiUNCBTmYinxmrfrlxkF6Ytw6IMqs5XmIWgNiXY3xxu9Umgbgxl/8hHpRkqRHkgIt IbnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jyrqU080wLyAttD8V6qJSDhw6F6mFHPu94fY43EnDAY=; b=WQPVaQa5dI3hqy47J7DfmRGAeQ7PWTPYhuH2mI4t47o/mF3VytZ8rnhWv+yo7adBCq l3Sb5QyGRYVisdQhibynmJ8mMyFTvgW2WQmMsS/tOyDQ2TXYNrMe/atN2MXGSq0eM1VA ii9V1qBXsyfHG30nkCXaC4gzmii7dT70oXOUTwjV5xAzKPTxQZOtdbqbdTm9DZce3vHa NA8ZcCPoHXr9qO5b7Sca5Xt1xleL1TGkxmELnnpJ3ntPdYh2ehCrniOIw3MRNXkKqN/x 2vDWK2CEaV+/MpfOZY0ppnnREy4CM1LFOl6kmDZ5qXVW6bEU5JAnL73OY/Sd9KpadwTI g/9Q== X-Gm-Message-State: APjAAAUDPMynAX9dfVV99ci0oyscQJCxYehlCw+aXxWYt0NmjQZwbr7C ZX/IRk1Ws8qEDfWjVw20e3uGo+y8 X-Google-Smtp-Source: APXvYqwtZWCzrGLL6PVxIJXECuUpl3b/+josga0bI1UHj5zeS/smXMlC2edBdiPt74OkI32/qbYX2g== X-Received: by 2002:a17:90a:b38f:: with SMTP id e15mr1680877pjr.101.1576531917700; Mon, 16 Dec 2019 13:31:57 -0800 (PST) Received: from dentonliu-ltm.internal.salesforce.com ([204.14.239.53]) by smtp.gmail.com with ESMTPSA id q6sm23951063pfl.140.2019.12.16.13.31.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Dec 2019 13:31:56 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Luis Marsano , Ted Zlatanov Subject: [PATCH 1/2] contrib/credential/netrc: make PERL_PATH configurable Date: Mon, 16 Dec 2019 13:32:33 -0800 Message-Id: X-Mailer: git-send-email 2.24.1.664.g198078bb5a In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The shebang path for the Perl interpreter in git-credential-netrc was hardcoded. However, some users may have it located at a different location and thus, would have had to manually edit the script. Add a .perl prefix to the script to denote it as a template and ignore the generated version. Augment the Makefile so that it generates git-credential-netrc from git-credential-netrc.perl, just like other Perl scripts. The Makefile recipes were shamelessly stolen from contrib/mw-to-git/Makefile. Signed-off-by: Denton Liu --- contrib/credential/netrc/.gitignore | 1 + contrib/credential/netrc/Makefile | 26 +++++++++++++++++-- ...ential-netrc => git-credential-netrc.perl} | 0 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 contrib/credential/netrc/.gitignore rename contrib/credential/netrc/{git-credential-netrc => git-credential-netrc.perl} (100%) diff --git a/contrib/credential/netrc/.gitignore b/contrib/credential/netrc/.gitignore new file mode 100644 index 0000000000..d41cdde84b --- /dev/null +++ b/contrib/credential/netrc/.gitignore @@ -0,0 +1 @@ +git-credential-netrc diff --git a/contrib/credential/netrc/Makefile b/contrib/credential/netrc/Makefile index 6174e3bb83..c284fb8ac4 100644 --- a/contrib/credential/netrc/Makefile +++ b/contrib/credential/netrc/Makefile @@ -1,8 +1,30 @@ # The default target of this Makefile is... all:: -test: +SCRIPT_PERL = git-credential-netrc.perl +GIT_ROOT_DIR = ../../.. +HERE = contrib/credential/netrc + +SCRIPT_PERL_FULL = $(patsubst %,$(HERE)/%,$(SCRIPT_PERL)) + +all:: build + +build: + $(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL="$(SCRIPT_PERL_FULL)" \ + build-perl-script + +install: build + $(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL="$(SCRIPT_PERL_FULL)" \ + install-perl-script + +clean: + $(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL="$(SCRIPT_PERL_FULL)" \ + clean-perl-script + +test: build ./t-git-credential-netrc.sh -testverbose: +testverbose: build ./t-git-credential-netrc.sh -d -v + +.PHONY: all build install clean test testverbose diff --git a/contrib/credential/netrc/git-credential-netrc b/contrib/credential/netrc/git-credential-netrc.perl similarity index 100% rename from contrib/credential/netrc/git-credential-netrc rename to contrib/credential/netrc/git-credential-netrc.perl From patchwork Mon Dec 16 21:32:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11295321 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9F617109A for ; Mon, 16 Dec 2019 21:32:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7D1EE24676 for ; Mon, 16 Dec 2019 21:32:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="H8Luv0/n" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727529AbfLPVb7 (ORCPT ); Mon, 16 Dec 2019 16:31:59 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:41797 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727500AbfLPVb7 (ORCPT ); Mon, 16 Dec 2019 16:31:59 -0500 Received: by mail-pf1-f193.google.com with SMTP id s18so6326004pfd.8 for ; Mon, 16 Dec 2019 13:31:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+EzFVKu3ifOlxGO3XRQxj82Z7+1W5sSE+/ss0IGOQds=; b=H8Luv0/nHv2zfa5JGZkY/9RWkbFNwunYi9h9p+IJb5IF1/d745VXidSSrO8yvXecYE fTWq8ovjJ2HtVapawCeb/hp0mFySSVvFLumnShOfsdWdPI7QI0cralgAo7IDjPw3DxWv O8YNk8qz3Xfy3E09RcpyFHWDc2jN/fB846coIdFsDJJsGPjKXwyJxFhKWQbmvUXOb4w6 2+agtSCZ8wKBRXJEHUXq0xv3IyesjnDBHCnOYIYMsAOSkQ5o0XvqEb+8v5+0cul4hoQe TLzBPVrMtrB7nGhZb4SXaGWReE4Y3fxf0qr0YQ18LwwjHO28w5cTX7p4H7FXaQ52imLd i6fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+EzFVKu3ifOlxGO3XRQxj82Z7+1W5sSE+/ss0IGOQds=; b=s6znXrJrScCDzAsjIXivLwgad8B0rJXrjLatkbe7DHRsCjxsYAz57sUzkePv9Vekym WNy0nKmK7q4P9iA9hhkiBJRXiwrCnHbivR5mFAtK9vS0x/3pTgId4La6uAHFuNYhck9c 4IsR40uRV6sH7q6vohPEgN1K+WwDcppU+tZ2bUDLLkUWy30CR4X5AGNYuDzScVyBY9MI y+4WVXzkKaPABG3ZNTpAV0sROclYsuLKoc6s9Fg9I7aMHnQcre4slhWtHY2CsPRzElKg gdYABiKTp2aA0VB44ZSztMGbvps5NaoMOaXXUBlrULXrWK4JJ8C/VnuXLicn7Lyw1Jtb keRQ== X-Gm-Message-State: APjAAAWncODv9tctbwparGjVjlpVyhca7zSCnhbT4FPr++ILQzt1SsOk +u1nVTdo2FDCvCyBezOe9l8JhGZw X-Google-Smtp-Source: APXvYqwYOlTiuYWrkNFEV/s3wWyYtGwxoYkDjk0RJx6Iv+4VICUUP5li9YNqnqKl+5rZwqmnA1jYuA== X-Received: by 2002:a62:8249:: with SMTP id w70mr17691759pfd.253.1576531918550; Mon, 16 Dec 2019 13:31:58 -0800 (PST) Received: from dentonliu-ltm.internal.salesforce.com ([204.14.239.53]) by smtp.gmail.com with ESMTPSA id q6sm23951063pfl.140.2019.12.16.13.31.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Dec 2019 13:31:58 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Luis Marsano , Ted Zlatanov Subject: [PATCH 2/2] contrib/credential/netrc: work outside a repo Date: Mon, 16 Dec 2019 13:32:34 -0800 Message-Id: X-Mailer: git-send-email 2.24.1.664.g198078bb5a In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Currently, git-credential-netrc does not work outside of a git repository. It fails with the following error: fatal: Not a git repository: . at /usr/share/perl5/Git.pm line 214. There is no real reason why need to be within a repository, though. Credential helpers should be able to work just fine outside the repository as well. Call the non-self version of config() so that git-credential-netrc no longer needs to be run within a repository. Signed-off-by: Denton Liu --- contrib/credential/netrc/git-credential-netrc.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/credential/netrc/git-credential-netrc.perl b/contrib/credential/netrc/git-credential-netrc.perl index ebfc123ec6..bc57cc6588 100755 --- a/contrib/credential/netrc/git-credential-netrc.perl +++ b/contrib/credential/netrc/git-credential-netrc.perl @@ -423,7 +423,7 @@ sub load_config { # load settings from git config my $options = shift; # set from command argument, gpg.program option, or default to gpg - $options->{'gpg'} //= Git->repository()->config('gpg.program') + $options->{'gpg'} //= Git::config('gpg.program') // 'gpg'; log_verbose("using $options{'gpg'} for GPG operations"); }