Commit 98e484b9 by Carlos Martín Nieto

revwalk: detect when we're out of interesting commits

When walking backwards and marking parents uninteresting, make sure we
detect when the list of commits we have left has run out of
uninteresting commits so we can stop marking commits as
uninteresting. Failing to do so can mean that we walk the whole history
marking everything uninteresting, which eats up time, CPU and IO for
with useless work.

While pre-marking does look for this, we still need to check during the
main traversal as there are setups for which pre-marking does not leave
enough information in the commits. This can happen if we push a commit
and hide its parent.
parent 04162eb1
......@@ -39,11 +39,31 @@ git_commit_list_node *git_revwalk__commit_lookup(
return commit;
}
typedef git_array_t(git_commit_list_node*) commit_list_node_array;
static bool interesting_arr(commit_list_node_array arr)
{
git_commit_list_node **n;
size_t i = 0, size;
size = git_array_size(arr);
for (i = 0; i < size; i++) {
n = git_array_get(arr, i);
if (!*n)
break;
if (!(*n)->uninteresting)
return true;
}
return false;
}
static int mark_uninteresting(git_revwalk *walk, git_commit_list_node *commit)
{
int error;
unsigned short i;
git_array_t(git_commit_list_node *) pending = GIT_ARRAY_INIT;
commit_list_node_array pending = GIT_ARRAY_INIT;
git_commit_list_node **tmp;
assert(commit);
......@@ -64,7 +84,7 @@ static int mark_uninteresting(git_revwalk *walk, git_commit_list_node *commit)
tmp = git_array_pop(pending);
commit = tmp ? *tmp : NULL;
} while (commit != NULL);
} while (commit != NULL && !interesting_arr(pending));
git_array_clear(pending);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment