contrib/credential/netrc: Makefile + script cleanup
cover contrib/credential/netrc: Makefile + script cleanup
I recently switched my workflow to use this credential helper and I noticed a couple of problems:
1. The interpreter path was hardcoded to #!/usr/bin/perl
2. The script refuses to run outside of a Git repository
This patch series should fix these problems.
Denton Liu (2):
contrib/credential/netrc: make PERL_PATH configurable contrib/credential/netrc: work outside a repo
contrib/credential/netrc/.gitignore | 1 +
contrib/credential/netrc/Makefile | 26 +++++++++++++++++--
...ential-netrc => git-credential-netrc.perl} | 2 +-
3 files changed, 26 insertions(+), 3 deletions(-)
create mode 100644 contrib/credential/netrc/.gitignore
rename contrib/credential/netrc/{git-credential-netrc => git-credential-netrc.perl} (99%)Signature · 1 line
2.24.1.664.g198078bb5a
PATCH 2/2 contrib/credential/netrc: work outside a repo
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.
--- contrib/credential/netrc/git-credential-netrc.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/credential/netrc/git-credential-netrc.perl +1 -1
@@ -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"); }
Signature · 1 line
2.24.1.664.g198078bb5a
PATCH 1/2 contrib/credential/netrc: make PERL_PATH configurable
In reply to Denton LiuThe 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.
---
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%)contrib/credential/netrc/.gitignore new file +1 -0
@@ -0,0 +1 @@ +git-credential-netrc
contrib/credential/netrc/Makefile +24 -2
@@ -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
contrib/credential/netrc/git-credential-netrc.perl renamed from contrib/credential/netrc/git-credential-netrc +0 -0
Signature · 1 line
2.24.1.664.g198078bb5a
Quoted 8 lines · Denton Liu
I recently switched my workflow to use this credential helper and I noticed a couple of problems:
1. The interpreter path was hardcoded to #!/usr/bin/perl
2. The script refuses to run outside of a Git repository
This patch series should fix these problems.
Both of these patches look good to me.
It does make me wonder if many people are using credential-netrc, given these pretty obvious problems. You're certainly welcome to use it if it works for you, but I am curious what made you pick it versus one of the other more advanced helpers.
I assume you're using a gpg-encrypted netrc (if not, you should probably just use credential-store). For "read-only" password access, I find the combination of pass[1] with config like this is a bit nicer:
[credential "https://github.com"] username = peff helper = "!f() { test $1 = get && echo password=`pass github/oauth`; }; f"
-Peff
Hi Peff,
Quoted 5 lines · Jeff King
Quoted 3 lines · Denton Liu
I recently switched my workflow to use this credential helper and I noticed a couple of problems:
Quoted 7 lines
Quoted 5 lines
1. The interpreter path was hardcoded to #!/usr/bin/perl
2. The script refuses to run outside of a Git repository
This patch series should fix these problems.
Both of these patches look good to me.
Thanks for reviewing :)
Quoted 5 lines
It does make me wonder if many people are using credential-netrc, given these pretty obvious problems. You're certainly welcome to use it if it works for you, but I am curious what made you pick it versus one of the other more advanced helpers.
I wanted a credential helper that was encrypted and OS-independent. Since GPG is basically available on everything, it fits my use case.
It also helped that it resulted in a workflow that was very similar to my old mutt workflow. Before, I had
source "gpg -dq ~/.mutt/credentials.gpg |"
and I just replaced the gpg with a script that wraps around git-credential.
Quoted 4 lines
I assume you're using a gpg-encrypted netrc (if not, you should probably just use credential-store). For "read-only" password access, I find the combination of pass[1] with config like this is a bit nicer:
Nice, I never knew heard about pass until now. I only have one password in my credential store currently but if I need to add more, I'll keep this in mind!
-Denton
Quoted 8 lines
[credential "https://github.com"] username = peff helper = "!f() { test $1 = get && echo password=`pass github/oauth`; }; f"-Peff
cover contrib/credential/netrc: Makefile + script cleanup
In reply to Denton LiuI recently switched my workflow to use this credential helper and I noticed a couple of problems:
1. The interpreter path was hardcoded to #!/usr/bin/perl
2. The script refuses to run outside of a Git repository
This patch series should fix these problems.
Denton Liu (2):
contrib/credential/netrc: make PERL_PATH configurable contrib/credential/netrc: work outside a repo
contrib/credential/netrc/.gitignore | 1 +
contrib/credential/netrc/Makefile | 26 +++++++++++++++++--
...ential-netrc => git-credential-netrc.perl} | 2 +-
3 files changed, 26 insertions(+), 3 deletions(-)
create mode 100644 contrib/credential/netrc/.gitignore
rename contrib/credential/netrc/{git-credential-netrc => git-credential-netrc.perl} (99%)Signature · 1 line
2.24.1.703.g2f499f1283
PATCH RESEND 1/2 contrib/credential/netrc: make PERL_PATH configurable
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.
---
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%)contrib/credential/netrc/.gitignore new file +1 -0
@@ -0,0 +1 @@ +git-credential-netrc
contrib/credential/netrc/Makefile +24 -2
@@ -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
contrib/credential/netrc/git-credential-netrc.perl renamed from contrib/credential/netrc/git-credential-netrc +0 -0
Signature · 1 line
2.24.1.703.g2f499f1283
PATCH RESEND 2/2 contrib/credential/netrc: work outside a repo
In reply to Denton LiuCurrently, 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.
--- contrib/credential/netrc/git-credential-netrc.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/credential/netrc/git-credential-netrc.perl +1 -1
@@ -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"); }
Signature · 1 line
2.24.1.703.g2f499f1283
Quoted 8 lines · Denton Liu
I recently switched my workflow to use this credential helper and I noticed a couple of problems:
1. The interpreter path was hardcoded to #!/usr/bin/perl
2. The script refuses to run outside of a Git repository
This patch series should fix these problems.
Since this is just a re-send, I'll re-send my:
:)
-Peff