X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=commit.c;h=06d5439152cd835e4de11552ef09438ce14b4d1d;hb=c7569b1e0009e0187ce9f87f23699eaa8576b6ee;hp=67e11d7a4f211c1d2cf62635029f60597ff618de;hpb=90768daaa006516c7ae69ed89d7c2e67243dfac1;p=git.git diff --git a/commit.c b/commit.c index 67e11d7a..06d54391 100644 --- a/commit.c +++ b/commit.c @@ -212,7 +212,8 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size) if (memcmp(bufptr, "tree ", 5)) return error("bogus commit object %s", sha1_to_hex(item->object.sha1)); if (get_sha1_hex(bufptr + 5, parent) < 0) - return error("bad tree pointer in commit %s\n", sha1_to_hex(item->object.sha1)); + return error("bad tree pointer in commit %s", + sha1_to_hex(item->object.sha1)); item->tree = lookup_tree(parent); if (item->tree) n_refs++; @@ -571,7 +572,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 +631,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 +651,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; }