Skip to content

Commit ef6b12b

Browse files
committed
revwalk: use GIT_ASSERT
1 parent 5bd139e commit ef6b12b

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

src/revwalk.c

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ int git_revwalk_push(git_revwalk *walk, const git_oid *oid)
9999
{
100100
git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
101101

102-
assert(walk && oid);
102+
GIT_ASSERT_ARG(walk);
103+
GIT_ASSERT_ARG(oid);
103104

104105
return git_revwalk__push_commit(walk, oid, &opts);
105106
}
@@ -108,7 +109,9 @@ int git_revwalk_push(git_revwalk *walk, const git_oid *oid)
108109
int git_revwalk_hide(git_revwalk *walk, const git_oid *oid)
109110
{
110111
git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
111-
assert(walk && oid);
112+
113+
GIT_ASSERT_ARG(walk);
114+
GIT_ASSERT_ARG(oid);
112115

113116
opts.uninteresting = 1;
114117
return git_revwalk__push_commit(walk, oid, &opts);
@@ -133,7 +136,8 @@ int git_revwalk__push_glob(git_revwalk *walk, const char *glob, const git_revwal
133136
git_reference_iterator *iter;
134137
size_t wildcard;
135138

136-
assert(walk && glob);
139+
GIT_ASSERT_ARG(walk);
140+
GIT_ASSERT_ARG(glob);
137141

138142
if (given_opts)
139143
memcpy(&opts, given_opts, sizeof(opts));
@@ -172,15 +176,19 @@ int git_revwalk__push_glob(git_revwalk *walk, const char *glob, const git_revwal
172176
int git_revwalk_push_glob(git_revwalk *walk, const char *glob)
173177
{
174178
git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
175-
assert(walk && glob);
179+
180+
GIT_ASSERT_ARG(walk);
181+
GIT_ASSERT_ARG(glob);
176182

177183
return git_revwalk__push_glob(walk, glob, &opts);
178184
}
179185

180186
int git_revwalk_hide_glob(git_revwalk *walk, const char *glob)
181187
{
182188
git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
183-
assert(walk && glob);
189+
190+
GIT_ASSERT_ARG(walk);
191+
GIT_ASSERT_ARG(glob);
184192

185193
opts.uninteresting = 1;
186194
return git_revwalk__push_glob(walk, glob, &opts);
@@ -189,15 +197,17 @@ int git_revwalk_hide_glob(git_revwalk *walk, const char *glob)
189197
int git_revwalk_push_head(git_revwalk *walk)
190198
{
191199
git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
192-
assert(walk);
200+
201+
GIT_ASSERT_ARG(walk);
193202

194203
return git_revwalk__push_ref(walk, GIT_HEAD_FILE, &opts);
195204
}
196205

197206
int git_revwalk_hide_head(git_revwalk *walk)
198207
{
199208
git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
200-
assert(walk);
209+
210+
GIT_ASSERT_ARG(walk);
201211

202212
opts.uninteresting = 1;
203213
return git_revwalk__push_ref(walk, GIT_HEAD_FILE, &opts);
@@ -206,7 +216,9 @@ int git_revwalk_hide_head(git_revwalk *walk)
206216
int git_revwalk_push_ref(git_revwalk *walk, const char *refname)
207217
{
208218
git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
209-
assert(walk && refname);
219+
220+
GIT_ASSERT_ARG(walk);
221+
GIT_ASSERT_ARG(refname);
210222

211223
return git_revwalk__push_ref(walk, refname, &opts);
212224
}
@@ -249,7 +261,10 @@ int git_revwalk_push_range(git_revwalk *walk, const char *range)
249261
int git_revwalk_hide_ref(git_revwalk *walk, const char *refname)
250262
{
251263
git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
252-
assert(walk && refname);
264+
265+
GIT_ASSERT_ARG(walk);
266+
GIT_ASSERT_ARG(refname);
267+
253268
opts.uninteresting = 1;
254269
return git_revwalk__push_ref(walk, refname, &opts);
255270
}
@@ -694,13 +709,14 @@ void git_revwalk_free(git_revwalk *walk)
694709

695710
git_repository *git_revwalk_repository(git_revwalk *walk)
696711
{
697-
assert(walk);
712+
GIT_ASSERT_ARG_WITH_RETVAL(walk, NULL);
713+
698714
return walk->repo;
699715
}
700716

701717
int git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode)
702718
{
703-
assert(walk);
719+
GIT_ASSERT_ARG(walk);
704720

705721
if (walk->walking)
706722
git_revwalk_reset(walk);
@@ -732,7 +748,8 @@ int git_revwalk_next(git_oid *oid, git_revwalk *walk)
732748
int error;
733749
git_commit_list_node *next;
734750

735-
assert(walk && oid);
751+
GIT_ASSERT_ARG(walk);
752+
GIT_ASSERT_ARG(oid);
736753

737754
if (!walk->walking) {
738755
if ((error = prepare_walk(walk)) < 0)
@@ -757,7 +774,7 @@ int git_revwalk_reset(git_revwalk *walk)
757774
{
758775
git_commit_list_node *commit;
759776

760-
assert(walk);
777+
GIT_ASSERT_ARG(walk);
761778

762779
git_oidmap_foreach_value(walk->commits, commit, {
763780
commit->seen = 0;
@@ -787,7 +804,7 @@ int git_revwalk_add_hide_cb(
787804
git_revwalk_hide_cb hide_cb,
788805
void *payload)
789806
{
790-
assert(walk);
807+
GIT_ASSERT_ARG(walk);
791808

792809
if (walk->walking)
793810
git_revwalk_reset(walk);

0 commit comments

Comments
 (0)