Skip to content

Commit

Permalink
get_revision(): do not dig deeper when we know we are at the end.
Browse files Browse the repository at this point in the history
This resurrects the special casing for "rev-list -n 1" which
avoided reading parents unnecessarily.

Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Linus Torvalds authored and Junio C Hamano committed Mar 5, 2006
1 parent 872d001 commit ea5ed3a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,13 +684,11 @@ static void rewrite_parents(struct commit *commit)
struct commit *get_revision(struct rev_info *revs)
{
struct commit_list *list = revs->commits;
struct commit *commit;

if (!list)
return NULL;

/* Check the max_count ... */
commit = list->item;
switch (revs->max_count) {
case -1:
break;
Expand All @@ -701,22 +699,28 @@ struct commit *get_revision(struct rev_info *revs)
}

do {
commit = pop_most_recent_commit(&revs->commits, SEEN);
struct commit *commit = revs->commits->item;

if (commit->object.flags & (UNINTERESTING|SHOWN))
continue;
goto next;
if (revs->min_age != -1 && (commit->date > revs->min_age))
continue;
goto next;
if (revs->max_age != -1 && (commit->date < revs->max_age))
return NULL;
if (revs->no_merges && commit->parents && commit->parents->next)
continue;
goto next;
if (revs->paths && revs->dense) {
if (!(commit->object.flags & TREECHANGE))
continue;
goto next;
rewrite_parents(commit);
}
/* More to go? */
if (revs->max_count)
pop_most_recent_commit(&revs->commits, SEEN);
commit->object.flags |= SHOWN;
return commit;
next:
pop_most_recent_commit(&revs->commits, SEEN);
} while (revs->commits);
return NULL;
}

0 comments on commit ea5ed3a

Please sign in to comment.