]> git.proxmox.com Git - libgit2.git/commitdiff
for-each-ref example: init/shutdown libgit2 in main
authorBoris Egorov <egorov@linux.com>
Wed, 4 Feb 2015 09:14:18 +0000 (15:14 +0600)
committerBoris Egorov <egorov@linux.com>
Thu, 5 Feb 2015 04:51:22 +0000 (10:51 +0600)
I don't get how it was working without git_libgit2_init() call. I run it
and libgit2 throws assertion somewhere in its internals. Now it works.

Updated commit with shutdown at the end.

examples/for-each-ref.c

index d6846bb0d8c175d3db5163d1629b8851d02c2203..a8ceaaff96bd0a23d80ada56345eacdc4abb8367 100644 (file)
@@ -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;
 }