Skip to content

Commit eda726c

Browse files
committed
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 parent a3dc419 commit eda726c

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

include/git2/submodule.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,18 @@ typedef enum {
107107
GIT_SUBMODULE_STATUS_WD_WD_MODIFIED | \
108108
GIT_SUBMODULE_STATUS_WD_UNTRACKED)) != 0)
109109

110+
/**
111+
* Function pointer to receive each submodule
112+
*
113+
* `sm` is the `git_submodule` currently being visited.
114+
*
115+
* `name` is the name of the submodule.
116+
*
117+
* `payload` is the value you passed to the foreach function as payload.
118+
*/
119+
typedef int (*git_submodule_cb)(
120+
git_submodule *sm, const char *name, void *payload);
121+
110122
/**
111123
* Submodule update options structure
112124
*
@@ -239,7 +251,7 @@ GIT_EXTERN(void) git_submodule_free(git_submodule *submodule);
239251
*/
240252
GIT_EXTERN(int) git_submodule_foreach(
241253
git_repository *repo,
242-
int (*callback)(git_submodule *sm, const char *name, void *payload),
254+
git_submodule_cb callback,
243255
void *payload);
244256

245257
/**

src/submodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ static int all_submodules(git_repository *repo, git_strmap *map)
495495

496496
int git_submodule_foreach(
497497
git_repository *repo,
498-
int (*callback)(git_submodule *sm, const char *name, void *payload),
498+
git_submodule_cb callback,
499499
void *payload)
500500
{
501501
git_vector snapshot = GIT_VECTOR_INIT;

0 commit comments

Comments
 (0)