- if (argc != 2 || get_sha1_hex(argv[1], sha1))
- usage("rev-tree [--cache <cache-file>] <commit-id>");
- parse_commit(sha1);
- for (i = 0; i < nr_rels; i++) {
- char parent[60];
- struct relationship *rel = rels[i];
- strcpy(parent, sha1_to_hex(rel->parent));
- printf("%s %s\n", sha1_to_hex(rel->sha1), parent);
+ /*
+ * Parse all the commits in date order.
+ *
+ * We really should stop once we know enough, but that's a
+ * decision that isn't trivial to make.
+ */
+ while (list)
+ pop_most_recent_commit(&list, REACHABLE);
+
+ /*
+ * Now we have the maximal tree. Walk the different sha files back to the root.
+ */
+ for (i = 0; i < nr; i++)
+ mark_reachable(&lookup_commit_reference(sha1[i])->object, 1 << i);
+
+ /*
+ * Now print out the results..
+ */
+ for (i = 0; i < nr_objs; i++) {
+ struct object *obj = objs[i];
+ struct commit *commit;
+ struct commit_list *p;
+
+ if (obj->type != commit_type)
+ continue;
+
+ commit = (struct commit *) obj;
+
+ if (!interesting(commit))
+ continue;
+
+ printf("%lu %s:%d", commit->date, sha1_to_hex(obj->sha1),
+ cmit_flags(commit));
+ p = commit->parents;
+ while (p) {
+ printf(" %s:%d", sha1_to_hex(p->item->object.sha1),
+ cmit_flags(p->item));
+ p = p->next;
+ }
+ printf("\n");