Commit 51fc5e89 by Carlos Martín Nieto

Make sure the ref iterator works in an repo without physical presence

parent 69a3c766
......@@ -128,7 +128,11 @@ int git_refdb_iterator(git_reference_iterator **out, git_refdb *db)
{
git_reference_iterator *iter;
/* FIXME: don't segfault when there is no backends */
if (!db->backend || !db->backend->iterator) {
giterr_set(GITERR_REFERENCE, "This backend doesn't support iterators");
return -1;
}
if (db->backend->iterator(&iter, db->backend) < 0) {
git__free(iter);
return -1;
......
......@@ -74,3 +74,21 @@ void test_refs_iterator__list(void)
}
git_vector_free(&output);
}
void test_refs_iterator__empty(void)
{
git_reference_iterator *iter;
git_odb *odb;
const char *name;
git_repository *empty;
cl_git_pass(git_odb_new(&odb));
cl_git_pass(git_repository_wrap_odb(&empty, odb));
cl_git_pass(git_reference_iterator_new(&iter, empty));
cl_assert_equal_i(GIT_ITEROVER, git_reference_next(&name, iter));
git_reference_iterator_free(iter);
git_odb_free(odb);
git_repository_free(empty);
}
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