Merge pull request #2875 from JIghtuse/master

for-each-ref example: initialize libgit2 in main
This commit is contained in:
Edward Thomson 2015-02-05 09:18:47 -05:00
commit 3dc92940c8

View File

@ -34,6 +34,7 @@ static int show_ref(git_reference *ref, void *data)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
git_repository *repo; git_repository *repo;
git_libgit2_init();
if (argc != 1 || argv[1] /* silence -Wunused-parameter */) if (argc != 1 || argv[1] /* silence -Wunused-parameter */)
fatal("Sorry, no for-each-ref options supported yet", NULL); fatal("Sorry, no for-each-ref options supported yet", NULL);
@ -42,5 +43,7 @@ int main(int argc, char **argv)
"Could not open repository", NULL); "Could not open repository", NULL);
check_lg2(git_reference_foreach(repo, show_ref, repo), check_lg2(git_reference_foreach(repo, show_ref, repo),
"Could not iterate over references", NULL); "Could not iterate over references", NULL);
git_libgit2_shutdown();
return 0; return 0;
} }