Skip to content

Commit

Permalink
revwalk: return GIT_EREVWALKER earlier if no references were pushed
Browse files Browse the repository at this point in the history
In the case that walk->one is NULL, we know that we have no positive
references, so we already know that the revwalk is over.
  • Loading branch information
carlosmn committed Apr 16, 2012
1 parent 05e0ab0 commit c33f54b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/revwalk.c
Expand Up @@ -697,6 +697,13 @@ static int prepare_walk(git_revwalk *walk)
commit_object *next, *two; commit_object *next, *two;
commit_list *bases = NULL; commit_list *bases = NULL;


/*
* If walk->one is NULL, there were no positive references,
* so we know that the walk is already over.
*/
if (walk->one == NULL)
return GIT_EREVWALKOVER;

/* first figure out what the merge bases are */ /* first figure out what the merge bases are */
if (merge_bases_many(&bases, walk, walk->one, &walk->twos) < 0) if (merge_bases_many(&bases, walk, walk->one, &walk->twos) < 0)
return -1; return -1;
Expand Down Expand Up @@ -849,7 +856,7 @@ int git_revwalk_next(git_oid *oid, git_revwalk *walk)


if (!walk->walking) { if (!walk->walking) {
if ((error = prepare_walk(walk)) < 0) if ((error = prepare_walk(walk)) < 0)
return -1; return error;
} }


error = walk->get_next(&next, walk); error = walk->get_next(&next, walk);
Expand Down

0 comments on commit c33f54b

Please sign in to comment.