diff --git a/commit.c b/commit.c
index 97205bfb2ceaf77c2b90552327c9a4a1de83a39d..06d5439152cd835e4de11552ef09438ce14b4d1d 100644 (file)
--- a/commit.c
+++ b/commit.c
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++;
@@ -438,13 +439,13 @@ static int add_merge_info(enum cmit_fmt fmt, char *buf, const struct commit *com
while (parent) {
struct commit *p = parent->item;
+ const char *hex = abbrev
+ ? find_unique_abbrev(p->object.sha1, abbrev)
+ : sha1_to_hex(p->object.sha1);
+ char *dots = (abbrev && strlen(hex) != 40) ? "..." : "";
parent = parent->next;
- offset += sprintf(buf + offset,
- abbrev ? " %s..." : " %s",
- abbrev
- ? find_unique_abbrev(p->object.sha1, abbrev)
- : sha1_to_hex(p->object.sha1));
+ offset += sprintf(buf + offset, " %s%s", hex, dots);
}
buf[offset++] = '\n';
return offset;
/*
* 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;
}
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;
* 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;
}