summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2020-04-05 22:16:57 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2020-11-27 11:09:21 +0000
commitd42e4d5fee93a7bf35f4acca0cc3a1bea94347ea (patch)
tree0aa9801124683a2d6f56a5a9cbbfe9bbb715a231
parent9083a0e62834123aa5172d11ee27022850ec37a9 (diff)
downloadlibgit2-d42e4d5fee93a7bf35f4acca0cc3a1bea94347ea.tar.gz
transaction: use GIT_ASSERT
-rw-r--r--src/transaction.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/transaction.c b/src/transaction.c
index 81af8d831..98fa1ba90 100644
--- a/src/transaction.c
+++ b/src/transaction.c
@@ -57,7 +57,9 @@ struct git_transaction {
int git_transaction_config_new(git_transaction **out, git_config *cfg)
{
git_transaction *tx;
- assert(out && cfg);
+
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(cfg);
tx = git__calloc(1, sizeof(git_transaction));
GIT_ERROR_CHECK_ALLOC(tx);
@@ -74,7 +76,8 @@ int git_transaction_new(git_transaction **out, git_repository *repo)
git_pool pool;
git_transaction *tx = NULL;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
if ((error = git_pool_init(&pool, 1)) < 0)
goto on_error;
@@ -109,7 +112,8 @@ int git_transaction_lock_ref(git_transaction *tx, const char *refname)
int error;
transaction_node *node;
- assert(tx && refname);
+ GIT_ASSERT_ARG(tx);
+ GIT_ASSERT_ARG(refname);
node = git_pool_mallocz(&tx->pool, sizeof(transaction_node));
GIT_ERROR_CHECK_ALLOC(node);
@@ -176,7 +180,9 @@ int git_transaction_set_target(git_transaction *tx, const char *refname, const g
int error;
transaction_node *node;
- assert(tx && refname && target);
+ GIT_ASSERT_ARG(tx);
+ GIT_ASSERT_ARG(refname);
+ GIT_ASSERT_ARG(target);
if ((error = find_locked(&node, tx, refname)) < 0)
return error;
@@ -195,7 +201,9 @@ int git_transaction_set_symbolic_target(git_transaction *tx, const char *refname
int error;
transaction_node *node;
- assert(tx && refname && target);
+ GIT_ASSERT_ARG(tx);
+ GIT_ASSERT_ARG(refname);
+ GIT_ASSERT_ARG(target);
if ((error = find_locked(&node, tx, refname)) < 0)
return error;
@@ -272,7 +280,9 @@ int git_transaction_set_reflog(git_transaction *tx, const char *refname, const g
int error;
transaction_node *node;
- assert(tx && refname && reflog);
+ GIT_ASSERT_ARG(tx);
+ GIT_ASSERT_ARG(refname);
+ GIT_ASSERT_ARG(reflog);
if ((error = find_locked(&node, tx, refname)) < 0)
return error;
@@ -320,7 +330,7 @@ int git_transaction_commit(git_transaction *tx)
transaction_node *node;
int error = 0;
- assert(tx);
+ GIT_ASSERT_ARG(tx);
if (tx->type == TRANSACTION_CONFIG) {
error = git_config_unlock(tx->cfg, true);
@@ -355,7 +365,8 @@ void git_transaction_free(git_transaction *tx)
transaction_node *node;
git_pool pool;
- assert(tx);
+ if (!tx)
+ return;
if (tx->type == TRANSACTION_CONFIG) {
if (tx->cfg) {