8000 Merge pull request #5904 from pluehne/support-authentication-in-push-… · russell/libgit2@198a1b2 · GitHub 8000
[go: up one dir, main page]

Skip to content

Commit 198a1b2

Browse files
authored
Merge pull request libgit2#5904 from pluehne/support-authentication-in-push-example
Support authentication in push example
2 parents 517d2cd + 7ed00c5 commit 198a1b2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

examples/push.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
/** Entry point for this command */
3333
int lg2_push(git_repository *repo, int argc, char **argv) {
3434
git_push_options options;
35+
git_remote_callbacks callbacks;
3536
git_remote* remote = NULL;
3637
char *refspec = "refs/heads/master";
3738
const git_strarray refspecs = {
@@ -47,7 +48,11 @@ int lg2_push(git_repository *repo, int argc, char **argv) {
4748

4849
check_lg2(git_remote_lookup(&remote, repo, "origin" ), "Unable to lookup remote", NULL);
4950

51+
check_lg2(git_remote_init_callbacks(&callbacks, GIT_REMOTE_CALLBACKS_VERSION), "Error initializing remote callbacks", NULL);
52+
callbacks.credentials = cred_acquire_cb;
53+
5054
check_lg2(git_push_options_init(&options, GIT_PUSH_OPTIONS_VERSION ), "Error initializing push", NULL);
55+
options.callbacks = callbacks;
5156

5257
check_lg2(git_remote_push(remote, &refspecs, &options), "Error pushing", NULL);
5358

0 commit comments

Comments
 (0)
0