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
8821c9aa
Commit
8821c9aa
authored
Sep 15, 2013
by
Ben Straub
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1850 from linquize/git-clone-init-options
git_clone supports init_options
parents
e580afd8
f2df503b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
+12
-3
include/git2/clone.h
+1
-0
src/clone.c
+11
-3
No files found.
include/git2/clone.h
View file @
8821c9aa
...
@@ -67,6 +67,7 @@ typedef struct git_clone_options {
...
@@ -67,6 +67,7 @@ typedef struct git_clone_options {
unsigned
int
version
;
unsigned
int
version
;
git_checkout_opts
checkout_opts
;
git_checkout_opts
checkout_opts
;
git_repository_init_options
*
init_options
;
int
bare
;
int
bare
;
git_transfer_progress_callback
fetch_progress_cb
;
git_transfer_progress_callback
fetch_progress_cb
;
void
*
fetch_progress_payload
;
void
*
fetch_progress_payload
;
...
...
src/clone.c
View file @
8821c9aa
...
@@ -418,7 +418,7 @@ static bool should_checkout(
...
@@ -418,7 +418,7 @@ static bool should_checkout(
return
!
git_repository_head_orphan
(
repo
);
return
!
git_repository_head_orphan
(
repo
);
}
}
static
void
normalize_options
(
git_clone_options
*
dst
,
const
git_clone_options
*
src
)
static
void
normalize_options
(
git_clone_options
*
dst
,
const
git_clone_options
*
src
,
git_repository_init_options
*
initOptions
)
{
{
git_clone_options
default_options
=
GIT_CLONE_OPTIONS_INIT
;
git_clone_options
default_options
=
GIT_CLONE_OPTIONS_INIT
;
if
(
!
src
)
src
=
&
default_options
;
if
(
!
src
)
src
=
&
default_options
;
...
@@ -427,6 +427,13 @@ static void normalize_options(git_clone_options *dst, const git_clone_options *s
...
@@ -427,6 +427,13 @@ static void normalize_options(git_clone_options *dst, const git_clone_options *s
/* Provide defaults for null pointers */
/* Provide defaults for null pointers */
if
(
!
dst
->
remote_name
)
dst
->
remote_name
=
"origin"
;
if
(
!
dst
->
remote_name
)
dst
->
remote_name
=
"origin"
;
if
(
!
dst
->
init_options
)
{
dst
->
init_options
=
initOptions
;
initOptions
->
flags
=
GIT_REPOSITORY_INIT_MKPATH
;
if
(
dst
->
bare
)
initOptions
->
flags
|=
GIT_REPOSITORY_INIT_BARE
;
}
}
}
int
git_clone
(
int
git_clone
(
...
@@ -439,10 +446,11 @@ int git_clone(
...
@@ -439,10 +446,11 @@ int git_clone(
git_repository
*
repo
=
NULL
;
git_repository
*
repo
=
NULL
;
git_clone_options
normOptions
;
git_clone_options
normOptions
;
int
remove_directory_on_failure
=
0
;
int
remove_directory_on_failure
=
0
;
git_repository_init_options
initOptions
=
GIT_REPOSITORY_INIT_OPTIONS_INIT
;
assert
(
out
&&
url
&&
local_path
);
assert
(
out
&&
url
&&
local_path
);
normalize_options
(
&
normOptions
,
options
);
normalize_options
(
&
normOptions
,
options
,
&
initOptions
);
GITERR_CHECK_VERSION
(
&
normOptions
,
GIT_CLONE_OPTIONS_VERSION
,
"git_clone_options"
);
GITERR_CHECK_VERSION
(
&
normOptions
,
GIT_CLONE_OPTIONS_VERSION
,
"git_clone_options"
);
/* Only clone to a new directory or an empty directory */
/* Only clone to a new directory or an empty directory */
...
@@ -455,7 +463,7 @@ int git_clone(
...
@@ -455,7 +463,7 @@ int git_clone(
/* Only remove the directory on failure if we create it */
/* Only remove the directory on failure if we create it */
remove_directory_on_failure
=
!
git_path_exists
(
local_path
);
remove_directory_on_failure
=
!
git_path_exists
(
local_path
);
if
(
!
(
retcode
=
git_repository_init
(
&
repo
,
local_path
,
normOptions
.
bare
)))
{
if
(
!
(
retcode
=
git_repository_init
_ext
(
&
repo
,
local_path
,
normOptions
.
init_options
)))
{
if
((
retcode
=
setup_remotes_and_fetch
(
repo
,
url
,
&
normOptions
))
<
0
)
{
if
((
retcode
=
setup_remotes_and_fetch
(
repo
,
url
,
&
normOptions
))
<
0
)
{
/* Failed to fetch; clean up */
/* Failed to fetch; clean up */
git_repository_free
(
repo
);
git_repository_free
(
repo
);
...
...
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