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
62cc77a1
Commit
62cc77a1
authored
Jul 28, 2022
by
yuangli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor commit parent assignment with graft
parent
14d2a60a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
15 deletions
+21
-15
src/libgit2/commit.c
+21
-15
No files found.
src/libgit2/commit.c
View file @
62cc77a1
...
...
@@ -499,6 +499,22 @@ int git_commit__parse_raw(void *commit, const char *data, size_t size)
return
commit_parse
(
commit
,
data
,
size
,
0
);
}
static
int
assign_parents_from_graft
(
git_commit
*
commit
,
git_commit_graft
*
graft
)
{
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
;
}
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
);
...
...
@@ -513,21 +529,11 @@ int git_commit__parse_ext(git_commit *commit, git_odb_object *odb_obj, unsigned
return
0
;
/* 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
;
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
)
return
0
;
return
assign_parents_from_graft
(
commit
,
graft
);
}
int
git_commit__parse
(
void
*
_commit
,
git_odb_object
*
odb_obj
)
...
...
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