Skip to content

Commit 4b331f0

Browse files
committed
revwalk functions: return an int
Stop returning a void for functions, future-proofing them to allow them to fail.
1 parent 82050fa commit 4b331f0

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

include/git2/revwalk.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ GIT_EXTERN(int) git_revwalk_new(git_revwalk **out, git_repository *repo);
8484
* is over.
8585
*
8686
* @param walker handle to reset.
87+
* @return 0 or an error code
8788
*/
88-
GIT_EXTERN(void) git_revwalk_reset(git_revwalk *walker);
89+
GIT_EXTERN(int) git_revwalk_reset(git_revwalk *walker);
8990

9091
/**
9192
* Add a new root for the traversal
@@ -224,8 +225,9 @@ GIT_EXTERN(int) git_revwalk_next(git_oid *out, git_revwalk *walk);
224225
*
225226
* @param walk the walker being used for the traversal.
226227
* @param sort_mode combination of GIT_SORT_XXX flags
228+
* @return 0 or an error code
227229
*/
228-
GIT_EXTERN(void) git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode);
230+
GIT_EXTERN(int) git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode);
229231

230232
/**
231233
* Push and hide the respective endpoints of the given range.
@@ -246,8 +248,10 @@ GIT_EXTERN(int) git_revwalk_push_range(git_revwalk *walk, const char *range);
246248
* Simplify the history by first-parent
247249
*
248250
* No parents other than the first for each commit will be enqueued.
251+
*
252+
* @return 0 or an error code
249253
*/
250-
GIT_EXTERN(void) git_revwalk_simplify_first_parent(git_revwalk *walk);
254+
GIT_EXTERN(int) git_revwalk_simplify_first_parent(git_revwalk *walk);
251255

252256

253257
/**

src/revwalk.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ git_repository *git_revwalk_repository(git_revwalk *walk)
700700
return walk->repo;
701701
}
702702

703-
void git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode)
703+
int git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode)
704704
{
705705
assert(walk);
706706

@@ -719,11 +719,14 @@ void git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode)
719719

720720
if (walk->sorting != GIT_SORT_NONE)
721721
walk->limited = 1;
722+
723+
return 0;
722724
}
723725

724-
void git_revwalk_simplify_first_parent(git_revwalk *walk)
726+
int git_revwalk_simplify_first_parent(git_revwalk *walk)
725727
{
726728
walk->first_parent = 1;
729+
return 0;
727730
}
728731

729732
int git_revwalk_next(git_oid *oid, git_revwalk *walk)
@@ -752,7 +755,7 @@ int git_revwalk_next(git_oid *oid, git_revwalk *walk)
752755
return error;
753756
}
754757

755-
void git_revwalk_reset(git_revwalk *walk)
758+
int git_revwalk_reset(git_revwalk *walk)
756759
{
757760
git_commit_list_node *commit;
758761

@@ -777,6 +780,8 @@ void git_revwalk_reset(git_revwalk *walk)
777780
walk->limited = 0;
778781
walk->did_push = walk->did_hide = 0;
779782
walk->sorting = GIT_SORT_NONE;
783+
784+
return 0;
780785
}
781786

782787
int git_revwalk_add_hide_cb(

0 commit comments

Comments
 (0)