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:
authorCarlos Martín Nieto <cmn@dwim.me>2014-05-05 18:04:14 +0400
committerCarlos Martín Nieto <cmn@dwim.me>2014-05-05 18:34:18 +0400
commitee311907ee0299ff2c1d7fc37699dc3e4da20c52 (patch)
treecd26f69937032be089e836f9c35e55ed7df7feea /tests/odb/foreach.c
parentd2c16e9ac4921e94eb5db972e6b8452d71a623fc (diff)
odb: ignore files in the objects dir
We assume that everything under GIT_DIR/objects/ is a directory. This is not necessarily the case if some process left a stray file in there. Check beforehand if we do have a directory and ignore the entry otherwise.
Diffstat (limited to 'tests/odb/foreach.c')
-rw-r--r--tests/odb/foreach.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/odb/foreach.c b/tests/odb/foreach.c
index 256ae9cd7..ab3808b00 100644
--- a/tests/odb/foreach.c
+++ b/tests/odb/foreach.c
@@ -2,6 +2,7 @@
#include "odb.h"
#include "git2/odb_backend.h"
#include "pack.h"
+#include "buffer.h"
static git_odb *_odb;
static git_repository *_repo;
@@ -80,3 +81,26 @@ void test_odb_foreach__interrupt_foreach(void)
cl_assert_equal_i(-321, git_odb_foreach(_odb, foreach_stop_cb, &nobj));
cl_assert(nobj == 1000);
}
+
+void test_odb_foreach__files_in_objects_dir(void)
+{
+ git_repository *repo;
+ git_odb *odb;
+ git_buf buf = GIT_BUF_INIT;
+ size_t nobj = 0;
+
+ cl_fixture_sandbox("testrepo.git");
+ cl_git_pass(git_repository_open(&repo, "testrepo.git"));
+
+ cl_git_pass(git_buf_printf(&buf, "%s/objects/somefile", git_repository_path(repo)));
+
+ cl_git_mkfile(buf.ptr, "");
+
+ cl_git_pass(git_repository_odb(&odb, repo));
+ cl_git_pass(git_odb_foreach(odb, foreach_cb, &nobj));
+ cl_assert_equal_i(47 + 1640, nobj); /* count + in-pack */
+
+ git_odb_free(odb);
+ git_repository_free(repo);
+ cl_fixture_cleanup("testrepo.git");
+}