]> git.ipfire.org Git - thirdparty/git.git/commitdiff
credential: load default config
authorThomas Koutcher <thomas.koutcher@online.fr>
Thu, 15 Oct 2020 21:59:20 +0000 (21:59 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 16 Oct 2020 19:30:45 +0000 (12:30 -0700)
Make `git credential fill` honour the core.askPass variable.

Signed-off-by: Thomas Koutcher <thomas.koutcher@online.fr>
[jk: added test]
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/credential.c
t/t0300-credentials.sh

index 879acfbcda75141d3022e9b285e191977a06ba3d..d75dcdc64aa3c3da303b117ba505ba683c1afcde 100644 (file)
@@ -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];
index bc2d74098f035cde80de8282736188c6f6db3066..a18f8a473bfc667023c433a6c55c05defcc2e9f0 100755 (executable)
@@ -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