mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-19 18:39:26 +00:00
Fixed linked list tail being lost when sorting.
Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
This commit is contained in:
parent
a7c182c594
commit
47c31f584e
12
src/commit.c
12
src/commit.c
@ -293,7 +293,7 @@ void git_commit_list_clear(git_commit_list *list, int free_commits)
|
|||||||
|
|
||||||
void git_commit_list_sort(git_commit_list *list)
|
void git_commit_list_sort(git_commit_list *list)
|
||||||
{
|
{
|
||||||
git_commit_node *p, *q, *e, *tail;
|
git_commit_node *p, *q, *e;
|
||||||
int in_size, p_size, q_size, merge_count, i;
|
int in_size, p_size, q_size, merge_count, i;
|
||||||
|
|
||||||
if (list->head == NULL)
|
if (list->head == NULL)
|
||||||
@ -304,7 +304,7 @@ void git_commit_list_sort(git_commit_list *list)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
p = list->head;
|
p = list->head;
|
||||||
tail = NULL;
|
list->tail = NULL;
|
||||||
merge_count = 0;
|
merge_count = 0;
|
||||||
|
|
||||||
while (p != NULL)
|
while (p != NULL)
|
||||||
@ -329,18 +329,18 @@ void git_commit_list_sort(git_commit_list *list)
|
|||||||
else
|
else
|
||||||
e = q, q = q->next, q_size--;
|
e = q, q = q->next, q_size--;
|
||||||
|
|
||||||
if (tail != NULL)
|
if (list->tail != NULL)
|
||||||
tail->next = e;
|
list->tail->next = e;
|
||||||
else
|
else
|
||||||
list->head = e;
|
list->head = e;
|
||||||
|
|
||||||
tail = e;
|
list->tail = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = q;
|
p = q;
|
||||||
}
|
}
|
||||||
|
|
||||||
tail->next = NULL;
|
list->tail->next = NULL;
|
||||||
in_size *= 2;
|
in_size *= 2;
|
||||||
|
|
||||||
} while (merge_count > 1);
|
} while (merge_count > 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user