]> oss.titaniummirror.com Git - repo_shell.git/blobdiff - repo_shell.c
Add version option, derived from repository tags
[repo_shell.git] / repo_shell.c
index e11bf5403f105366544085cfbc71aa18b8dbe42b..b51c0add25039ca49e31b232a50a9f3add431fa8 100644 (file)
@@ -8,6 +8,7 @@
 #include <pwd.h>
 #include <string.h>
 #include "ini.h"
+#include "version.h"
 
 #define CFG_FILE "/etc/repo_shell.cfg"
 #define GIT_ACL_FILE "git_acl.cfg"
@@ -164,8 +165,8 @@ static int git_acl(const char *user, const char *repo)
        len = strlen(pw->pw_dir) + strlen(GIT_ACL_FILE) + 2;
        file = xmalloc(sizeof(char) * len);
        sprintf(file, "%s/%s", pw->pw_dir, GIT_ACL_FILE);
-        fprintf(stderr, "[someday check %s]\n", file);
-        free(file);
+       fprintf(stderr, "[someday check %s]\n", file);
+       free(file);
        return 2; /* assume read/write for now */
 }
 
@@ -303,7 +304,7 @@ static struct commands {
 };
 
 static int handler(void* user, const char* section, const char* name,
-                   const char* value)
+               const char* value)
 {
        cfg_t* pconfig = (cfg_t*)user;
 
@@ -339,6 +340,11 @@ int main(int argc, char **argv)
                die("opening /dev/null failed");
        close (devnull_fd);
 
+       if (argc == 2 && (!strcmp(argv[1], "-v") ||
+                       !strcmp(argv[1], "--version"))) {
+               fprintf(stderr, "%s\n", version);
+               return 0;
+        }
        if (argc < 3)
                die("invalid arguments");