summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Egorov <egorov@linux.com>2015-02-04 15:14:18 +0600
committerBoris Egorov <egorov@linux.com>2015-02-05 10:51:22 +0600
commit2107dac34624421015c3a633975bde0ff797ba53 (patch)
treee76fb61487dd249dee6d096ce648676fc47377f4
parentf9e7abcbe2e9961f0e7ee603b67b81aa59134d87 (diff)
downloadlibgit2-2107dac34624421015c3a633975bde0ff797ba53.tar.gz
for-each-ref example: init/shutdown libgit2 in main
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.
-rw-r--r--examples/for-each-ref.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/examples/for-each-ref.c b/examples/for-each-ref.c
index d6846bb0d..a8ceaaff9 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;
}