summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-11-02 21:17:39 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-11-02 21:17:39 (GMT)
commite0f6ad2984918e316df9bd5bf6b90fe6e885beee (patch)
tree579b486456d65789321f32f99be0d1be8e14c7f6
parentb6fb70c985a6fc113e971a6696f328abf8315dce (diff)
parent567ad2c0f90fe63d1fde2c0269be8df17675148c (diff)
downloadgit-e0f6ad2984918e316df9bd5bf6b90fe6e885beee.zip
git-e0f6ad2984918e316df9bd5bf6b90fe6e885beee.tar.gz
git-e0f6ad2984918e316df9bd5bf6b90fe6e885beee.tar.bz2
Merge branch 'tk/credential-config'
"git credential' didn't honor the core.askPass configuration variable (among other things), which has been corrected. * tk/credential-config: credential: load default config
-rw-r--r--builtin/credential.c3
-rwxr-xr-xt/t0300-credentials.sh26
2 files changed, 29 insertions, 0 deletions
diff --git a/builtin/credential.c b/builtin/credential.c
index 879acfb..d75dcdc 100644
--- a/builtin/credential.c
+++ b/builtin/credential.c
@@ -1,6 +1,7 @@
#include "git-compat-util.h"
#include "credential.h"
#include "builtin.h"
+#include "config.h"
static const char usage_msg[] =
"git credential [fill|approve|reject]";
@@ -10,6 +11,8 @@ int cmd_credential(int argc, const char **argv, const char *prefix)
const char *op;
struct credential c = CREDENTIAL_INIT;
+ git_config(git_default_config, NULL);
+
if (argc != 2 || !strcmp(argv[1], "-h"))
usage(usage_msg);
op = argv[1];
diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh
index bc2d740..a18f8a4 100755
--- a/t/t0300-credentials.sh
+++ b/t/t0300-credentials.sh
@@ -265,6 +265,32 @@ test_expect_success 'internal getpass does not ask for known username' '
EOF
'
+test_expect_success 'git-credential respects core.askPass' '
+ write_script alternate-askpass <<-\EOF &&
+ echo >&2 "alternate askpass invoked"
+ echo alternate-value
+ EOF
+ test_config core.askpass "$PWD/alternate-askpass" &&
+ (
+ # unset GIT_ASKPASS set by lib-credential.sh which would
+ # override our config, but do so in a subshell so that we do
+ # not interfere with other tests
+ sane_unset GIT_ASKPASS &&
+ check fill <<-\EOF
+ protocol=http
+ host=example.com
+ --
+ protocol=http
+ host=example.com
+ username=alternate-value
+ password=alternate-value
+ --
+ alternate askpass invoked
+ alternate askpass invoked
+ EOF
+ )
+'
+
HELPER="!f() {
cat >/dev/null
echo username=foo