| 4657 | } |
| 4658 | |
| 4659 | struct commit *get_revision(struct rev_info *revs) |
| 4660 | { |
| 4661 | struct commit *c; |
| 4662 | struct commit_list *reversed; |
| 4663 | struct commit_list *queue = NULL; |
| 4664 | struct commit_list *p; |
| 4665 | |
| 4666 | if (revs->max_count_type == 1 && !revs->max_count_stage) { |
| 4667 | retrieve_oldest_commits(revs, &queue); |
| 4668 | commit_list_free(revs->commits); |
| 4669 | revs->commits = queue; |
| 4670 | revs->max_count_stage = 1; |
| 4671 | } |
| 4672 | |
| 4673 | if (revs->reverse) { |
| 4674 | reversed = NULL; |
| 4675 | if (revs->max_count_type == 1) |
| 4676 | while ((c = pop_commit(&revs->commits))) |
| 4677 | commit_list_insert(c, &reversed); |
| 4678 | else |
| 4679 | while ((c = get_revision_internal(revs))) |
| 4680 | commit_list_insert(c, &reversed); |
| 4681 | commit_list_free(revs->commits); |
| 4682 | revs->commits = reversed; |
| 4683 | revs->reverse = 0; |
| 4684 | revs->reverse_output_stage = 1; |
| 4685 | } |
| 4686 | |
| 4687 | if (revs->reverse_output_stage) { |
| 4688 | c = pop_commit(&revs->commits); |
| 4689 | if (revs->track_linear) |
| 4690 | revs->linear = !!(c && c->object.flags & TRACK_LINEAR); |
| 4691 | return c; |
| 4692 | } |
| 4693 | |
| 4694 | if (revs->max_count_stage) { |
| 4695 | c = pop_commit(&revs->commits); |
| 4696 | if (c) { |
| 4697 | c->object.flags |= SHOWN; |
| 4698 | if (!(c->object.flags & BOUNDARY)) |
| 4699 | for (p = c->parents; p; p = p->next) |
| 4700 | p->item->object.flags |= CHILD_SHOWN; |
| 4701 | } |
| 4702 | } else { |
| 4703 | c = get_revision_internal(revs); |
| 4704 | } |
| 4705 | |
| 4706 | if (c && revs->graph) |
| 4707 | graph_update(revs->graph, c); |
| 4708 | if (!c) { |
| 4709 | free_saved_parents(revs); |
| 4710 | commit_list_free(revs->previous_parents); |
| 4711 | revs->previous_parents = NULL; |
| 4712 | } |
| 4713 | return c; |
| 4714 | } |
| 4715 | |
| 4716 | const char *get_revision_mark(const struct rev_info *revs, const struct commit *commit) |