X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=commit.c;h=c550a00d8242f9a57e0bd008d952f24e1b91ad35;hb=73be17f0b387b2741646498a9a80da677a9e0c7a;hp=67e11d7a4f211c1d2cf62635029f60597ff618de;hpb=6bfb27a0c5d742306905ed9c0962ba3c0a091625;p=git.git diff --git a/commit.c b/commit.c index 67e11d7a..c550a00d 100644 --- a/commit.c +++ b/commit.c @@ -571,7 +571,7 @@ int count_parents(struct commit * commit) /* * Performs an in-place topological sort on the list supplied. */ -void sort_in_topological_order(struct commit_list ** list) +void sort_in_topological_order(struct commit_list ** list, int lifo) { struct commit_list * next = *list; struct commit_list * work = NULL, **insert; @@ -630,7 +630,10 @@ void sort_in_topological_order(struct commit_list ** list) } next=next->next; } + /* process the list in topological order */ + if (!lifo) + sort_by_date(&work); while (work) { struct commit * work_item = pop_commit(&work); struct sort_node * work_node = (struct sort_node *)work_item->object.util; @@ -647,8 +650,12 @@ void sort_in_topological_order(struct commit_list ** list) * guaranteeing topological order. */ pn->indegree--; - if (!pn->indegree) - commit_list_insert(parent, &work); + if (!pn->indegree) { + if (!lifo) + insert_by_date(parent, &work); + else + commit_list_insert(parent, &work); + } } parents=parents->next; }