Skip to content

Commit 89ee31a

Browse files
committed
refspec: use GIT_ASSERT
1 parent 7f0cabd commit 89ee31a

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/refspec.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch)
2424
int valid = 0;
2525
unsigned int flags;
2626

27-
assert(refspec && input);
27+
GIT_ASSERT_ARG(refspec);
28+
GIT_ASSERT_ARG(input);
2829

2930
memset(refspec, 0x0, sizeof(git_refspec));
3031
refspec->push = !is_fetch;
@@ -180,7 +181,8 @@ void git_refspec__dispose(git_refspec *refspec)
180181
int git_refspec_parse(git_refspec **out_refspec, const char *input, int is_fetch)
181182
{
182183
git_refspec *refspec;
183-
assert(out_refspec && input);
184+
GIT_ASSERT_ARG(out_refspec);
185+
GIT_ASSERT_ARG(input);
184186

185187
*out_refspec = NULL;
186188

@@ -219,7 +221,7 @@ const char *git_refspec_string(const git_refspec *refspec)
219221

220222
int git_refspec_force(const git_refspec *refspec)
221223
{
222-
assert(refspec);
224+
GIT_ASSERT_ARG(refspec);
223225

224226
return refspec->force;
225227
}
@@ -261,7 +263,7 @@ static int refspec_transform(
261263
from_star = strchr(from, '*');
262264
to_star = strchr(to, '*');
263265

264-
assert(from_star && to_star);
266+
GIT_ASSERT(from_star && to_star);
265267

266268
/* star offset, both in 'from' and in 'name' */
267269
star_offset = from_star - from;
@@ -283,7 +285,9 @@ int git_refspec_transform(git_buf *out, const git_refspec *spec, const char *nam
283285
{
284286
int error;
285287

286-
assert(out && spec && name);
288+
GIT_ASSERT_ARG(out);
289+
GIT_ASSERT_ARG(spec);
290+
GIT_ASSERT_ARG(name);
287291

288292
if ((error = git_buf_sanitize(out)) < 0)
289293
return error;
@@ -303,7 +307,9 @@ int git_refspec_rtransform(git_buf *out, const git_refspec *spec, const char *na
303307
{
304308
int error;
305309

306-
assert(out && spec && name);
310+
GIT_ASSERT_ARG(out);
311+
GIT_ASSERT_ARG(spec);
312+
GIT_ASSERT_ARG(name);
307313

308314
if ((error = git_buf_sanitize(out)) < 0)
309315
return error;
@@ -333,14 +339,15 @@ int git_refspec__serialize(git_buf *out, const git_refspec *refspec)
333339

334340
int git_refspec_is_wildcard(const git_refspec *spec)
335341
{
336-
assert(spec && spec->src);
342+
GIT_ASSERT_ARG(spec);
343+
GIT_ASSERT_ARG(spec->src);
337344

338345
return (spec->src[strlen(spec->src) - 1] == '*');
339346
}
340347

341348
git_direction git_refspec_direction(const git_refspec *spec)
342349
{
343-
assert(spec);
350+
GIT_ASSERT_ARG(spec);
344351

345352
return spec->push;
346353
}
@@ -359,7 +366,9 @@ int git_refspec__dwim_one(git_vector *out, git_refspec *spec, git_vector *refs)
359366
NULL
360367
};
361368

362-
assert(out && spec && refs);
369+
GIT_ASSERT_ARG(out);
370+
GIT_ASSERT_ARG(spec);
371+
GIT_ASSERT_ARG(refs);
363372

364373
cur = git__calloc(1, sizeof(git_refspec));
365374
GIT_ERROR_CHECK_ALLOC(cur);

0 commit comments

Comments
 (0)