summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2013-01-08 12:58:20 -0800
committerBen Straub <bs@github.com>2013-01-09 13:31:17 -0800
commitffb02b1630da85e063a816cc6dddcdc004a8ff72 (patch)
treef8660cf4d0c99b7185b1428edc777c6f573b9041 /src
parent252b24049cf7018ba80c736fda636c53c465fbd2 (diff)
downloadlibgit2-ffb02b1630da85e063a816cc6dddcdc004a8ff72.tar.gz
Expose stock user/pass credential utility
Diffstat (limited to 'src')
-rw-r--r--src/transports/cred.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/transports/cred.c b/src/transports/cred.c
index 85472bd6a..5ecb8a4b9 100644
--- a/src/transports/cred.c
+++ b/src/transports/cred.c
@@ -57,3 +57,23 @@ int git_cred_userpass_plaintext_new(
*cred = &c->parent;
return 0;
}
+
+int git_cred_stock_userpass_plaintext(
+ git_cred **cred,
+ const char *url,
+ unsigned int allowed_types,
+ void *payload)
+{
+ git_cred_stock_userpass_plaintext_payload *userpass =
+ (git_cred_stock_userpass_plaintext_payload*)payload;
+
+ GIT_UNUSED(url);
+
+ if (!userpass || !userpass->username || !userpass->password) return -1;
+
+ if ((GIT_CREDTYPE_USERPASS_PLAINTEXT & allowed_types) == 0 ||
+ git_cred_userpass_plaintext_new(cred, userpass->username, userpass->password) < 0)
+ return -1;
+
+ return 0;
+}