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
633cde01
Unverified
Commit
633cde01
authored
Jul 15, 2023
by
Edward Thomson
Committed by
GitHub
Jul 15, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6539 from cavaquinho/fix/revwalk-insert-by-date
Partial fix for #6532: insert-by-date order.
parents
15e42fb5
4edf6c11
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
7 deletions
+35
-7
src/libgit2/commit_list.c
+8
-3
src/libgit2/commit_list.h
+1
-0
src/libgit2/revwalk.c
+26
-4
No files found.
src/libgit2/commit_list.c
View file @
633cde01
...
...
@@ -43,13 +43,18 @@ int git_commit_list_time_cmp(const void *a, const void *b)
return
0
;
}
git_commit_list
*
git_commit_list_insert
(
git_commit_list_node
*
item
,
git_commit_list
**
list_p
)
{
git_commit_list
*
git_commit_list_create
(
git_commit_list_node
*
item
,
git_commit_list
*
next
)
{
git_commit_list
*
new_list
=
git__malloc
(
sizeof
(
git_commit_list
));
if
(
new_list
!=
NULL
)
{
new_list
->
item
=
item
;
new_list
->
next
=
*
list_p
;
new_list
->
next
=
next
;
}
return
new_list
;
}
git_commit_list
*
git_commit_list_insert
(
git_commit_list_node
*
item
,
git_commit_list
**
list_p
)
{
git_commit_list
*
new_list
=
git_commit_list_create
(
item
,
*
list_p
);
*
list_p
=
new_list
;
return
new_list
;
}
...
...
src/libgit2/commit_list.h
View file @
633cde01
...
...
@@ -49,6 +49,7 @@ git_commit_list_node *git_commit_list_alloc_node(git_revwalk *walk);
int
git_commit_list_generation_cmp
(
const
void
*
a
,
const
void
*
b
);
int
git_commit_list_time_cmp
(
const
void
*
a
,
const
void
*
b
);
void
git_commit_list_free
(
git_commit_list
**
list_p
);
git_commit_list
*
git_commit_list_create
(
git_commit_list_node
*
item
,
git_commit_list
*
next
);
git_commit_list
*
git_commit_list_insert
(
git_commit_list_node
*
item
,
git_commit_list
**
list_p
);
git_commit_list
*
git_commit_list_insert_by_date
(
git_commit_list_node
*
item
,
git_commit_list
**
list_p
);
int
git_commit_list_parse
(
git_revwalk
*
walk
,
git_commit_list_node
*
commit
);
...
...
src/libgit2/revwalk.c
View file @
633cde01
...
...
@@ -83,8 +83,13 @@ int git_revwalk__push_commit(git_revwalk *walk, const git_oid *oid, const git_re
commit
->
uninteresting
=
opts
->
uninteresting
;
list
=
walk
->
user_input
;
if
((
opts
->
insert_by_date
&&
git_commit_list_insert_by_date
(
commit
,
&
list
)
==
NULL
)
||
/* To insert by date, we need to parse so we know the date. */
if
(
opts
->
insert_by_date
&&
((
error
=
git_commit_list_parse
(
walk
,
commit
))
<
0
))
return
error
;
if
((
opts
->
insert_by_date
==
0
||
git_commit_list_insert_by_date
(
commit
,
&
list
)
==
NULL
)
&&
git_commit_list_insert
(
commit
,
&
list
)
==
NULL
)
{
git_error_set_oom
();
return
-
1
;
...
...
@@ -609,7 +614,7 @@ cleanup:
static
int
prepare_walk
(
git_revwalk
*
walk
)
{
int
error
=
0
;
git_commit_list
*
list
,
*
commits
=
NULL
;
git_commit_list
*
list
,
*
commits
=
NULL
,
*
commits_last
=
NULL
;
git_commit_list_node
*
next
;
/* If there were no pushes, we know that the walk is already over */
...
...
@@ -618,6 +623,12 @@ static int prepare_walk(git_revwalk *walk)
return
GIT_ITEROVER
;
}
/*
* This is a bit convoluted, but necessary to maintain the order of
* the commits. This is especially important in situations where
* git_revwalk__push_glob is called with a git_revwalk__push_options
* setting insert_by_date = 1, which is critical for fetch negotiation.
*/
for
(
list
=
walk
->
user_input
;
list
;
list
=
list
->
next
)
{
git_commit_list_node
*
commit
=
list
->
item
;
if
((
error
=
git_commit_list_parse
(
walk
,
commit
))
<
0
)
...
...
@@ -627,8 +638,19 @@ static int prepare_walk(git_revwalk *walk)
mark_parents_uninteresting
(
commit
);
if
(
!
commit
->
seen
)
{
git_commit_list
*
new_list
=
NULL
;
if
((
new_list
=
git_commit_list_create
(
commit
,
NULL
))
==
NULL
)
{
git_error_set_oom
();
return
-
1
;
}
commit
->
seen
=
1
;
git_commit_list_insert
(
commit
,
&
commits
);
if
(
commits_last
==
NULL
)
commits
=
new_list
;
else
commits_last
->
next
=
new_list
;
commits_last
=
new_list
;
}
}
...
...
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