Skip to content

Commit 690ff9c

Browse files
committed
rebase: use GIT_ASSERT
1 parent 00e57f6 commit 690ff9c

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

src/rebase.c

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ static git_rebase_operation *rebase_operation_alloc(
186186
{
187187
git_rebase_operation *operation;
188188

189-
assert((type == GIT_REBASE_OPERATION_EXEC) == !id);
190-
assert((type == GIT_REBASE_OPERATION_EXEC) == !!exec);
189+
GIT_ASSERT_WITH_RETVAL((type == GIT_REBASE_OPERATION_EXEC) == !id, NULL);
190+
GIT_ASSERT_WITH_RETVAL((type == GIT_REBASE_OPERATION_EXEC) == !!exec, NULL);
191191

192192
if ((operation = git_array_alloc(rebase->operations)) == NULL)
193193
return NULL;
@@ -301,7 +301,7 @@ int git_rebase_open(
301301
size_t state_path_len;
302302
int error;
303303

304-
assert(repo);
304+
GIT_ASSERT_ARG(repo);
305305

306306
if ((error = rebase_check_versions(given_opts)) < 0)
307307
return error;
@@ -701,7 +701,8 @@ int git_rebase_init(
701701
bool inmemory = (given_opts && given_opts->inmemory);
702702
int error;
703703

704-
assert(repo && (upstream || onto));
704+
GIT_ASSERT_ARG(repo);
705+
GIT_ASSERT_ARG(upstream || onto);
705706

706707
*out = NULL;
707708

@@ -912,7 +913,8 @@ int git_rebase_next(
912913
{
913914
int error;
914915

915-
assert(out && rebase);
916+
GIT_ASSERT_ARG(out);
917+
GIT_ASSERT_ARG(rebase);
916918

917919
if ((error = rebase_movenext(rebase)) < 0)
918920
return error;
@@ -931,7 +933,9 @@ int git_rebase_inmemory_index(
931933
git_index **out,
932934
git_rebase *rebase)
933935
{
934-
assert(out && rebase && rebase->index);
936+
GIT_ASSERT_ARG(out);
937+
GIT_ASSERT_ARG(rebase);
938+
GIT_ASSERT_ARG(rebase->index);
935939

936940
GIT_REFCOUNT_INC(rebase->index);
937941
*out = rebase->index;
@@ -1006,12 +1010,12 @@ static int rebase_commit__create(
10061010
}
10071011

10081012
if (git_buf_is_allocated(&commit_signature)) {
1009-
assert(git_buf_contains_nul(&commit_signature));
1013+
GIT_ASSERT(git_buf_contains_nul(&commit_signature));
10101014
commit_signature_string = git_buf_cstr(&commit_signature);
10111015
}
10121016

10131017
if (git_buf_is_allocated(&signature_field)) {
1014-
assert(git_buf_contains_nul(&signature_field));
1018+
GIT_ASSERT(git_buf_contains_nul(&signature_field));
10151019
signature_field_string = git_buf_cstr(&signature_field);
10161020
}
10171021

@@ -1055,7 +1059,7 @@ static int rebase_commit_merge(
10551059
int error;
10561060

10571061
operation = git_array_get(rebase->operations, rebase->current);
1058-
assert(operation);
1062+
GIT_ASSERT(operation);
10591063

10601064
if ((error = rebase_ensure_not_dirty(rebase->repo, false, true, GIT_EUNMERGED)) < 0 ||
10611065
(error = git_repository_head(&head, rebase->repo)) < 0 ||
@@ -1095,9 +1099,9 @@ static int rebase_commit_inmemory(
10951099
git_commit *commit = NULL;
10961100
int error = 0;
10971101

1098-
assert(rebase->index);
1099-
assert(rebase->last_commit);
1100-
assert(rebase->current < rebase->operations.size);
1102+
GIT_ASSERT_ARG(rebase->index);
1103+
GIT_ASSERT_ARG(rebase->last_commit);
1104+
GIT_ASSERT_ARG(rebase->current < rebase->operations.size);
11011105

11021106
if ((error = rebase_commit__create(&commit, rebase, rebase->index,
11031107
rebase->last_commit, author, committer, message_encoding, message)) < 0)
@@ -1125,7 +1129,8 @@ int git_rebase_commit(
11251129
{
11261130
int error;
11271131

1128-
assert(rebase && committer);
1132+
GIT_ASSERT_ARG(rebase);
1133+
GIT_ASSERT_ARG(committer);
11291134

11301135
if (rebase->inmemory)
11311136
error = rebase_commit_inmemory(
@@ -1145,7 +1150,7 @@ int git_rebase_abort(git_rebase *rebase)
11451150
git_commit *orig_head_commit = NULL;
11461151
int error;
11471152

1148-
assert(rebase);
1153+
GIT_ASSERT_ARG(rebase);
11491154

11501155
if (rebase->inmemory)
11511156
return 0;
@@ -1358,7 +1363,7 @@ int git_rebase_finish(
13581363
{
13591364
int error = 0;
13601365

1361-
assert(rebase);
1366+
GIT_ASSERT_ARG(rebase);
13621367

13631368
if (rebase->inmemory)
13641369
return 0;
@@ -1373,14 +1378,17 @@ int git_rebase_finish(
13731378
}
13741379

13751380
const char *git_rebase_orig_head_name(git_rebase *rebase) {
1381+
GIT_ASSERT_ARG_WITH_RETVAL(rebase, NULL);
13761382
return rebase->orig_head_name;
13771383
}
13781384

13791385
const git_oid *git_rebase_orig_head_id(git_rebase *rebase) {
1386+
GIT_ASSERT_ARG_WITH_RETVAL(rebase, NULL);
13801387
return &rebase->orig_head_id;
13811388
}
13821389

13831390
const char *git_rebase_onto_name(git_rebase *rebase) {
1391+
GIT_ASSERT_ARG_WITH_RETVAL(rebase, NULL);
13841392
return rebase->onto_name;
13851393
}
13861394

@@ -1390,21 +1398,21 @@ const git_oid *git_rebase_onto_id(git_rebase *rebase) {
13901398

13911399
size_t git_rebase_operation_entrycount(git_rebase *rebase)
13921400
{
1393-
assert(rebase);
1401+
GIT_ASSERT_ARG_WITH_RETVAL(rebase, 0);
13941402

13951403
return git_array_size(rebase->operations);
13961404
}
13971405

13981406
size_t git_rebase_operation_current(git_rebase *rebase)
13991407
{
1400-
assert(rebase);
1408+
GIT_ASSERT_ARG_WITH_RETVAL(rebase, 0);
14011409

14021410
return rebase->started ? rebase->current : GIT_REBASE_NO_OPERATION;
14031411
}
14041412

14051413
git_rebase_operation *git_rebase_operation_byindex(git_rebase *rebase, size_t idx)
14061414
{
1407-
assert(rebase);
1415+
GIT_ASSERT_ARG_WITH_RETVAL(rebase, NULL);
14081416

14091417
return git_array_get(rebase->operations, idx);
14101418
}

0 commit comments

Comments
 (0)