rebase: use GIT_ASSERT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
diff --git a/src/rebase.c b/src/rebase.c
index 7c65611..bf6581a 100644
--- a/src/rebase.c
+++ b/src/rebase.c
@@ -186,8 +186,8 @@ static git_rebase_operation *rebase_operation_alloc(
{
git_rebase_operation *operation;
- assert((type == GIT_REBASE_OPERATION_EXEC) == !id);
- assert((type == GIT_REBASE_OPERATION_EXEC) == !!exec);
+ GIT_ASSERT_WITH_RETVAL((type == GIT_REBASE_OPERATION_EXEC) == !id, NULL);
+ GIT_ASSERT_WITH_RETVAL((type == GIT_REBASE_OPERATION_EXEC) == !!exec, NULL);
if ((operation = git_array_alloc(rebase->operations)) == NULL)
return NULL;
@@ -301,7 +301,7 @@ int git_rebase_open(
size_t state_path_len;
int error;
- assert(repo);
+ GIT_ASSERT_ARG(repo);
if ((error = rebase_check_versions(given_opts)) < 0)
return error;
@@ -701,7 +701,8 @@ int git_rebase_init(
bool inmemory = (given_opts && given_opts->inmemory);
int error;
- assert(repo && (upstream || onto));
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(upstream || onto);
*out = NULL;
@@ -912,7 +913,8 @@ int git_rebase_next(
{
int error;
- assert(out && rebase);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(rebase);
if ((error = rebase_movenext(rebase)) < 0)
return error;
@@ -931,7 +933,9 @@ int git_rebase_inmemory_index(
git_index **out,
git_rebase *rebase)
{
- assert(out && rebase && rebase->index);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(rebase);
+ GIT_ASSERT_ARG(rebase->index);
GIT_REFCOUNT_INC(rebase->index);
*out = rebase->index;
@@ -1006,12 +1010,12 @@ static int rebase_commit__create(
}
if (git_buf_is_allocated(&commit_signature)) {
- assert(git_buf_contains_nul(&commit_signature));
+ GIT_ASSERT(git_buf_contains_nul(&commit_signature));
commit_signature_string = git_buf_cstr(&commit_signature);
}
if (git_buf_is_allocated(&signature_field)) {
- assert(git_buf_contains_nul(&signature_field));
+ GIT_ASSERT(git_buf_contains_nul(&signature_field));
signature_field_string = git_buf_cstr(&signature_field);
}
@@ -1055,7 +1059,7 @@ static int rebase_commit_merge(
int error;
operation = git_array_get(rebase->operations, rebase->current);
- assert(operation);
+ GIT_ASSERT(operation);
if ((error = rebase_ensure_not_dirty(rebase->repo, false, true, GIT_EUNMERGED)) < 0 ||
(error = git_repository_head(&head, rebase->repo)) < 0 ||
@@ -1095,9 +1099,9 @@ static int rebase_commit_inmemory(
git_commit *commit = NULL;
int error = 0;
- assert(rebase->index);
- assert(rebase->last_commit);
- assert(rebase->current < rebase->operations.size);
+ GIT_ASSERT_ARG(rebase->index);
+ GIT_ASSERT_ARG(rebase->last_commit);
+ GIT_ASSERT_ARG(rebase->current < rebase->operations.size);
if ((error = rebase_commit__create(&commit, rebase, rebase->index,
rebase->last_commit, author, committer, message_encoding, message)) < 0)
@@ -1125,7 +1129,8 @@ int git_rebase_commit(
{
int error;
- assert(rebase && committer);
+ GIT_ASSERT_ARG(rebase);
+ GIT_ASSERT_ARG(committer);
if (rebase->inmemory)
error = rebase_commit_inmemory(
@@ -1145,7 +1150,7 @@ int git_rebase_abort(git_rebase *rebase)
git_commit *orig_head_commit = NULL;
int error;
- assert(rebase);
+ GIT_ASSERT_ARG(rebase);
if (rebase->inmemory)
return 0;
@@ -1358,7 +1363,7 @@ int git_rebase_finish(
{
int error = 0;
- assert(rebase);
+ GIT_ASSERT_ARG(rebase);
if (rebase->inmemory)
return 0;
@@ -1373,14 +1378,17 @@ int git_rebase_finish(
}
const char *git_rebase_orig_head_name(git_rebase *rebase) {
+ GIT_ASSERT_ARG_WITH_RETVAL(rebase, NULL);
return rebase->orig_head_name;
}
const git_oid *git_rebase_orig_head_id(git_rebase *rebase) {
+ GIT_ASSERT_ARG_WITH_RETVAL(rebase, NULL);
return &rebase->orig_head_id;
}
const char *git_rebase_onto_name(git_rebase *rebase) {
+ GIT_ASSERT_ARG_WITH_RETVAL(rebase, NULL);
return rebase->onto_name;
}
@@ -1390,21 +1398,21 @@ const git_oid *git_rebase_onto_id(git_rebase *rebase) {
size_t git_rebase_operation_entrycount(git_rebase *rebase)
{
- assert(rebase);
+ GIT_ASSERT_ARG_WITH_RETVAL(rebase, 0);
return git_array_size(rebase->operations);
}
size_t git_rebase_operation_current(git_rebase *rebase)
{
- assert(rebase);
+ GIT_ASSERT_ARG_WITH_RETVAL(rebase, 0);
return rebase->started ? rebase->current : GIT_REBASE_NO_OPERATION;
}
git_rebase_operation *git_rebase_operation_byindex(git_rebase *rebase, size_t idx)
{
- assert(rebase);
+ GIT_ASSERT_ARG_WITH_RETVAL(rebase, NULL);
return git_array_get(rebase->operations, idx);
}