]> git.armaanb.net Git - stagit.git/blobdiff - stagit-index.c
reduce scope of repodir, remove unused branch parameter
[stagit.git] / stagit-index.c
index 1d26e0f9a37172ef191acd884df3cea1bbd21f92..402568b608117968de41903ddc379c60fb1aaf31 100644 (file)
 #include <git2.h>
 
 #include "compat.h"
-#include "config.h"
 
 static git_repository *repo;
 
 static const char *relpath = "";
-static const char *repodir;
 
 static char description[255] = "Repositories";
 static char *name = "";
 static char owner[255];
 
+#ifndef USE_PLEDGE
+int
+pledge(const char *promises, const char *paths[])
+{
+        return 0;
+}
+#endif
+
+void
+joinpath(char *buf, size_t bufsiz, const char *path, const char *path2)
+{
+       int r;
+
+       r = snprintf(buf, bufsiz, "%s%s%s",
+               path, path[0] && path[strlen(path) - 1] != '/' ? "/" : "", path2);
+       if (r == -1 || (size_t)r >= bufsiz)
+               errx(1, "path truncated: '%s%s%s'",
+                       path, path[0] && path[strlen(path) - 1] != '/' ? "/" : "", path2);
+}
+
 /* Escape characters below as HTML 2.0 / XML 1.0. */
 void
 xmlencode(FILE *fp, const char *s, size_t len)
@@ -55,7 +73,7 @@ printtimeshort(FILE *fp, const git_time *intime)
        fputs(out, fp);
 }
 
-int
+void
 writeheader(FILE *fp)
 {
        fputs("<!DOCTYPE html>\n"
@@ -73,14 +91,12 @@ writeheader(FILE *fp)
              "<table id=\"index\"><thead>\n"
              "<tr><td>Name</td><td>Description</td><td>Owner</td><td>Last commit</td></tr>"
              "</thead><tbody>\n", fp);
-
-       return 0;
 }
 
-int
+void
 writefooter(FILE *fp)
 {
-       return !fputs("</tbody>\n</table>\n</div>\n</body>\n</html>\n", fp);
+       fputs("</tbody>\n</table>\n</div>\n</body>\n</html>\n", fp);
 }
 
 int
@@ -134,26 +150,18 @@ err:
        return ret;
 }
 
-void
-joinpath(char *buf, size_t bufsiz, const char *path, const char *path2)
-{
-       int r;
-
-       r = snprintf(buf, bufsiz, "%s%s%s",
-               repodir, path[0] && path[strlen(path) - 1] != '/' ? "/" : "", path2);
-       if (r == -1 || (size_t)r >= bufsiz)
-               errx(1, "path truncated: '%s%s%s'",
-                       path, path[0] && path[strlen(path) - 1] != '/' ? "/" : "", path2);
-}
-
 int
 main(int argc, char *argv[])
 {
        const git_error *e = NULL;
        FILE *fp;
        char path[PATH_MAX], repodirabs[PATH_MAX + 1];
+       const char *repodir;
        int i, ret = 0;
 
+       if (pledge("stdio rpath", NULL) == -1)
+               err(1, "pledge");
+
        if (argc < 2) {
                fprintf(stderr, "%s [repodir...]\n", argv[0]);
                return 1;