Skip to content

Commit 3dc9294

Browse files
committed
Merge pull request libgit2#2875 from JIghtuse/master
for-each-ref example: initialize libgit2 in main
2 parents 3983935 + 2107dac commit 3dc9294

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

examples/for-each-ref.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ static int show_ref(git_reference *ref, void *data)
3434
int main(int argc, char **argv)
3535
{
3636
git_repository *repo;
37+
git_libgit2_init();
3738

3839
if (argc != 1 || argv[1] /* silence -Wunused-parameter */)
3940
fatal("Sorry, no for-each-ref options supported yet", NULL);
@@ -42,5 +43,7 @@ int main(int argc, char **argv)
4243
"Could not open repository", NULL);
4344
check_lg2(git_reference_foreach(repo, show_ref, repo),
4445
"Could not iterate over references", NULL);
46+
47+
git_libgit2_shutdown();
4548
return 0;
4649
}

0 commit comments

Comments
 (0)