revwalk functions: return an int Stop returning a void for functions, future-proofing them to allow them to fail.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
diff --git a/include/git2/revwalk.h b/include/git2/revwalk.h
index 9cb0d0a..98dcbf8 100644
--- a/include/git2/revwalk.h
+++ b/include/git2/revwalk.h
@@ -84,8 +84,9 @@ GIT_EXTERN(int) git_revwalk_new(git_revwalk **out, git_repository *repo);
* is over.
*
* @param walker handle to reset.
+ * @return 0 or an error code
*/
-GIT_EXTERN(void) git_revwalk_reset(git_revwalk *walker);
+GIT_EXTERN(int) git_revwalk_reset(git_revwalk *walker);
/**
* Add a new root for the traversal
@@ -224,8 +225,9 @@ GIT_EXTERN(int) git_revwalk_next(git_oid *out, git_revwalk *walk);
*
* @param walk the walker being used for the traversal.
* @param sort_mode combination of GIT_SORT_XXX flags
+ * @return 0 or an error code
*/
-GIT_EXTERN(void) git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode);
+GIT_EXTERN(int) git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode);
/**
* 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);
* Simplify the history by first-parent
*
* No parents other than the first for each commit will be enqueued.
+ *
+ * @return 0 or an error code
*/
-GIT_EXTERN(void) git_revwalk_simplify_first_parent(git_revwalk *walk);
+GIT_EXTERN(int) git_revwalk_simplify_first_parent(git_revwalk *walk);
/**
diff --git a/src/revwalk.c b/src/revwalk.c
index 6f49bf2..4587b5a 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -700,7 +700,7 @@ git_repository *git_revwalk_repository(git_revwalk *walk)
return walk->repo;
}
-void git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode)
+int git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode)
{
assert(walk);
@@ -719,11 +719,14 @@ void git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode)
if (walk->sorting != GIT_SORT_NONE)
walk->limited = 1;
+
+ return 0;
}
-void git_revwalk_simplify_first_parent(git_revwalk *walk)
+int git_revwalk_simplify_first_parent(git_revwalk *walk)
{
walk->first_parent = 1;
+ return 0;
}
int git_revwalk_next(git_oid *oid, git_revwalk *walk)
@@ -752,7 +755,7 @@ int git_revwalk_next(git_oid *oid, git_revwalk *walk)
return error;
}
-void git_revwalk_reset(git_revwalk *walk)
+int git_revwalk_reset(git_revwalk *walk)
{
git_commit_list_node *commit;
@@ -777,6 +780,8 @@ void git_revwalk_reset(git_revwalk *walk)
walk->limited = 0;
walk->did_push = walk->did_hide = 0;
walk->sorting = GIT_SORT_NONE;
+
+ return 0;
}
int git_revwalk_add_hide_cb(