-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Description
For certain repos git_submodule_foreach seems to not work without any reason or error.
I can't narrow down what causes this; it happens for .gitmodules, for example certain names with a dot icw/ shallow = true. Below an example.
Reproduction steps
- git clone https://github.com/jeroen/libgit2bug
- call any program with
git_submodule_foreachto list the submodules.
For example this program:
#include <string.h>
#include <stdio.h>
#include <git2.h>
static int submodule_count(git_submodule *submod, const char *name, void *payload){
int *count = payload;
printf("Found submodule %s\n", git_submodule_name(submod));
*count = (*count) + 1;
return 0;
}
int main(int argc, char *argv[]) {
git_repository *repo = NULL;
git_libgit2_init();
int err = git_repository_open(&repo, ".");
if(err){
const git_error *info = giterr_last();
printf("Failure in git_repository_open: %s\n", info->message);
return 1;
}
int n = 0;
git_submodule_foreach(repo, submodule_count, &n);
printf("This function has %d submodules\n", n);
return 0;
}Alternatively you can use the libgit2 example app: libgit2/examples/a.out status --list-submodules on that same repo.
Expected behavior
We iterate over the submodules.
Actual behavior
No submodules are listed.
Version of libgit2 (release number or SHA1)
1.6.4
Operating system(s) tested
MacOS, Linux.
Metadata
Metadata
Assignees
Labels
No labels