summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2015-05-02 10:51:24 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2015-05-02 10:51:24 -0400
commit72f8da9175c823036077445915309e250d802b3b (patch)
tree3b825f3b611e30e7950ea1edb55a820481620c30
parentef23a82fa751a2aa64ca0c0807311c5a0c503681 (diff)
parent785990bead1a717698eb0c2603e3d0b2ee51262f (diff)
downloadlibgit2-72f8da9175c823036077445915309e250d802b3b.tar.gz
Merge pull request #3089 from volftomas/patch-2
Added call to git_libgit2_shutdown()
-rw-r--r--examples/network/git2.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/examples/network/git2.c b/examples/network/git2.c
index d44334b85..448103c46 100644
--- a/examples/network/git2.c
+++ b/examples/network/git2.c
@@ -23,8 +23,8 @@ static int run_command(git_cb fn, int argc, char **argv)
int error;
git_repository *repo;
-// Before running the actual command, create an instance of the local
-// repository and pass it to the function.
+ // Before running the actual command, create an instance of the local
+ // repository and pass it to the function.
error = git_repository_open(&repo, ".git");
if (error < 0)
@@ -48,6 +48,7 @@ static int run_command(git_cb fn, int argc, char **argv)
int main(int argc, char **argv)
{
int i;
+ int return_code = 1;
if (argc < 2) {
fprintf(stderr, "usage: %s <cmd> [repo]\n", argv[0]);
@@ -57,10 +58,16 @@ int main(int argc, char **argv)
git_libgit2_init();
for (i = 0; commands[i].name != NULL; ++i) {
- if (!strcmp(argv[1], commands[i].name))
- return run_command(commands[i].fn, --argc, ++argv);
+ if (!strcmp(argv[1], commands[i].name)) {
+ return_code = run_command(commands[i].fn, --argc, ++argv);
+ goto shutdown;
+ }
}
fprintf(stderr, "Command not found: %s\n", argv[1]);
- return 1;
+
+shutdown:
+ git_libgit2_shutdown();
+
+ return return_code;
}