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
b4d13652
Commit
b4d13652
authored
Nov 29, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deploy GIT_REPOSITORY_INIT_OPTIONS_INIT
parent
9267ff58
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
10 deletions
+20
-10
src/repository.c
+16
-2
src/submodule.c
+1
-2
tests-clar/repo/init.c
+3
-6
No files found.
src/repository.c
View file @
b4d13652
...
...
@@ -1151,9 +1151,8 @@ static int repo_init_create_origin(git_repository *repo, const char *url)
int
git_repository_init
(
git_repository
**
repo_out
,
const
char
*
path
,
unsigned
is_bare
)
{
git_repository_init_options
opts
;
git_repository_init_options
opts
=
GIT_REPOSITORY_INIT_OPTIONS_INIT
;
memset
(
&
opts
,
0
,
sizeof
(
opts
));
opts
.
flags
=
GIT_REPOSITORY_INIT_MKPATH
;
/* don't love this default */
if
(
is_bare
)
opts
.
flags
|=
GIT_REPOSITORY_INIT_BARE
;
...
...
@@ -1161,6 +1160,18 @@ int git_repository_init(
return
git_repository_init_ext
(
repo_out
,
path
,
&
opts
);
}
static
bool
options_have_valid_version
(
git_repository_init_options
*
opts
)
{
if
(
!
opts
)
return
true
;
if
(
opts
->
version
>
0
&&
opts
->
version
<=
GIT_REMOTE_CALLBACKS_VERSION
)
return
true
;
giterr_set
(
GITERR_INVALID
,
"Invalid version %d for git_repository_init_options"
,
opts
->
version
);
return
false
;
}
int
git_repository_init_ext
(
git_repository
**
out
,
const
char
*
given_repo
,
...
...
@@ -1171,6 +1182,9 @@ int git_repository_init_ext(
assert
(
out
&&
given_repo
&&
opts
);
if
(
!
options_have_valid_version
(
opts
))
return
-
1
;
error
=
repo_init_directories
(
&
repo_path
,
&
wd_path
,
given_repo
,
opts
);
if
(
error
<
0
)
goto
cleanup
;
...
...
src/submodule.c
View file @
b4d13652
...
...
@@ -205,7 +205,7 @@ int git_submodule_add_setup(
git_config_backend
*
mods
=
NULL
;
git_submodule
*
sm
;
git_buf
name
=
GIT_BUF_INIT
,
real_url
=
GIT_BUF_INIT
;
git_repository_init_options
initopt
;
git_repository_init_options
initopt
=
GIT_REPOSITORY_INIT_OPTIONS_INIT
;
git_repository
*
subrepo
=
NULL
;
assert
(
repo
&&
url
&&
path
);
...
...
@@ -275,7 +275,6 @@ int git_submodule_add_setup(
* Old style: sub-repo goes directly into repo/<name>/.git/
*/
memset
(
&
initopt
,
0
,
sizeof
(
initopt
));
initopt
.
flags
=
GIT_REPOSITORY_INIT_MKPATH
|
GIT_REPOSITORY_INIT_NO_REINIT
;
initopt
.
origin_url
=
real_url
.
ptr
;
...
...
tests-clar/repo/init.c
View file @
b4d13652
...
...
@@ -304,8 +304,7 @@ void test_repo_init__sets_logAllRefUpdates_according_to_type_of_repository(void)
void
test_repo_init__extended_0
(
void
)
{
git_repository_init_options
opts
;
memset
(
&
opts
,
0
,
sizeof
(
opts
));
git_repository_init_options
opts
=
GIT_REPOSITORY_INIT_OPTIONS_INIT
;
/* without MKDIR this should fail */
cl_git_fail
(
git_repository_init_ext
(
&
_repo
,
"extended"
,
&
opts
));
...
...
@@ -327,8 +326,7 @@ void test_repo_init__extended_1(void)
git_reference
*
ref
;
git_remote
*
remote
;
struct
stat
st
;
git_repository_init_options
opts
;
memset
(
&
opts
,
0
,
sizeof
(
opts
));
git_repository_init_options
opts
=
GIT_REPOSITORY_INIT_OPTIONS_INIT
;
opts
.
flags
=
GIT_REPOSITORY_INIT_MKPATH
|
GIT_REPOSITORY_INIT_NO_DOTGIT_DIR
;
...
...
@@ -367,8 +365,7 @@ void test_repo_init__extended_1(void)
void
test_repo_init__extended_with_template
(
void
)
{
git_repository_init_options
opts
;
memset
(
&
opts
,
0
,
sizeof
(
opts
));
git_repository_init_options
opts
=
GIT_REPOSITORY_INIT_OPTIONS_INIT
;
opts
.
flags
=
GIT_REPOSITORY_INIT_MKPATH
|
GIT_REPOSITORY_INIT_BARE
;
opts
.
template_path
=
cl_fixture
(
"template"
);
...
...
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