]> git.proxmox.com Git - libgit2.git/blobdiff - tests/odb/foreach.c
New upstream version 1.3.0+dfsg.1
[libgit2.git] / tests / odb / foreach.c
index 42d706467ebacfed397922a808df4563d2535df4..02112380b80424efcf4bae4973e0af712b5b48f7 100644 (file)
@@ -81,6 +81,16 @@ static int foreach_stop_first_cb(const git_oid *oid, void *data)
        return -123;
 }
 
+static int foreach_stop_cb_positive_ret(const git_oid *oid, void *data)
+{
+       int *nobj = data;
+       (*nobj)++;
+
+       GIT_UNUSED(oid);
+
+       return (*nobj == 1000) ? 321 : 0;
+}
+
 void test_odb_foreach__interrupt_foreach(void)
 {
        int nobj = 0;
@@ -92,13 +102,18 @@ void test_odb_foreach__interrupt_foreach(void)
        cl_assert_equal_i(-321, git_odb_foreach(_odb, foreach_stop_cb, &nobj));
        cl_assert(nobj == 1000);
 
+       nobj = 0;
+
+       cl_assert_equal_i(321, git_odb_foreach(_odb, foreach_stop_cb_positive_ret, &nobj));
+       cl_assert(nobj == 1000);
+
        git_odb_free(_odb);
        git_repository_free(_repo);
 
        cl_git_pass(git_repository_init(&_repo, "onlyloose.git", true));
        git_repository_odb(&_odb, _repo);
 
-       cl_git_pass(git_odb_write(&id, _odb, "", 0, GIT_OBJ_BLOB));
+       cl_git_pass(git_odb_write(&id, _odb, "", 0, GIT_OBJECT_BLOB));
        cl_assert_equal_i(-123, git_odb_foreach(_odb, foreach_stop_first_cb, &nobj));
 }
 
@@ -112,9 +127,9 @@ void test_odb_foreach__files_in_objects_dir(void)
        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_pass(git_buf_joinpath(&buf, git_repository_path(repo), "objects/somefile"));
        cl_git_mkfile(buf.ptr, "");
-       git_buf_free(&buf);
+       git_buf_dispose(&buf);
 
        cl_git_pass(git_repository_odb(&odb, repo));
        cl_git_pass(git_odb_foreach(odb, foreach_cb, &nobj));