]> git.ipfire.org Git - thirdparty/git.git/blame - rev-list.c
rev-list split: minimum fixup.
[thirdparty/git.git] / rev-list.c
CommitLineData
64745109 1#include "cache.h"
e091eb93 2#include "refs.h"
36f8d174 3#include "tag.h"
64745109 4#include "commit.h"
9de48752
LT
5#include "tree.h"
6#include "blob.h"
a3437b8c 7#include "epoch.h"
cf484544 8#include "diff.h"
ae563542
LT
9#include "revision.h"
10
11/* bits #0 and #1 in revision.h */
64745109 12
8b3a1e05 13#define COUNTED (1u << 2)
bce62866 14#define SHOWN (1u << 3)
1b9e059d 15#define TREECHANGE (1u << 4)
88494423 16#define TMP_MARK (1u << 5) /* for isolated cases; clean after use */
8906300f 17
a6f68d47 18static const char rev_list_usage[] =
69e0c256
JH
19"git-rev-list [OPTION] <commit-id>... [ -- paths... ]\n"
20" limiting output:\n"
21" --max-count=nr\n"
22" --max-age=epoch\n"
23" --min-age=epoch\n"
24" --sparse\n"
25" --no-merges\n"
93b74bca 26" --remove-empty\n"
69e0c256
JH
27" --all\n"
28" ordering output:\n"
29" --merge-order [ --show-breaks ]\n"
30" --topo-order\n"
4c8725f1 31" --date-order\n"
69e0c256
JH
32" formatting output:\n"
33" --parents\n"
c6496575 34" --objects | --objects-edge\n"
69e0c256
JH
35" --unpacked\n"
36" --header | --pretty\n"
9da5c2f0 37" --abbrev=nr | --no-abbrev\n"
69e0c256
JH
38" special purpose:\n"
39" --bisect"
40;
a6f68d47 41
ae563542
LT
42struct rev_info revs;
43
12d2a187 44static int unpacked = 0;
8b3a1e05 45static int bisect_list = 0;
81f2bb1f 46static int verbose_header = 0;
9da5c2f0 47static int abbrev = DEFAULT_ABBREV;
81f2bb1f 48static int show_parents = 0;
81f2bb1f 49static int hdr_termination = 0;
d998a089 50static const char *commit_prefix = "";
000182ea 51static enum cmit_fmt commit_format = CMIT_FMT_RAW;
a3437b8c
JS
52static int merge_order = 0;
53static int show_breaks = 0;
5e749e25 54static int stop_traversal = 0;
76cd8eb6 55static int no_merges = 0;
e646de0d 56
81f2bb1f
LT
57static void show_commit(struct commit *commit)
58{
51b1e171 59 commit->object.flags |= SHOWN;
a3437b8c 60 if (show_breaks) {
d998a089 61 commit_prefix = "| ";
a3437b8c 62 if (commit->object.flags & DISCONTINUITY) {
d998a089 63 commit_prefix = "^ ";
a3437b8c 64 } else if (commit->object.flags & BOUNDARY) {
d998a089 65 commit_prefix = "= ";
a3437b8c
JS
66 }
67 }
d998a089 68 printf("%s%s", commit_prefix, sha1_to_hex(commit->object.sha1));
81f2bb1f
LT
69 if (show_parents) {
70 struct commit_list *parents = commit->parents;
71 while (parents) {
88494423 72 struct object *o = &(parents->item->object);
81f2bb1f 73 parents = parents->next;
88494423
JH
74 if (o->flags & TMP_MARK)
75 continue;
76 printf(" %s", sha1_to_hex(o->sha1));
77 o->flags |= TMP_MARK;
81f2bb1f 78 }
88494423
JH
79 /* TMP_MARK is a general purpose flag that can
80 * be used locally, but the user should clean
81 * things up after it is done with them.
82 */
83 for (parents = commit->parents;
84 parents;
85 parents = parents->next)
86 parents->item->object.flags &= ~TMP_MARK;
81f2bb1f 87 }
d87449c5
JH
88 if (commit_format == CMIT_FMT_ONELINE)
89 putchar(' ');
90 else
91 putchar('\n');
92
81f2bb1f 93 if (verbose_header) {
000182ea 94 static char pretty_header[16384];
9da5c2f0 95 pretty_print_commit(commit_format, commit, ~0, pretty_header, sizeof(pretty_header), abbrev);
000182ea 96 printf("%s%c", pretty_header, hdr_termination);
7620d39f
LT
97 }
98 fflush(stdout);
a3437b8c
JS
99}
100
129adf4d 101static int rewrite_one(struct commit **pp)
1b9e059d
LT
102{
103 for (;;) {
104 struct commit *p = *pp;
105 if (p->object.flags & (TREECHANGE | UNINTERESTING))
129adf4d
LT
106 return 0;
107 if (!p->parents)
108 return -1;
1b9e059d
LT
109 *pp = p->parents->item;
110 }
111}
112
113static void rewrite_parents(struct commit *commit)
114{
129adf4d
LT
115 struct commit_list **pp = &commit->parents;
116 while (*pp) {
117 struct commit_list *parent = *pp;
118 if (rewrite_one(&parent->item) < 0) {
119 *pp = parent->next;
120 continue;
121 }
122 pp = &parent->next;
1b9e059d
LT
123 }
124}
125
a3437b8c
JS
126static int filter_commit(struct commit * commit)
127{
d2775a81 128 if (stop_traversal && (commit->object.flags & BOUNDARY))
5e749e25 129 return STOP;
51b1e171 130 if (commit->object.flags & (UNINTERESTING|SHOWN))
a3437b8c 131 return CONTINUE;
ae563542 132 if (revs.min_age != -1 && (commit->date > revs.min_age))
a3437b8c 133 return CONTINUE;
ae563542 134 if (revs.max_age != -1 && (commit->date < revs.max_age)) {
d2775a81 135 stop_traversal=1;
27cfe2e2 136 return CONTINUE;
5e749e25 137 }
76cd8eb6
JS
138 if (no_merges && (commit->parents && commit->parents->next))
139 return CONTINUE;
ae563542 140 if (revs.paths && revs.dense) {
1b9e059d
LT
141 if (!(commit->object.flags & TREECHANGE))
142 return CONTINUE;
143 rewrite_parents(commit);
144 }
a3437b8c
JS
145 return DO;
146}
147
148static int process_commit(struct commit * commit)
149{
150 int action=filter_commit(commit);
151
152 if (action == STOP) {
153 return STOP;
154 }
155
156 if (action == CONTINUE) {
157 return CONTINUE;
81f2bb1f 158 }
a3437b8c 159
ae563542 160 if (revs.max_count != -1 && !revs.max_count--)
07f92477
LT
161 return STOP;
162
a3437b8c
JS
163 show_commit(commit);
164
165 return CONTINUE;
81f2bb1f
LT
166}
167
e646de0d
JH
168static struct object_list **process_blob(struct blob *blob,
169 struct object_list **p,
170 struct name_path *path,
171 const char *name)
9de48752
LT
172{
173 struct object *obj = &blob->object;
174
ae563542 175 if (!revs.blob_objects)
9de48752
LT
176 return p;
177 if (obj->flags & (UNINTERESTING | SEEN))
178 return p;
179 obj->flags |= SEEN;
e646de0d 180 return add_object(obj, p, path, name);
9de48752
LT
181}
182
e646de0d
JH
183static struct object_list **process_tree(struct tree *tree,
184 struct object_list **p,
185 struct name_path *path,
186 const char *name)
9de48752
LT
187{
188 struct object *obj = &tree->object;
189 struct tree_entry_list *entry;
e646de0d 190 struct name_path me;
9de48752 191
ae563542 192 if (!revs.tree_objects)
9de48752
LT
193 return p;
194 if (obj->flags & (UNINTERESTING | SEEN))
195 return p;
196 if (parse_tree(tree) < 0)
197 die("bad tree object %s", sha1_to_hex(obj->sha1));
198 obj->flags |= SEEN;
e646de0d
JH
199 p = add_object(obj, p, path, name);
200 me.up = path;
201 me.elem = name;
202 me.elem_len = strlen(name);
b0d8923e
LT
203 entry = tree->entries;
204 tree->entries = NULL;
205 while (entry) {
206 struct tree_entry_list *next = entry->next;
9de48752 207 if (entry->directory)
e646de0d 208 p = process_tree(entry->item.tree, p, &me, entry->name);
9de48752 209 else
e646de0d 210 p = process_blob(entry->item.blob, p, &me, entry->name);
b0d8923e
LT
211 free(entry);
212 entry = next;
9de48752
LT
213 }
214 return p;
215}
216
81f2bb1f
LT
217static void show_commit_list(struct commit_list *list)
218{
36f8d174 219 struct object_list *objects = NULL, **p = &objects, *pending;
81f2bb1f
LT
220 while (list) {
221 struct commit *commit = pop_most_recent_commit(&list, SEEN);
222
e646de0d 223 p = process_tree(commit->tree, p, NULL, "");
a3437b8c 224 if (process_commit(commit) == STOP)
81f2bb1f 225 break;
81f2bb1f 226 }
d9cfb964 227 for (pending = revs.pending_objects; pending; pending = pending->next) {
36f8d174
LT
228 struct object *obj = pending->item;
229 const char *name = pending->name;
230 if (obj->flags & (UNINTERESTING | SEEN))
231 continue;
232 if (obj->type == tag_type) {
233 obj->flags |= SEEN;
e646de0d 234 p = add_object(obj, p, NULL, name);
36f8d174
LT
235 continue;
236 }
237 if (obj->type == tree_type) {
e646de0d 238 p = process_tree((struct tree *)obj, p, NULL, name);
36f8d174
LT
239 continue;
240 }
241 if (obj->type == blob_type) {
e646de0d 242 p = process_blob((struct blob *)obj, p, NULL, name);
36f8d174
LT
243 continue;
244 }
245 die("unknown pending object %s (%s)", sha1_to_hex(obj->sha1), name);
246 }
9de48752 247 while (objects) {
50319850
JH
248 /* An object with name "foo\n0000000..." can be used to
249 * confuse downstream git-pack-objects very badly.
c807f771
JH
250 */
251 const char *ep = strchr(objects->name, '\n');
252 if (ep) {
253 printf("%s %.*s\n", sha1_to_hex(objects->item->sha1),
254 (int) (ep - objects->name),
255 objects->name);
256 }
257 else
258 printf("%s %s\n", sha1_to_hex(objects->item->sha1), objects->name);
9de48752
LT
259 objects = objects->next;
260 }
261}
262
4311d328 263static int everybody_uninteresting(struct commit_list *orig)
8906300f 264{
4311d328 265 struct commit_list *list = orig;
8906300f
LT
266 while (list) {
267 struct commit *commit = list->item;
268 list = list->next;
269 if (commit->object.flags & UNINTERESTING)
270 continue;
271 return 0;
272 }
273 return 1;
274}
275
8b3a1e05
LT
276/*
277 * This is a truly stupid algorithm, but it's only
278 * used for bisection, and we just don't care enough.
279 *
280 * We care just barely enough to avoid recursing for
281 * non-merge entries.
282 */
283static int count_distance(struct commit_list *entry)
284{
285 int nr = 0;
286
287 while (entry) {
288 struct commit *commit = entry->item;
289 struct commit_list *p;
290
291 if (commit->object.flags & (UNINTERESTING | COUNTED))
292 break;
ae563542 293 if (!revs.paths || (commit->object.flags & TREECHANGE))
b3cfd939 294 nr++;
8b3a1e05
LT
295 commit->object.flags |= COUNTED;
296 p = commit->parents;
297 entry = p;
298 if (p) {
299 p = p->next;
300 while (p) {
301 nr += count_distance(p);
302 p = p->next;
303 }
304 }
305 }
b3cfd939 306
8b3a1e05
LT
307 return nr;
308}
309
3d958064 310static void clear_distance(struct commit_list *list)
8b3a1e05
LT
311{
312 while (list) {
313 struct commit *commit = list->item;
314 commit->object.flags &= ~COUNTED;
315 list = list->next;
316 }
317}
318
319static struct commit_list *find_bisection(struct commit_list *list)
320{
321 int nr, closest;
322 struct commit_list *p, *best;
323
324 nr = 0;
325 p = list;
326 while (p) {
ae563542 327 if (!revs.paths || (p->item->object.flags & TREECHANGE))
b3cfd939 328 nr++;
8b3a1e05
LT
329 p = p->next;
330 }
331 closest = 0;
332 best = list;
333
b3cfd939
LT
334 for (p = list; p; p = p->next) {
335 int distance;
336
ae563542 337 if (revs.paths && !(p->item->object.flags & TREECHANGE))
b3cfd939
LT
338 continue;
339
340 distance = count_distance(p);
8b3a1e05
LT
341 clear_distance(list);
342 if (nr - distance < distance)
343 distance = nr - distance;
344 if (distance > closest) {
345 best = p;
346 closest = distance;
347 }
8b3a1e05
LT
348 }
349 if (best)
350 best->next = NULL;
351 return best;
352}
353
c6496575
JH
354static void mark_edge_parents_uninteresting(struct commit *commit)
355{
356 struct commit_list *parents;
357
358 for (parents = commit->parents; parents; parents = parents->next) {
359 struct commit *parent = parents->item;
360 if (!(parent->object.flags & UNINTERESTING))
361 continue;
362 mark_tree_uninteresting(parent->tree);
ae563542 363 if (revs.edge_hint && !(parent->object.flags & SHOWN)) {
eb38cc68 364 parent->object.flags |= SHOWN;
c6496575 365 printf("-%s\n", sha1_to_hex(parent->object.sha1));
eb38cc68 366 }
c6496575
JH
367 }
368}
369
5bdbaaa4
LT
370static void mark_edges_uninteresting(struct commit_list *list)
371{
372 for ( ; list; list = list->next) {
c6496575 373 struct commit *commit = list->item;
5bdbaaa4 374
c6496575
JH
375 if (commit->object.flags & UNINTERESTING) {
376 mark_tree_uninteresting(commit->tree);
377 continue;
5bdbaaa4 378 }
c6496575 379 mark_edge_parents_uninteresting(commit);
5bdbaaa4
LT
380 }
381}
382
461cf59f
LT
383#define TREE_SAME 0
384#define TREE_NEW 1
385#define TREE_DIFFERENT 2
386static int tree_difference = TREE_SAME;
cf484544
LT
387
388static void file_add_remove(struct diff_options *options,
389 int addremove, unsigned mode,
390 const unsigned char *sha1,
391 const char *base, const char *path)
392{
461cf59f
LT
393 int diff = TREE_DIFFERENT;
394
395 /*
396 * Is it an add of a new file? It means that
397 * the old tree didn't have it at all, so we
398 * will turn "TREE_SAME" -> "TREE_NEW", but
399 * leave any "TREE_DIFFERENT" alone (and if
400 * it already was "TREE_NEW", we'll keep it
401 * "TREE_NEW" of course).
402 */
403 if (addremove == '+') {
404 diff = tree_difference;
405 if (diff != TREE_SAME)
406 return;
407 diff = TREE_NEW;
408 }
409 tree_difference = diff;
cf484544
LT
410}
411
412static void file_change(struct diff_options *options,
413 unsigned old_mode, unsigned new_mode,
414 const unsigned char *old_sha1,
415 const unsigned char *new_sha1,
416 const char *base, const char *path)
417{
461cf59f 418 tree_difference = TREE_DIFFERENT;
cf484544
LT
419}
420
421static struct diff_options diff_opt = {
422 .recursive = 1,
423 .add_remove = file_add_remove,
424 .change = file_change,
425};
426
461cf59f 427static int compare_tree(struct tree *t1, struct tree *t2)
1b9e059d 428{
461cf59f
LT
429 if (!t1)
430 return TREE_NEW;
431 if (!t2)
432 return TREE_DIFFERENT;
433 tree_difference = TREE_SAME;
1b9e059d 434 if (diff_tree_sha1(t1->object.sha1, t2->object.sha1, "", &diff_opt) < 0)
461cf59f
LT
435 return TREE_DIFFERENT;
436 return tree_difference;
1b9e059d
LT
437}
438
129adf4d
LT
439static int same_tree_as_empty(struct tree *t1)
440{
441 int retval;
442 void *tree;
443 struct tree_desc empty, real;
444
445 if (!t1)
446 return 0;
447
448 tree = read_object_with_reference(t1->object.sha1, "tree", &real.size, NULL);
449 if (!tree)
450 return 0;
451 real.buf = tree;
452
453 empty.buf = "";
454 empty.size = 0;
455
461cf59f 456 tree_difference = 0;
129adf4d
LT
457 retval = diff_tree(&empty, &real, "", &diff_opt);
458 free(tree);
459
461cf59f 460 return retval >= 0 && !tree_difference;
129adf4d
LT
461}
462
461cf59f 463static void try_to_simplify_commit(struct commit *commit)
cf484544 464{
461cf59f
LT
465 struct commit_list **pp, *parent;
466
cf484544 467 if (!commit->tree)
461cf59f 468 return;
cf484544 469
461cf59f
LT
470 if (!commit->parents) {
471 if (!same_tree_as_empty(commit->tree))
472 commit->object.flags |= TREECHANGE;
473 return;
474 }
475
476 pp = &commit->parents;
477 while ((parent = *pp) != NULL) {
cf484544 478 struct commit *p = parent->item;
461cf59f
LT
479
480 if (p->object.flags & UNINTERESTING) {
481 pp = &parent->next;
482 continue;
483 }
484
cf484544 485 parse_commit(p);
461cf59f
LT
486 switch (compare_tree(p->tree, commit->tree)) {
487 case TREE_SAME:
488 parent->next = NULL;
489 commit->parents = parent;
490 return;
491
492 case TREE_NEW:
ae563542 493 if (revs.remove_empty_trees && same_tree_as_empty(p->tree)) {
461cf59f
LT
494 *pp = parent->next;
495 continue;
496 }
497 /* fallthrough */
498 case TREE_DIFFERENT:
499 pp = &parent->next;
cf484544 500 continue;
461cf59f
LT
501 }
502 die("bad tree compare for commit %s", sha1_to_hex(commit->object.sha1));
cf484544 503 }
461cf59f 504 commit->object.flags |= TREECHANGE;
cf484544
LT
505}
506
507static void add_parents_to_list(struct commit *commit, struct commit_list **list)
508{
509 struct commit_list *parent = commit->parents;
510
511 /*
512 * If the commit is uninteresting, don't try to
513 * prune parents - we want the maximal uninteresting
514 * set.
515 *
516 * Normally we haven't parsed the parent
517 * yet, so we won't have a parent of a parent
518 * here. However, it may turn out that we've
519 * reached this commit some other way (where it
520 * wasn't uninteresting), in which case we need
521 * to mark its parents recursively too..
522 */
523 if (commit->object.flags & UNINTERESTING) {
524 while (parent) {
525 struct commit *p = parent->item;
526 parent = parent->next;
527 parse_commit(p);
528 p->object.flags |= UNINTERESTING;
529 if (p->parents)
530 mark_parents_uninteresting(p);
531 if (p->object.flags & SEEN)
532 continue;
533 p->object.flags |= SEEN;
534 insert_by_date(p, list);
535 }
536 return;
537 }
538
539 /*
461cf59f
LT
540 * Ok, the commit wasn't uninteresting. Try to
541 * simplify the commit history and find the parent
542 * that has no differences in the path set if one exists.
cf484544 543 */
ae563542 544 if (revs.paths)
461cf59f 545 try_to_simplify_commit(commit);
cf484544 546
461cf59f 547 parent = commit->parents;
cf484544
LT
548 while (parent) {
549 struct commit *p = parent->item;
550
551 parent = parent->next;
552
553 parse_commit(p);
554 if (p->object.flags & SEEN)
555 continue;
556 p->object.flags |= SEEN;
557 insert_by_date(p, list);
558 }
559}
560
6da4016a 561static struct commit_list *limit_list(struct commit_list *list)
3b42a63c
LT
562{
563 struct commit_list *newlist = NULL;
564 struct commit_list **p = &newlist;
36f8d174 565 while (list) {
cf484544
LT
566 struct commit_list *entry = list;
567 struct commit *commit = list->item;
3b42a63c
LT
568 struct object *obj = &commit->object;
569
cf484544
LT
570 list = list->next;
571 free(entry);
572
ae563542 573 if (revs.max_age != -1 && (commit->date < revs.max_age))
27cfe2e2 574 obj->flags |= UNINTERESTING;
12d2a187
LT
575 if (unpacked && has_sha1_pack(obj->sha1))
576 obj->flags |= UNINTERESTING;
cf484544 577 add_parents_to_list(commit, &list);
337cb3fb 578 if (obj->flags & UNINTERESTING) {
3b42a63c
LT
579 mark_parents_uninteresting(commit);
580 if (everybody_uninteresting(list))
581 break;
582 continue;
583 }
ae563542 584 if (revs.min_age != -1 && (commit->date > revs.min_age))
27cfe2e2 585 continue;
3b42a63c 586 p = &commit_list_insert(commit, p)->next;
36f8d174 587 }
ae563542 588 if (revs.tree_objects)
5bdbaaa4 589 mark_edges_uninteresting(newlist);
8b3a1e05
LT
590 if (bisect_list)
591 newlist = find_bisection(newlist);
3b42a63c
LT
592 return newlist;
593}
594
cf484544 595int main(int argc, const char **argv)
64745109 596{
ae563542 597 struct commit_list *list;
337cb3fb 598 int i, limited = 0;
64745109 599
ae563542
LT
600 argc = setup_revisions(argc, argv, &revs);
601
fcfda02b 602 for (i = 1 ; i < argc; i++) {
cf484544 603 const char *arg = argv[i];
fcfda02b 604
8233340c
EW
605 /* accept -<digit>, like traditilnal "head" */
606 if ((*arg == '-') && isdigit(arg[1])) {
ae563542 607 revs.max_count = atoi(arg + 1);
8233340c
EW
608 continue;
609 }
3af06987
EW
610 if (!strcmp(arg, "-n")) {
611 if (++i >= argc)
612 die("-n requires an argument");
ae563542 613 revs.max_count = atoi(argv[i]);
3af06987
EW
614 continue;
615 }
616 if (!strncmp(arg,"-n",2)) {
ae563542 617 revs.max_count = atoi(arg + 2);
a6f68d47 618 continue;
fcfda02b 619 }
a6f68d47
LT
620 if (!strcmp(arg, "--header")) {
621 verbose_header = 1;
622 continue;
623 }
9da5c2f0
JH
624 if (!strcmp(arg, "--no-abbrev")) {
625 abbrev = 0;
626 continue;
627 }
628 if (!strncmp(arg, "--abbrev=", 9)) {
629 abbrev = strtoul(arg + 9, NULL, 10);
630 if (abbrev && abbrev < MINIMUM_ABBREV)
631 abbrev = MINIMUM_ABBREV;
632 else if (40 < abbrev)
633 abbrev = 40;
634 continue;
635 }
000182ea
LT
636 if (!strncmp(arg, "--pretty", 8)) {
637 commit_format = get_commit_format(arg+8);
9d97aa64 638 verbose_header = 1;
9d97aa64 639 hdr_termination = '\n';
d87449c5 640 if (commit_format == CMIT_FMT_ONELINE)
d998a089 641 commit_prefix = "";
d87449c5 642 else
d998a089 643 commit_prefix = "commit ";
9d97aa64
LT
644 continue;
645 }
76cd8eb6
JS
646 if (!strncmp(arg, "--no-merges", 11)) {
647 no_merges = 1;
648 continue;
649 }
97658004
LT
650 if (!strcmp(arg, "--parents")) {
651 show_parents = 1;
652 continue;
653 }
8b3a1e05
LT
654 if (!strcmp(arg, "--bisect")) {
655 bisect_list = 1;
656 continue;
657 }
12d2a187
LT
658 if (!strcmp(arg, "--unpacked")) {
659 unpacked = 1;
660 limited = 1;
661 continue;
662 }
12ba7eaf 663 if (!strcmp(arg, "--merge-order")) {
a3437b8c
JS
664 merge_order = 1;
665 continue;
666 }
12ba7eaf 667 if (!strcmp(arg, "--show-breaks")) {
a3437b8c
JS
668 show_breaks = 1;
669 continue;
670 }
ae563542 671 usage(rev_list_usage);
a6f68d47 672
fcfda02b
KS
673 }
674
ae563542 675 list = revs.commits;
d9cfb964 676 if (list)
ae563542
LT
677 limited = 1;
678
679 if (revs.topo_order)
680 limited = 1;
681
ef1cc2cc 682 if (!list &&
ae563542 683 (!(revs.tag_objects||revs.tree_objects||revs.blob_objects) && !revs.pending_objects))
7b34c2fa
LT
684 usage(rev_list_usage);
685
ae563542 686 if (revs.paths) {
7b34c2fa 687 limited = 1;
ae563542 688 diff_tree_setup_paths(revs.paths);
7b34c2fa 689 }
d9cfb964 690 if (revs.max_age != -1 || revs.min_age != -1)
ae563542 691 limited = 1;
7b34c2fa 692
60ab26de 693 save_commit_buffer = verbose_header;
8805ccac 694 track_object_refs = 0;
60ab26de 695
a3437b8c 696 if (!merge_order) {
a7336ae5 697 sort_by_date(&list);
ae563542
LT
698 if (list && !limited && revs.max_count == 1 &&
699 !revs.tag_objects && !revs.tree_objects && !revs.blob_objects) {
fe5f51ce
LT
700 show_commit(list->item);
701 return 0;
702 }
17ebe977 703 if (limited)
a3437b8c 704 list = limit_list(list);
ae563542
LT
705 if (revs.topo_order)
706 sort_in_topological_order(&list, revs.lifo);
a3437b8c 707 show_commit_list(list);
a3437b8c 708 } else {
dd53c7ab 709#ifndef NO_OPENSSL
a3437b8c 710 if (sort_list_in_merge_order(list, &process_commit)) {
dd53c7ab 711 die("merge order sort failed\n");
a3437b8c 712 }
dd53c7ab
PB
713#else
714 die("merge order sort unsupported, OpenSSL not linked");
715#endif
a3437b8c 716 }
8906300f 717
64745109
LT
718 return 0;
719}