Skip to content

Commit aa4cd77

Browse files
authored
Merge pull request libgit2#5336 from libgit2/ethomson/credtype
cred: change enum to git_credential_t and GIT_CREDENTIAL_*
2 parents f9b41a6 + 3f54ba8 commit aa4cd77

32 files changed

+966
-761
lines changed

examples/common.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static int ask(char **out, const char *prompt, char optional)
176176
return 0;
177177
}
178178

179-
int cred_acquire_cb(git_cred **out,
179+
int cred_acquire_cb(git_credential **out,
180180
const char *url,
181181
const char *username_from_url,
182182
unsigned int allowed_types,
@@ -195,7 +195,7 @@ int cred_acquire_cb(git_cred **out,
195195
goto out;
196196
}
197197

198-
if (allowed_types & GIT_CREDTYPE_SSH_KEY) {
198+
if (allowed_types & GIT_CREDENTIAL_SSH_KEY) {
199199
int n;
200200

201201
if ((error = ask(&privkey, "SSH Key:", 0)) < 0 ||
@@ -207,14 +207,14 @@ int cred_acquire_cb(git_cred **out,
207207
(n = snprintf(pubkey, n + 1, "%s.pub", privkey)) < 0)
208208
goto out;
209209

210-
error = git_cred_ssh_key_new(out, username, pubkey, privkey, password);
211-
} else if (allowed_types & GIT_CREDTYPE_USERPASS_PLAINTEXT) {
210+
error = git_credential_ssh_key_new(out, username, pubkey, privkey, password);
211+
} else if (allowed_types & GIT_CREDENTIAL_USERPASS_PLAINTEXT) {
212212
if ((error = ask(&password, "Password:", 1)) < 0)
213213
goto out;
214214

215-
error = git_cred_userpass_plaintext_new(out, username, password);
216-
} else if (allowed_types & GIT_CREDTYPE_USERNAME) {
217-
error = git_cred_username_new(out, username);
215+
error = git_credential_userpass_plaintext_new(out, username, password);
216+
} else if (allowed_types & GIT_CREDENTIAL_USERNAME) {
217+
error = git_credential_username_new(out, username);
218218
}
219219

220220
out:

examples/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ extern int resolve_refish(git_annotated_commit **commit, git_repository *repo, c
125125
/**
126126
* Acquire credentials via command line
127127
*/
128-
extern int cred_acquire_cb(git_cred **out,
128+
extern int cred_acquire_cb(git_credential **out,
129129
const char *url,
130130
const char *username_from_url,
131131
unsigned int allowed_types,

include/git2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "git2/commit.h"
2323
#include "git2/common.h"
2424
#include "git2/config.h"
25-
#include "git2/cred.h"
25+
#include "git2/credential.h"
2626
#include "git2/deprecated.h"
2727
#include "git2/describe.h"
2828
#include "git2/diff.h"

include/git2/cred_helpers.h

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,9 @@
77
#ifndef INCLUDE_git_cred_helpers_h__
88
#define INCLUDE_git_cred_helpers_h__
99

10-
#include "transport.h"
11-
12-
/**
13-
* @file git2/cred_helpers.h
14-
* @brief Utility functions for credential management
15-
* @defgroup git_cred_helpers credential management helpers
16-
* @ingroup Git
17-
* @{
18-
*/
19-
GIT_BEGIN_DECL
20-
21-
/**
22-
* Payload for git_cred_stock_userpass_plaintext.
23-
*/
24-
typedef struct git_cred_userpass_payload {
25-
const char *username;
26-
const char *password;
27-
} git_cred_userpass_payload;
28-
29-
30-
/**
31-
* Stock callback usable as a git_cred_acquire_cb. This calls
32-
* git_cred_userpass_plaintext_new unless the protocol has not specified
33-
* `GIT_CREDTYPE_USERPASS_PLAINTEXT` as an allowed type.
34-
*
35-
* @param cred The newly created credential object.
36-
* @param url The resource for which we are demanding a credential.
37-
* @param user_from_url The username that was embedded in a "user\@host"
38-
* remote url, or NULL if not included.
39-
* @param allowed_types A bitmask stating which cred types are OK to return.
40-
* @param payload The payload provided when specifying this callback. (This is
41-
* interpreted as a `git_cred_userpass_payload*`.)
42-
*/
43-
GIT_EXTERN(int) git_cred_userpass(
44-
git_cred **cred,
45-
const char *url,
46-
const char *user_from_url,
47-
unsigned int allowed_types,
48-
void *payload);
49-
10+
/* These declarations have moved. */
11+
#ifndef GIT_DEPRECATE_HARD
12+
# include "git2/credential_helpers.h"
13+
#endif
5014

51-
/** @} */
52-
GIT_END_DECL
5315
#endif

0 commit comments

Comments
 (0)