Commit 8d66d57f by Edward Thomson

refdb: use GIT_ASSERT

parent 690ff9cd
......@@ -24,7 +24,8 @@ int git_refdb_new(git_refdb **out, git_repository *repo)
{
git_refdb *db;
assert(out && repo);
GIT_ASSERT_ARG(out);
GIT_ASSERT_ARG(repo);
db = git__calloc(1, sizeof(*db));
GIT_ERROR_CHECK_ALLOC(db);
......@@ -41,7 +42,8 @@ int git_refdb_open(git_refdb **out, git_repository *repo)
git_refdb *db;
git_refdb_backend *dir;
assert(out && repo);
GIT_ASSERT_ARG(out);
GIT_ASSERT_ARG(repo);
*out = NULL;
......@@ -89,7 +91,7 @@ int git_refdb_set_backend(git_refdb *db, git_refdb_backend *backend)
int git_refdb_compress(git_refdb *db)
{
assert(db);
GIT_ASSERT_ARG(db);
if (db->backend->compress)
return db->backend->compress(db->backend);
......@@ -114,7 +116,9 @@ void git_refdb_free(git_refdb *db)
int git_refdb_exists(int *exists, git_refdb *refdb, const char *ref_name)
{
assert(exists && refdb && refdb->backend);
GIT_ASSERT_ARG(exists);
GIT_ASSERT_ARG(refdb);
GIT_ASSERT_ARG(refdb->backend);
return refdb->backend->exists(exists, refdb->backend, ref_name);
}
......@@ -124,7 +128,10 @@ int git_refdb_lookup(git_reference **out, git_refdb *db, const char *ref_name)
git_reference *ref;
int error;
assert(db && db->backend && out && ref_name);
GIT_ASSERT_ARG(db);
GIT_ASSERT_ARG(db->backend);
GIT_ASSERT_ARG(out);
GIT_ASSERT_ARG(ref_name);
error = db->backend->lookup(&ref, db->backend, ref_name);
if (error < 0)
......@@ -234,7 +241,8 @@ void git_refdb_iterator_free(git_reference_iterator *iter)
int git_refdb_write(git_refdb *db, git_reference *ref, int force, const git_signature *who, const char *message, const git_oid *old_id, const char *old_target)
{
assert(db && db->backend);
GIT_ASSERT_ARG(db);
GIT_ASSERT_ARG(db->backend);
GIT_REFCOUNT_INC(db);
ref->db = db;
......@@ -253,7 +261,9 @@ int git_refdb_rename(
{
int error;
assert(db && db->backend);
GIT_ASSERT_ARG(db);
GIT_ASSERT_ARG(db->backend);
error = db->backend->rename(out, db->backend, old_name, new_name, force, who, message);
if (error < 0)
return error;
......@@ -268,7 +278,9 @@ int git_refdb_rename(
int git_refdb_delete(struct git_refdb *db, const char *ref_name, const git_oid *old_id, const char *old_target)
{
assert(db && db->backend);
GIT_ASSERT_ARG(db);
GIT_ASSERT_ARG(db->backend);
return db->backend->del(db->backend, ref_name, old_id, old_target);
}
......@@ -276,7 +288,8 @@ int git_refdb_reflog_read(git_reflog **out, git_refdb *db, const char *name)
{
int error;
assert(db && db->backend);
GIT_ASSERT_ARG(db);
GIT_ASSERT_ARG(db->backend);
if ((error = db->backend->reflog_read(out, db->backend, name)) < 0)
return error;
......@@ -368,14 +381,16 @@ out:
int git_refdb_has_log(git_refdb *db, const char *refname)
{
assert(db && refname);
GIT_ASSERT_ARG(db);
GIT_ASSERT_ARG(refname);
return db->backend->has_log(db->backend, refname);
}
int git_refdb_ensure_log(git_refdb *db, const char *refname)
{
assert(db && refname);
GIT_ASSERT_ARG(db);
GIT_ASSERT_ARG(refname);
return db->backend->ensure_log(db->backend, refname);
}
......@@ -389,7 +404,9 @@ int git_refdb_init_backend(git_refdb_backend *backend, unsigned int version)
int git_refdb_lock(void **payload, git_refdb *db, const char *refname)
{
assert(payload && db && refname);
GIT_ASSERT_ARG(payload);
GIT_ASSERT_ARG(db);
GIT_ASSERT_ARG(refname);
if (!db->backend->lock) {
git_error_set(GIT_ERROR_REFERENCE, "backend does not support locking");
......@@ -401,7 +418,7 @@ int git_refdb_lock(void **payload, git_refdb *db, const char *refname)
int git_refdb_unlock(git_refdb *db, void *payload, int success, int update_reflog, const git_reference *ref, const git_signature *sig, const char *message)
{
assert(db);
GIT_ASSERT_ARG(db);
return db->backend->unlock(db->backend, payload, success, update_reflog, ref, sig, message);
}
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