Commit 8060cdc9 by Michael Schubert

revwalk: fix off-by-one error

Fixes #921.
parent 5942bd18
......@@ -274,7 +274,8 @@ static int commit_parse(git_revwalk *walk, commit_object *commit)
static int interesting(git_pqueue *list)
{
unsigned int i;
for (i = 1; i < git_pqueue_size(list); i++) {
/* element 0 isn't used - we need to start at 1 */
for (i = 1; i < list->size; i++) {
commit_object *commit = list->d[i];
if ((commit->flags & STALE) == 0)
return 1;
......
......@@ -42,7 +42,7 @@ void test_odb_foreach__foreach(void)
git_repository_odb(&_odb, _repo);
cl_git_pass(git_odb_foreach(_odb, foreach_cb, NULL));
cl_assert_equal_i(43 + 1640, nobj); /* count + in-pack */
cl_assert_equal_i(46 + 1640, nobj); /* count + in-pack */
}
void test_odb_foreach__one_pack(void)
......
......@@ -67,6 +67,15 @@ void test_revwalk_mergebase__no_common_ancestor_returns_ENOTFOUND(void)
cl_assert_equal_i(GIT_ENOTFOUND, error);
}
void test_revwalk_mergebase__no_off_by_one_missing(void)
{
git_oid result, one, two;
cl_git_pass(git_oid_fromstr(&one, "1a443023183e3f2bfbef8ac923cd81c1018a18fd"));
cl_git_pass(git_oid_fromstr(&two, "9f13f7d0a9402c681f91dc590cf7b5470e6a77d2"));
cl_git_pass(git_merge_base(&result, _repo, &one, &two));
}
static void assert_mergebase_many(const char *expected_sha, int count, ...)
{
va_list ap;
......
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