Fixed linked list tail being lost when sorting. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
diff --git a/src/commit.c b/src/commit.c
index dec93ef..10b759e 100644
--- a/src/commit.c
+++ b/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)
{
- git_commit_node *p, *q, *e, *tail;
+ git_commit_node *p, *q, *e;
int in_size, p_size, q_size, merge_count, i;
if (list->head == NULL)
@@ -304,7 +304,7 @@ void git_commit_list_sort(git_commit_list *list)
do
{
p = list->head;
- tail = NULL;
+ list->tail = NULL;
merge_count = 0;
while (p != NULL)
@@ -329,18 +329,18 @@ void git_commit_list_sort(git_commit_list *list)
else
e = q, q = q->next, q_size--;
- if (tail != NULL)
- tail->next = e;
+ if (list->tail != NULL)
+ list->tail->next = e;
else
list->head = e;
- tail = e;
+ list->tail = e;
}
p = q;
}
- tail->next = NULL;
+ list->tail->next = NULL;
in_size *= 2;
} while (merge_count > 1);