mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-27 22:41:37 +00:00
Make sure the ref iterator works in an repo without physical presence
This commit is contained in:
parent
69a3c766b6
commit
51fc5e895d
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user