Commit 3dc92940c8606b55c1ed35552ab6fa3b113dd2bd

Edward Thomson 2015-02-05T09:18:47

Merge pull request #2875 from JIghtuse/master for-each-ref example: initialize libgit2 in main

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/examples/for-each-ref.c b/examples/for-each-ref.c
index d6846bb..a8ceaaf 100644
--- a/examples/for-each-ref.c
+++ b/examples/for-each-ref.c
@@ -34,6 +34,7 @@ static int show_ref(git_reference *ref, void *data)
 int main(int argc, char **argv)
 {
         git_repository *repo;
+        git_libgit2_init();
 
         if (argc != 1 || argv[1] /* silence -Wunused-parameter */)
                 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);
         check_lg2(git_reference_foreach(repo, show_ref, repo),
                   "Could not iterate over references", NULL);
+
+        git_libgit2_shutdown();
         return 0;
 }