Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 21b1e01

Browse files
committed
Merge pull request libgit2#3539 from libgit2/typedef-submodule-cb
Use a typedef for the submodule_foreach callback.
2 parents d698929 + ab27382 commit 21b1e01

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

include/git2/submodule.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ 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+
* @param sm git_submodule currently being visited
114+
* @param name name of the submodule
115+
* @param payload value you passed to the foreach function as payload
116+
* @return 0 on success or error code
117+
*/
118+
typedef int (*git_submodule_cb)(
119+
git_submodule *sm, const char *name, void *payload);
120+
110121
/**
111122
* Submodule update options structure
112123
*
@@ -239,7 +250,7 @@ GIT_EXTERN(void) git_submodule_free(git_submodule *submodule);
239250
*/
240251
GIT_EXTERN(int) git_submodule_foreach(
241252
git_repository *repo,
242-
int (*callback)(git_submodule *sm, const char *name, void *payload),
253+
git_submodule_cb callback,
243254
void *payload);
244255

245256
/**

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)