summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2012-09-28 11:48:43 -0700
committerVicent Martí <vicent@github.com>2012-09-28 11:48:43 -0700
commit3f849902e4b20216c80ec69714d6a6a0fdd332d2 (patch)
tree39adbaae7a8ad316473b4e7de1f825ec42bfaa1a
parentb55fd885fccc788c07c81990a9283e6ea05858a7 (diff)
parent8060cdc93cc185e9a71c1aa17091dc0a5ab14457 (diff)
downloadlibgit2-3f849902e4b20216c80ec69714d6a6a0fdd332d2.tar.gz
Merge pull request #958 from schu/fix-merge-base
revwalk: fix off-by-one error
-rw-r--r--src/revwalk.c3
-rw-r--r--tests-clar/odb/foreach.c2
-rw-r--r--tests-clar/resources/testrepo.git/objects/1a/443023183e3f2bfbef8ac923cd81c1018a18fdbin0 -> 122 bytes
-rw-r--r--tests-clar/resources/testrepo.git/objects/9f/13f7d0a9402c681f91dc590cf7b5470e6a77d22
-rw-r--r--tests-clar/resources/testrepo.git/objects/fd/4959ce7510db09d4d8217fa2d1780413e05a09bin0 -> 152 bytes
-rw-r--r--tests-clar/revwalk/mergebase.c9
6 files changed, 14 insertions, 2 deletions
diff --git a/src/revwalk.c b/src/revwalk.c
index 8141d177b..4fff238ca 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -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;
diff --git a/tests-clar/odb/foreach.c b/tests-clar/odb/foreach.c
index c1304a2e4..bf52cc1b5 100644
--- a/tests-clar/odb/foreach.c
+++ b/tests-clar/odb/foreach.c
@@ -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)
diff --git a/tests-clar/resources/testrepo.git/objects/1a/443023183e3f2bfbef8ac923cd81c1018a18fd b/tests-clar/resources/testrepo.git/objects/1a/443023183e3f2bfbef8ac923cd81c1018a18fd
new file mode 100644
index 000000000..3ec541288
--- /dev/null
+++ b/tests-clar/resources/testrepo.git/objects/1a/443023183e3f2bfbef8ac923cd81c1018a18fd
Binary files differ
diff --git a/tests-clar/resources/testrepo.git/objects/9f/13f7d0a9402c681f91dc590cf7b5470e6a77d2 b/tests-clar/resources/testrepo.git/objects/9f/13f7d0a9402c681f91dc590cf7b5470e6a77d2
new file mode 100644
index 000000000..7f1cfb23c
--- /dev/null
+++ b/tests-clar/resources/testrepo.git/objects/9f/13f7d0a9402c681f91dc590cf7b5470e6a77d2
@@ -0,0 +1,2 @@
+xM
+0F]d2<A~&`Vmҡ7U$JL9yM!GuH&U>;XEȎ5R AE &n}Z<E}=O[Ӽ^,^#ɿ]P`>A \ No newline at end of file
diff --git a/tests-clar/resources/testrepo.git/objects/fd/4959ce7510db09d4d8217fa2d1780413e05a09 b/tests-clar/resources/testrepo.git/objects/fd/4959ce7510db09d4d8217fa2d1780413e05a09
new file mode 100644
index 000000000..158aef21f
--- /dev/null
+++ b/tests-clar/resources/testrepo.git/objects/fd/4959ce7510db09d4d8217fa2d1780413e05a09
Binary files differ
diff --git a/tests-clar/revwalk/mergebase.c b/tests-clar/revwalk/mergebase.c
index a210c1ff2..84349010a 100644
--- a/tests-clar/revwalk/mergebase.c
+++ b/tests-clar/revwalk/mergebase.c
@@ -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;