]> git.armaanb.net Git - stagit.git/commitdiff
pledge after git_libgit2_init
authorHiltjo Posthuma <hiltjo@codemadness.org>
Mon, 26 Mar 2018 18:08:19 +0000 (20:08 +0200)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Mon, 26 Mar 2018 18:08:19 +0000 (20:08 +0200)
this is because libgit uses curl which uses some initialization
checks, namely an IPv6 check which creates a socket.

stagit.c

index 6c9b5c0def1b3ac717abe3629782dd1a0cad1504..e1c862176cf39db6fc58540752b653debd60bdb5 100644 (file)
--- a/stagit.c
+++ b/stagit.c
@@ -1027,9 +1027,6 @@ main(int argc, char *argv[])
        size_t n;
        int i, fd;
 
-       if (pledge("stdio rpath wpath cpath fattr", NULL) == -1)
-               err(1, "pledge");
-
        for (i = 1; i < argc; i++) {
                if (argv[i][0] != '-') {
                        if (repodir)
@@ -1052,8 +1049,6 @@ main(int argc, char *argv[])
                                usage(argv[0]);
                }
        }
-       if (!cachefile && pledge("stdio rpath wpath cpath", NULL) == -1)
-               err(1, "pledge");
        if (!repodir)
                usage(argv[0]);
 
@@ -1062,6 +1057,14 @@ main(int argc, char *argv[])
 
        git_libgit2_init();
 
+       if (cachefile) {
+               if (pledge("stdio rpath wpath cpath fattr", NULL) == -1)
+                       err(1, "pledge");
+       } else {
+               if (pledge("stdio rpath wpath cpath", NULL) == -1)
+                       err(1, "pledge");
+       }
+
        if (git_repository_open_ext(&repo, repodir,
                GIT_REPOSITORY_OPEN_NO_SEARCH, NULL) < 0) {
                e = giterr_last();