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
316bca69
Commit
316bca69
authored
Dec 19, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix clone sample
parent
00998a12
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
17 deletions
+6
-17
examples/network/clone.c
+6
-17
No files found.
examples/network/clone.c
View file @
316bca69
...
@@ -64,7 +64,7 @@ static int cred_acquire(git_cred **out, const char *url, unsigned int allowed_ty
...
@@ -64,7 +64,7 @@ static int cred_acquire(git_cred **out, const char *url, unsigned int allowed_ty
int
do_clone
(
git_repository
*
repo
,
int
argc
,
char
**
argv
)
int
do_clone
(
git_repository
*
repo
,
int
argc
,
char
**
argv
)
{
{
progress_data
pd
;
progress_data
pd
=
{
0
}
;
git_repository
*
cloned_repo
=
NULL
;
git_repository
*
cloned_repo
=
NULL
;
git_remote
*
origin
;
git_remote
*
origin
;
git_clone_options
clone_opts
=
GIT_CLONE_OPTIONS_INIT
;
git_clone_options
clone_opts
=
GIT_CLONE_OPTIONS_INIT
;
...
@@ -82,27 +82,16 @@ int do_clone(git_repository *repo, int argc, char **argv)
...
@@ -82,27 +82,16 @@ int do_clone(git_repository *repo, int argc, char **argv)
}
}
// Set up options
// Set up options
clone_opts
.
checkout_opts
=
&
checkout_opts
;
checkout_opts
.
checkout_strategy
=
GIT_CHECKOUT_SAFE
;
checkout_opts
.
checkout_strategy
=
GIT_CHECKOUT_SAFE
;
checkout_opts
.
progress_cb
=
checkout_progress
;
checkout_opts
.
progress_cb
=
checkout_progress
;
memset
(
&
pd
,
0
,
sizeof
(
pd
));
checkout_opts
.
progress_payload
=
&
pd
;
checkout_opts
.
progress_payload
=
&
pd
;
// 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
();
if
(
err
)
printf
(
"ERROR %d: %s
\n
"
,
err
->
klass
,
err
->
message
);
else
printf
(
"ERROR %d: no detailed info
\n
"
,
error
);
return
error
;
}
git_remote_set_cred_acquire_cb
(
origin
,
cred_acquire
,
NULL
);
// Do the clone
clone_opts
.
checkout_opts
=
&
checkout_opts
;
clone_opts
.
fetch_progress_cb
=
&
fetch_progress
;
clone_opts
.
fetch_progress_cb
=
&
fetch_progress
;
clone_opts
.
fetch_progress_payload
=
&
pd
;
clone_opts
.
fetch_progress_payload
=
&
pd
;
error
=
git_clone
(
&
cloned_repo
,
origin
,
path
,
&
clone_opts
);
clone_opts
.
cred_acquire_cb
=
cred_acquire
;
git_remote_free
(
origin
);
// Do the clone
error
=
git_clone
(
&
cloned_repo
,
url
,
path
,
&
clone_opts
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
if
(
error
!=
0
)
{
if
(
error
!=
0
)
{
const
git_error
*
err
=
giterr_last
();
const
git_error
*
err
=
giterr_last
();
...
...
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