Skip to content

Commit e1af2e5

Browse files
committed
tag: use GIT_ASSERT
1 parent fc98354 commit e1af2e5

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

src/tag.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,25 @@ void git_tag__free(void *_tag)
2727

2828
int git_tag_target(git_object **target, const git_tag *t)
2929
{
30-
assert(t);
30+
GIT_ASSERT_ARG(t);
3131
return git_object_lookup(target, t->object.repo, &t->target, t->type);
3232
}
3333

3434
const git_oid *git_tag_target_id(const git_tag *t)
3535
{
36-
assert(t);
36+
GIT_ASSERT_ARG_WITH_RETVAL(t, NULL);
3737
return &t->target;
3838
}
3939

4040
git_object_t git_tag_target_type(const git_tag *t)
4141
{
42-
assert(t);
42+
GIT_ASSERT_ARG_WITH_RETVAL(t, GIT_OBJECT_INVALID);
4343
return t->type;
4444
}
4545

4646
const char *git_tag_name(const git_tag *t)
4747
{
48-
assert(t);
48+
GIT_ASSERT_ARG_WITH_RETVAL(t, NULL);
4949
return t->tag_name;
5050
}
5151

@@ -56,7 +56,7 @@ const git_signature *git_tag_tagger(const git_tag *t)
5656

5757
const char *git_tag_message(const git_tag *t)
5858
{
59-
assert(t);
59+
GIT_ASSERT_ARG_WITH_RETVAL(t, NULL);
6060
return t->message;
6161
}
6262

@@ -259,8 +259,10 @@ static int git_tag_create__internal(
259259

260260
int error;
261261

262-
assert(repo && tag_name && target);
263-
assert(!create_tag_annotation || (tagger && message));
262+
GIT_ASSERT_ARG(repo);
263+
GIT_ASSERT_ARG(tag_name);
264+
GIT_ASSERT_ARG(target);
265+
GIT_ASSERT_ARG(!create_tag_annotation || (tagger && message));
264266

265267
if (git_object_owner(target) != repo) {
266268
git_error_set(GIT_ERROR_INVALID, "the given target does not belong to this repository");
@@ -313,7 +315,12 @@ int git_tag_annotation_create(
313315
const git_signature *tagger,
314316
const char *message)
315317
{
316-
assert(oid && repo && tag_name && target && tagger && message);
318+
GIT_ASSERT_ARG(oid);
319+
GIT_ASSERT_ARG(repo);
320+
GIT_ASSERT_ARG(tag_name);
321+
GIT_ASSERT_ARG(target);
322+
GIT_ASSERT_ARG(tagger);
323+
GIT_ASSERT_ARG(message);
317324

318325
return write_tag_annotation(oid, repo, tag_name, target, tagger, message);
319326
}
@@ -339,7 +346,8 @@ int git_tag_create_from_buffer(git_oid *oid, git_repository *repo, const char *b
339346
git_reference *new_ref = NULL;
340347
git_buf ref_name = GIT_BUF_INIT;
341348

342-
assert(oid && buffer);
349+
GIT_ASSERT_ARG(oid);
350+
GIT_ASSERT_ARG(buffer);
343351

344352
memset(&tag, 0, sizeof(tag));
345353

@@ -454,7 +462,8 @@ int git_tag_foreach(git_repository *repo, git_tag_foreach_cb cb, void *cb_data)
454462
{
455463
tag_cb_data data;
456464

457-
assert(repo && cb);
465+
GIT_ASSERT_ARG(repo);
466+
GIT_ASSERT_ARG(cb);
458467

459468
data.cb = cb;
460469
data.cb_data = cb_data;
@@ -493,7 +502,9 @@ int git_tag_list_match(git_strarray *tag_names, const char *pattern, git_reposit
493502
tag_filter_data filter;
494503
git_vector taglist;
495504

496-
assert(tag_names && repo && pattern);
505+
GIT_ASSERT_ARG(tag_names);
506+
GIT_ASSERT_ARG(repo);
507+
GIT_ASSERT_ARG(pattern);
497508

498509
if ((error = git_vector_init(&taglist, 8, NULL)) < 0)
499510
return error;

0 commit comments

Comments
 (0)