diff options
author | Carlos Martín Nieto <cmn@elego.de> | 2012-06-05 16:48:51 +0400 |
---|---|---|
committer | Carlos Martín Nieto <carlos@cmartin.tk> | 2012-07-03 14:50:51 +0400 |
commit | 521aedad307c6f72d6f6d660943508b2b015f6dd (patch) | |
tree | aef33032b13ca170a3d7a016e7e8522a7635ce6f /tests-clar/odb | |
parent | e560aa8ffa7cf143fbd34a5aec44741ae4c77271 (diff) |
odb: add git_odb_foreach()
Go through each backend and list every objects that exists in
them. This allows fsck-like uses.
Diffstat (limited to 'tests-clar/odb')
-rw-r--r-- | tests-clar/odb/foreach.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests-clar/odb/foreach.c b/tests-clar/odb/foreach.c new file mode 100644 index 000000000..6cb4faad2 --- /dev/null +++ b/tests-clar/odb/foreach.c @@ -0,0 +1,36 @@ +#include "clar_libgit2.h" +#include "odb.h" +#include "git2/odb_backend.h" +#include "pack.h" + +static git_odb *_odb; +static git_repository *_repo; +static int nobj; + +void test_odb_foreach__initialize(void) +{ + cl_git_pass(git_repository_open(&_repo, cl_fixture("testrepo.git"))); + git_repository_odb(&_odb, _repo); +} + +void test_odb_foreach__cleanup(void) +{ + git_odb_free(_odb); + git_repository_free(_repo); +} + +static int foreach_cb(git_oid *oid, void *data) +{ + GIT_UNUSED(data); + GIT_UNUSED(oid); + + nobj++; + + return 0; +} + +void test_odb_foreach__foreach(void) +{ + cl_git_pass(git_odb_foreach(_odb, foreach_cb, NULL)); + cl_assert(nobj == 1681); +} |