Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
2b10a2b0
Commit
2b10a2b0
authored
Dec 13, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable authenticated clones in network sample
parent
24393ea6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
1 deletions
+17
-1
examples/network/clone.c
+17
-1
No files found.
examples/network/clone.c
View file @
2b10a2b0
...
...
@@ -47,6 +47,21 @@ static void checkout_progress(const char *path, size_t cur, size_t tot, void *pa
print_progress
(
pd
);
}
static
int
cred_acquire
(
git_cred
**
out
,
const
char
*
url
,
unsigned
int
allowed_types
,
void
*
payload
)
{
char
username
[
128
]
=
{
0
};
char
password
[
128
]
=
{
0
};
printf
(
"Username: "
);
scanf
(
"%s"
,
username
);
/* Yup. Right there on your terminal. Careful where you copy/paste output. */
printf
(
"Password: "
);
scanf
(
"%s"
,
password
);
return
git_cred_userpass_plaintext_new
(
out
,
username
,
password
);
}
int
do_clone
(
git_repository
*
repo
,
int
argc
,
char
**
argv
)
{
progress_data
pd
;
...
...
@@ -71,7 +86,7 @@ int do_clone(git_repository *repo, int argc, char **argv)
memset
(
&
pd
,
0
,
sizeof
(
pd
));
checkout_opts
.
progress_payload
=
&
pd
;
// Create the origin remote
// Create the origin remote
, and set up for auth
error
=
git_remote_new
(
&
origin
,
NULL
,
"origin"
,
url
,
GIT_REMOTE_DEFAULT_FETCH
);
if
(
error
!=
0
)
{
const
git_error
*
err
=
giterr_last
();
...
...
@@ -79,6 +94,7 @@ int do_clone(git_repository *repo, int argc, char **argv)
else
printf
(
"ERROR %d: no detailed info
\n
"
,
error
);
return
error
;
}
git_remote_set_cred_acquire_cb
(
origin
,
cred_acquire
,
NULL
);
// Do the clone
error
=
git_clone
(
&
cloned_repo
,
origin
,
path
,
&
checkout_opts
,
&
fetch_progress
,
&
pd
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment