summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2023-04-22 23:42:41 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2023-04-24 11:49:16 +0100
commit48273490e7ccfaa56b784c69cb488111bd06f357 (patch)
tree02a4c80d0698fb651f080896bb7faf2d96b899ab /src
parent6cec01b4d8498203ae3a03949ffd480845269a3d (diff)
downloadlibgit2-48273490e7ccfaa56b784c69cb488111bd06f357.tar.gz
shallow: use GIT_ASSERT (not assert)
Diffstat (limited to 'src')
-rw-r--r--src/libgit2/grafts.c13
-rw-r--r--src/libgit2/repository.c11
2 files changed, 13 insertions, 11 deletions
diff --git a/src/libgit2/grafts.c b/src/libgit2/grafts.c
index 13c33aad0..1bfdc500e 100644
--- a/src/libgit2/grafts.c
+++ b/src/libgit2/grafts.c
@@ -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);
diff --git a/src/libgit2/repository.c b/src/libgit2/repository.c
index 99982b724..3b6ecae24 100644
--- a/src/libgit2/repository.c
+++ b/src/libgit2/repository.c
@@ -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);