Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-05-11 17:42:25 +0400
committerRussell Belfer <rb@github.com>2013-05-11 17:42:25 +0400
commit99d32707b963e6fea16817cafd5c3f579578a262 (patch)
tree3596036b3570e8c8784cfe5ebb4d496631c5e33c /tests-clar/refs
parent7b5bc8f498cd4f05f8580d848c03188dc5b06811 (diff)
Fix refdb iteration early termination bug
There was a problem found in the Rugged test suite where the refdb_fs_backend__next function could exit too early in some very specific hashing patterns for packed refs. This ports the Rugged test to libgit2 and then fixes the bug.
Diffstat (limited to 'tests-clar/refs')
-rw-r--r--tests-clar/refs/branches/foreach.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/tests-clar/refs/branches/foreach.c b/tests-clar/refs/branches/foreach.c
index 96a5bc2b9..57f9c0e39 100644
--- a/tests-clar/refs/branches/foreach.c
+++ b/tests-clar/refs/branches/foreach.c
@@ -24,6 +24,8 @@ void test_refs_branches_foreach__cleanup(void)
repo = NULL;
cl_fixture_cleanup("testrepo.git");
+
+ cl_git_sandbox_cleanup();
}
static int count_branch_list_cb(const char *branch_name, git_branch_t branch_type, void *payload)
@@ -72,14 +74,11 @@ static void assert_branch_has_been_found(struct expectations *findings, const ch
{
int pos = 0;
- while (findings[pos].branch_name)
- {
+ for (pos = 0; findings[pos].branch_name; ++pos) {
if (strcmp(expected_branch_name, findings[pos].branch_name) == 0) {
cl_assert_equal_i(1, findings[pos].encounters);
return;
}
-
- pos++;
}
cl_fail("expected branch not found in list.");
@@ -94,12 +93,9 @@ static int contains_branch_list_cb(const char *branch_name, git_branch_t branch_
exp = (struct expectations *)payload;
- while (exp[pos].branch_name)
- {
+ for (pos = 0; exp[pos].branch_name; ++pos) {
if (strcmp(branch_name, exp[pos].branch_name) == 0)
exp[pos].encounters++;
-
- pos++;
}
return 0;
@@ -153,3 +149,25 @@ void test_refs_branches_foreach__can_cancel(void)
cl_assert_equal_i(5, count);
}
+
+void test_refs_branches_foreach__mix_of_packed_and_loose(void)
+{
+ struct expectations exp[] = {
+ { "master", 0 },
+ { "origin/HEAD", 0 },
+ { "origin/master", 0 },
+ { "origin/packed", 0 },
+ { NULL, 0 }
+ };
+ git_repository *r2;
+
+ r2 = cl_git_sandbox_init("testrepo2");
+
+ cl_git_pass(git_branch_foreach(r2, GIT_BRANCH_LOCAL | GIT_BRANCH_REMOTE,
+ contains_branch_list_cb, &exp));
+
+ assert_branch_has_been_found(exp, "master");
+ assert_branch_has_been_found(exp, "origin/HEAD");
+ assert_branch_has_been_found(exp, "origin/master");
+ assert_branch_has_been_found(exp, "origin/packed");
+}