git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] contrib/credential/netrc: work outside a repo

From
Denton Liu <liu.denton@gmail.com>
Date
Dec 16, 2019, 21:32 UTC
Message-ID
<d22eb1f9e2431199f1b6bea2aefe8473284e966e.1576531851.git.liu.denton@gmail.com>
In-Reply-To
<cover.1576531851.git.liu.denton@gmail.com>

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 <liu.denton@gmail.com>
---
 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");
 }
-- 
2.24.1.664.g198078bb5a
Previous: Denton LiuNext: Denton Liu
Message 2 of 9 in “contrib/credential/netrc: Makefile + script cleanup”
  1. 0/2 contrib/credential/netrc: Makefile + script cleanupDenton Liu, Dec 16, 2019
  2. 2/2 contrib/credential/netrc: work outside a repoDenton Liu, Dec 16, 2019
  3. 1/2 contrib/credential/netrc: make PERL_PATH configurableDenton Liu, Dec 16, 2019
  4. Jeff KingDec 17, 2019
  5. Denton LiuDec 17, 2019
  6. 0/2 contrib/credential/netrc: Makefile + script cleanupDenton Liu, Dec 20, 2019
  7. 1/2 contrib/credential/netrc: make PERL_PATH configurableDenton Liu, Dec 20, 2019
  8. 2/2 contrib/credential/netrc: work outside a repoDenton Liu, Dec 20, 2019
  9. Jeff KingDec 20, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.