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
ad563552
Commit
ad563552
authored
Jun 27, 2022
by
Yuang Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use shallow feature flag in shallow clone support source code
parent
6bab22f4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
17 deletions
+23
-17
src/commit.c
+22
-16
src/repository.c
+1
-1
No files found.
src/commit.c
View file @
ad563552
...
...
@@ -500,29 +500,35 @@ int git_commit__parse_raw(void *commit, const char *data, size_t size)
int
git_commit__parse_ext
(
git_commit
*
commit
,
git_odb_object
*
odb_obj
,
unsigned
int
flags
)
{
git_repository
*
repo
=
git_object_owner
((
git_object
*
)
commit
);
git_commit_graft
*
graft
;
int
error
;
int
error
;
if
((
error
=
commit_parse
(
commit
,
git_odb_object_data
(
odb_obj
),
git_odb_object_size
(
odb_obj
),
flags
))
<
0
)
return
error
;
/* Perform necessary grafts */
if
(
git_grafts_get
(
&
graft
,
repo
->
grafts
,
git_odb_object_id
(
odb_obj
))
==
0
||
git_grafts_get
(
&
graft
,
repo
->
shallow_grafts
,
git_odb_object_id
(
odb_obj
))
==
0
)
{
size_t
idx
;
git_oid
*
oid
;
git_array_clear
(
commit
->
parent_ids
);
git_array_init_to_size
(
commit
->
parent_ids
,
git_array_size
(
graft
->
parents
));
git_array_foreach
(
graft
->
parents
,
idx
,
oid
)
{
git_oid
*
id
=
git_array_alloc
(
commit
->
parent_ids
);
GIT_ERROR_CHECK_ALLOC
(
id
);
git_oid_cpy
(
id
,
oid
);
if
(
GIT_OPT_ENABLE_SHALLOW
)
{
git_repository
*
repo
=
git_object_owner
((
git_object
*
)
commit
);
git_commit_graft
*
graft
;
/* Perform necessary grafts */
if
(
git_grafts_get
(
&
graft
,
repo
->
grafts
,
git_odb_object_id
(
odb_obj
))
==
0
||
git_grafts_get
(
&
graft
,
repo
->
shallow_grafts
,
git_odb_object_id
(
odb_obj
))
==
0
)
{
size_t
idx
;
git_oid
*
oid
;
git_array_clear
(
commit
->
parent_ids
);
git_array_init_to_size
(
commit
->
parent_ids
,
git_array_size
(
graft
->
parents
));
git_array_foreach
(
graft
->
parents
,
idx
,
oid
)
{
git_oid
*
id
=
git_array_alloc
(
commit
->
parent_ids
);
GIT_ERROR_CHECK_ALLOC
(
id
);
git_oid_cpy
(
id
,
oid
);
}
}
}
}
return
0
;
}
...
...
src/repository.c
View file @
ad563552
...
...
@@ -926,7 +926,7 @@ int git_repository_open_ext(
if
((
error
=
check_extensions
(
config
,
version
))
<
0
)
goto
cleanup
;
if
((
error
=
load_grafts
(
repo
))
<
0
)
if
(
GIT_OPT_ENABLE_SHALLOW
&&
(
error
=
load_grafts
(
repo
))
<
0
)
goto
cleanup
;
if
((
flags
&
GIT_REPOSITORY_OPEN_BARE
)
!=
0
)
...
...
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