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;
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));
}
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));