Merge branch 'jk/revision-walk-stop-at-max-count'
"git log -n 1 -- rarely-touched-path" was spending unnecessary cycles after showing the first change to find the next one, only to discard it. * jk/revision-walk-stop-at-max-count: revision: avoid work after --max-count is reached
This commit is contained in:
commit
d05e56ea67
39
revision.c
39
revision.c
@ -2369,29 +2369,28 @@ static struct commit *get_revision_internal(struct rev_info *revs)
|
||||
}
|
||||
|
||||
/*
|
||||
* Now pick up what they want to give us
|
||||
* If our max_count counter has reached zero, then we are done. We
|
||||
* don't simply return NULL because we still might need to show
|
||||
* boundary commits. But we want to avoid calling get_revision_1, which
|
||||
* might do a considerable amount of work finding the next commit only
|
||||
* for us to throw it away.
|
||||
*
|
||||
* If it is non-zero, then either we don't have a max_count at all
|
||||
* (-1), or it is still counting, in which case we decrement.
|
||||
*/
|
||||
c = get_revision_1(revs);
|
||||
if (c) {
|
||||
while (0 < revs->skip_count) {
|
||||
revs->skip_count--;
|
||||
c = get_revision_1(revs);
|
||||
if (!c)
|
||||
break;
|
||||
if (revs->max_count) {
|
||||
c = get_revision_1(revs);
|
||||
if (c) {
|
||||
while (0 < revs->skip_count) {
|
||||
revs->skip_count--;
|
||||
c = get_revision_1(revs);
|
||||
if (!c)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check the max_count.
|
||||
*/
|
||||
switch (revs->max_count) {
|
||||
case -1:
|
||||
break;
|
||||
case 0:
|
||||
c = NULL;
|
||||
break;
|
||||
default:
|
||||
revs->max_count--;
|
||||
if (revs->max_count > 0)
|
||||
revs->max_count--;
|
||||
}
|
||||
|
||||
if (c)
|
||||
|
Loading…
Reference in New Issue
Block a user