Use a typedef for the submodule_foreach callback. This fits with the style for the rest of the project, but more importantly, makes life easier for bindings authors who auto-generate code.
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
diff --git a/include/git2/submodule.h b/include/git2/submodule.h
index 689fe4b..96187b0 100644
--- a/include/git2/submodule.h
+++ b/include/git2/submodule.h
@@ -108,6 +108,18 @@ typedef enum {
GIT_SUBMODULE_STATUS_WD_UNTRACKED)) != 0)
/**
+ * Function pointer to receive each submodule
+ *
+ * `sm` is the `git_submodule` currently being visited.
+ *
+ * `name` is the name of the submodule.
+ *
+ * `payload` is the value you passed to the foreach function as payload.
+ */
+typedef int (*git_submodule_cb)(
+ git_submodule *sm, const char *name, void *payload);
+
+/**
* Submodule update options structure
*
* Use the GIT_SUBMODULE_UPDATE_OPTIONS_INIT to get the default settings,
@@ -239,7 +251,7 @@ GIT_EXTERN(void) git_submodule_free(git_submodule *submodule);
*/
GIT_EXTERN(int) git_submodule_foreach(
git_repository *repo,
- int (*callback)(git_submodule *sm, const char *name, void *payload),
+ git_submodule_cb callback,
void *payload);
/**
diff --git a/src/submodule.c b/src/submodule.c
index 1148f87..6ec4c53 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -495,7 +495,7 @@ cleanup:
int git_submodule_foreach(
git_repository *repo,
- int (*callback)(git_submodule *sm, const char *name, void *payload),
+ git_submodule_cb callback,
void *payload)
{
git_vector snapshot = GIT_VECTOR_INIT;