diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-06-25 15:41:01 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-06-26 22:58:38 +0200 |
commit | 54da69588e9560694b6687d3384ac53f18aa11ea (patch) | |
tree | 267dc6a37380f4053336ce3463af4a1cab3e48d2 /src/transports/cred.c | |
parent | d7f962f40897556bc5c5d2b91cceb06d2fe9307d (diff) | |
download | libgit2-54da69588e9560694b6687d3384ac53f18aa11ea.tar.gz |
cred: introduce username-only cred
This exists as ssh needs to know about the username to use before it can
query for the supported authentication methods.
Diffstat (limited to 'src/transports/cred.c')
-rw-r--r-- | src/transports/cred.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/transports/cred.c b/src/transports/cred.c index 913ec36cc..872b0ad30 100644 --- a/src/transports/cred.c +++ b/src/transports/cred.c @@ -129,6 +129,11 @@ static void default_free(struct git_cred *cred) git__free(c); } +static void username_free(struct git_cred *cred) +{ + git__free(cred); +} + int git_cred_ssh_key_new( git_cred **cred, const char *username, @@ -263,3 +268,21 @@ int git_cred_default_new(git_cred **cred) *cred = c; return 0; } + +int git_cred_username_new(git_cred **cred, const char *username) +{ + git_cred_username *c; + size_t len; + + assert(cred); + + len = strlen(username); + c = git__malloc(sizeof(git_cred_username) + len + 1); + GITERR_CHECK_ALLOC(c); + + c->parent.credtype = GIT_CREDTYPE_USERNAME; + c->parent.free = username_free; + memcpy(c->username, username, len + 1); + + return 0; +} |