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
8eadeede
Commit
8eadeede
authored
Feb 09, 2023
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
repo: take an oid_type when initializing
parent
af20d13b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
3 deletions
+24
-3
include/git2/repository.h
+9
-0
src/libgit2/repository.c
+15
-3
No files found.
include/git2/repository.h
View file @
8eadeede
...
@@ -351,6 +351,15 @@ typedef struct {
...
@@ -351,6 +351,15 @@ typedef struct {
* pointing to this URL.
* pointing to this URL.
*/
*/
const
char
*
origin_url
;
const
char
*
origin_url
;
#ifdef GIT_EXPERIMENTAL_SHA256
/**
*
* Type of object IDs to use for this repository, or 0 for
* default (currently SHA1).
*/
git_oid_t
oid_type
;
#endif
}
git_repository_init_options
;
}
git_repository_init_options
;
#define GIT_REPOSITORY_INIT_OPTIONS_VERSION 1
#define GIT_REPOSITORY_INIT_OPTIONS_VERSION 1
...
...
src/libgit2/repository.c
View file @
8eadeede
...
@@ -1983,7 +1983,8 @@ static int repo_init_config(
...
@@ -1983,7 +1983,8 @@ static int repo_init_config(
const
char
*
repo_dir
,
const
char
*
repo_dir
,
const
char
*
work_dir
,
const
char
*
work_dir
,
uint32_t
flags
,
uint32_t
flags
,
uint32_t
mode
)
uint32_t
mode
,
git_oid_t
oid_type
)
{
{
int
error
=
0
;
int
error
=
0
;
git_str
cfg_path
=
GIT_STR_INIT
,
worktree_path
=
GIT_STR_INIT
;
git_str
cfg_path
=
GIT_STR_INIT
,
worktree_path
=
GIT_STR_INIT
;
...
@@ -2040,6 +2041,11 @@ static int repo_init_config(
...
@@ -2040,6 +2041,11 @@ static int repo_init_config(
SET_REPO_CONFIG
(
bool
,
"receive.denyNonFastforwards"
,
true
);
SET_REPO_CONFIG
(
bool
,
"receive.denyNonFastforwards"
,
true
);
}
}
if
(
oid_type
!=
GIT_OID_SHA1
)
{
SET_REPO_CONFIG
(
int32
,
"core.repositoryformatversion"
,
1
);
SET_REPO_CONFIG
(
string
,
"extensions.objectformat"
,
git_oid_type_name
(
oid_type
));
}
cleanup:
cleanup:
git_str_dispose
(
&
cfg_path
);
git_str_dispose
(
&
cfg_path
);
git_str_dispose
(
&
worktree_path
);
git_str_dispose
(
&
worktree_path
);
...
@@ -2520,6 +2526,7 @@ int git_repository_init_ext(
...
@@ -2520,6 +2526,7 @@ int git_repository_init_ext(
common_path
=
GIT_STR_INIT
;
common_path
=
GIT_STR_INIT
;
const
char
*
wd
;
const
char
*
wd
;
bool
is_valid
;
bool
is_valid
;
git_oid_t
oid_type
=
GIT_OID_DEFAULT
;
int
error
;
int
error
;
GIT_ASSERT_ARG
(
out
);
GIT_ASSERT_ARG
(
out
);
...
@@ -2528,6 +2535,11 @@ int git_repository_init_ext(
...
@@ -2528,6 +2535,11 @@ int git_repository_init_ext(
GIT_ERROR_CHECK_VERSION
(
opts
,
GIT_REPOSITORY_INIT_OPTIONS_VERSION
,
"git_repository_init_options"
);
GIT_ERROR_CHECK_VERSION
(
opts
,
GIT_REPOSITORY_INIT_OPTIONS_VERSION
,
"git_repository_init_options"
);
#ifdef GIT_EXPERIMENTAL_SHA256
if
(
opts
->
oid_type
)
oid_type
=
opts
->
oid_type
;
#endif
if
((
error
=
repo_init_directories
(
&
repo_path
,
&
wd_path
,
given_repo
,
opts
))
<
0
)
if
((
error
=
repo_init_directories
(
&
repo_path
,
&
wd_path
,
given_repo
,
opts
))
<
0
)
goto
out
;
goto
out
;
...
@@ -2546,13 +2558,13 @@ int git_repository_init_ext(
...
@@ -2546,13 +2558,13 @@ int git_repository_init_ext(
opts
->
flags
|=
GIT_REPOSITORY_INIT__IS_REINIT
;
opts
->
flags
|=
GIT_REPOSITORY_INIT__IS_REINIT
;
if
((
error
=
repo_init_config
(
repo_path
.
ptr
,
wd
,
opts
->
flags
,
opts
->
mode
))
<
0
)
if
((
error
=
repo_init_config
(
repo_path
.
ptr
,
wd
,
opts
->
flags
,
opts
->
mode
,
oid_type
))
<
0
)
goto
out
;
goto
out
;
/* TODO: reinitialize the templates */
/* TODO: reinitialize the templates */
}
else
{
}
else
{
if
((
error
=
repo_init_structure
(
repo_path
.
ptr
,
wd
,
opts
))
<
0
||
if
((
error
=
repo_init_structure
(
repo_path
.
ptr
,
wd
,
opts
))
<
0
||
(
error
=
repo_init_config
(
repo_path
.
ptr
,
wd
,
opts
->
flags
,
opts
->
mode
))
<
0
||
(
error
=
repo_init_config
(
repo_path
.
ptr
,
wd
,
opts
->
flags
,
opts
->
mode
,
oid_type
))
<
0
||
(
error
=
repo_init_head
(
repo_path
.
ptr
,
opts
->
initial_head
))
<
0
)
(
error
=
repo_init_head
(
repo_path
.
ptr
,
opts
->
initial_head
))
<
0
)
goto
out
;
goto
out
;
}
}
...
...
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