Commit 48273490 by Edward Thomson

shallow: use GIT_ASSERT (not assert)

parent 6cec01b4
......@@ -75,7 +75,8 @@ void git_grafts_clear(git_grafts *grafts)
{
git_commit_graft *graft;
assert(grafts);
if (!grafts)
return;
git_oidmap_foreach_value(grafts->commits, graft, {
git__free(graft->parents.ptr);
......@@ -90,7 +91,7 @@ int git_grafts_refresh(git_grafts *grafts)
git_str contents = GIT_STR_INIT;
int error, updated = 0;
assert(grafts);
GIT_ASSERT_ARG(grafts);
if (!grafts->path)
return 0;
......@@ -168,7 +169,7 @@ int git_grafts_add(git_grafts *grafts, const git_oid *oid, git_array_oid_t paren
int error;
size_t i;
assert(grafts && oid);
GIT_ASSERT_ARG(grafts && oid);
graft = git__calloc(1, sizeof(*graft));
GIT_ERROR_CHECK_ALLOC(graft);
......@@ -200,7 +201,7 @@ int git_grafts_remove(git_grafts *grafts, const git_oid *oid)
git_commit_graft *graft;
int error;
assert(grafts && oid);
GIT_ASSERT_ARG(grafts && oid);
if ((graft = git_oidmap_get(grafts->commits, oid)) == NULL)
return GIT_ENOTFOUND;
......@@ -216,7 +217,7 @@ int git_grafts_remove(git_grafts *grafts, const git_oid *oid)
int git_grafts_get(git_commit_graft **out, git_grafts *grafts, const git_oid *oid)
{
assert(out && grafts && oid);
GIT_ASSERT_ARG(out && grafts && oid);
if ((*out = git_oidmap_get(grafts->commits, oid)) == NULL)
return GIT_ENOTFOUND;
return 0;
......@@ -228,7 +229,7 @@ int git_grafts_get_oids(git_array_oid_t *out, git_grafts *grafts)
size_t i = 0;
int error;
assert(out && grafts);
GIT_ASSERT_ARG(out && grafts);
while ((error = git_oidmap_iterate(NULL, grafts->commits, &i, &oid)) == 0) {
git_oid *cpy = git_array_alloc(*out);
......
......@@ -1613,14 +1613,16 @@ int git_repository_set_index(git_repository *repo, git_index *index)
int git_repository_grafts__weakptr(git_grafts **out, git_repository *repo)
{
assert(out && repo && repo->grafts);
GIT_ASSERT_ARG(out && repo);
GIT_ASSERT(repo->grafts);
*out = repo->grafts;
return 0;
}
int git_repository_shallow_grafts__weakptr(git_grafts **out, git_repository *repo)
{
assert(out && repo && repo->shallow_grafts);
GIT_ASSERT_ARG(out && repo);
GIT_ASSERT(repo->shallow_grafts);
*out = repo->shallow_grafts;
return 0;
}
......@@ -3672,7 +3674,7 @@ int git_repository__shallow_roots_write(git_repository *repo, git_array_oid_t ro
git_oid *oid;
int filebuf_hash, error = 0;
assert(repo);
GIT_ASSERT_ARG(repo);
filebuf_hash = git_filebuf_hash_flags(git_oid_algorithm(GIT_OID_SHA1));
GIT_ASSERT(filebuf_hash);
......@@ -3695,9 +3697,8 @@ int git_repository__shallow_roots_write(git_repository *repo, git_array_oid_t ro
goto on_error;
}
if (git_array_size(roots) == 0) {
if (git_array_size(roots) == 0)
remove(path.ptr);
}
on_error:
git_str_dispose(&path);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment