aboutsummaryrefslogtreecommitdiffstats
path: root/credential.c
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2024-04-17 00:02:39 +0000
committerJunio C Hamano <gitster@pobox.com>2024-04-16 22:39:08 -0700
commit40220f48b1895c7c4c824c3c33576399128fbc0f (patch)
treecc7f8907ba9cd826a1e9b7e3b37b68dc710353e3 /credential.c
parent30c0a3036fc5ac8e49f570675950bb3a133ce34d (diff)
downloadgit-40220f48b1895c7c4c824c3c33576399128fbc0f.tar.gz
credential-cache: implement authtype capability
Now that we have full support in Git for the authtype capability, let's add support to the cache credential helper. When parsing data, we always set the initial capabilities because we're the helper, and we need both the initial and helper capabilities to be set in order to have the helper capabilities take effect. When emitting data, always emit the supported capability and make sure we emit items only if we have them and they're supported by the caller. Since we may no longer have a username or password, be sure to emit those conditionally as well so we don't segfault on a NULL pointer. Similarly, when comparing credentials, consider both the password and credential fields when we're matching passwords. Adjust the partial credential detection code so that we can store credentials missing a username or password as long as they have an authtype and credential. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'credential.c')
-rw-r--r--credential.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/credential.c b/credential.c
index 98b040cf11..ffaf31499e 100644
--- a/credential.c
+++ b/credential.c
@@ -80,7 +80,8 @@ int credential_match(const struct credential *want,
CHECK(host) &&
CHECK(path) &&
CHECK(username) &&
- (!match_password || CHECK(password));
+ (!match_password || CHECK(password)) &&
+ (!match_password || CHECK(credential));
#undef CHECK
}
@@ -248,8 +249,8 @@ static void credential_getpass(struct credential *c)
PROMPT_ASKPASS);
}
-static int credential_has_capability(const struct credential_capability *capa,
- enum credential_op_type op_type)
+int credential_has_capability(const struct credential_capability *capa,
+ enum credential_op_type op_type)
{
/*
* We're checking here if each previous step indicated that we had the