summaryrefslogtreecommitdiffabout
path: root/shared.c
Side-by-side diff
Diffstat (limited to 'shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--shared.c45
1 files changed, 40 insertions, 5 deletions
diff --git a/shared.c b/shared.c
index b6d2fa1..077934f 100644
--- a/shared.c
+++ b/shared.c
@@ -14,2 +14,4 @@ int cgit_cmd;
+const char *cgit_version = CGIT_VERSION;
+
char *cgit_root_title = "Git repository browser";
@@ -28,2 +30,3 @@ int cgit_nocache = 0;
int cgit_snapshots = 0;
+int cgit_enable_index_links = 0;
int cgit_enable_log_filecount = 0;
@@ -61,3 +64,4 @@ int cgit_get_cmd_index(const char *cmd)
{
- static char *cmds[] = {"log", "commit", "diff", "tree", "view", "blob", "snapshot", NULL};
+ static char *cmds[] = {"log", "commit", "diff", "tree", "blob",
+ "snapshot", "tag", NULL};
int i;
@@ -84,2 +88,9 @@ int chk_positive(int result, char *msg)
+int chk_non_negative(int result, char *msg)
+{
+ if (result < 0)
+ die("%s: %s",msg, strerror(errno));
+ return result;
+}
+
struct repoinfo *add_repo(const char *url)
@@ -146,3 +157,5 @@ void cgit_global_config_cb(const char *name, const char *value)
else if (!strcmp(name, "snapshots"))
- cgit_snapshots = atoi(value);
+ cgit_snapshots = cgit_parse_snapshots_mask(value);
+ else if (!strcmp(name, "enable-index-links"))
+ cgit_enable_index_links = atoi(value);
else if (!strcmp(name, "enable-log-filecount"))
@@ -186,3 +199,3 @@ void cgit_global_config_cb(const char *name, const char *value)
else if (cgit_repo && !strcmp(name, "repo.snapshots"))
- cgit_repo->snapshots = cgit_snapshots * atoi(value);
+ cgit_repo->snapshots = cgit_snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */
else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount"))
@@ -226,3 +239,3 @@ void cgit_querystring_cb(const char *name, const char *value)
} else if (!strcmp(name, "path")) {
- cgit_query_path = xstrdup(value);
+ cgit_query_path = trim_end(value, '/');
} else if (!strcmp(name, "name")) {
@@ -255,2 +268,24 @@ int hextoint(char c)
+char *trim_end(const char *str, char c)
+{
+ int len;
+ char *s, *t;
+
+ if (str == NULL)
+ return NULL;
+ t = (char *)str;
+ len = strlen(t);
+ while(len > 0 && t[len - 1] == c)
+ len--;
+
+ if (len == 0)
+ return NULL;
+
+ c = t[len];
+ t[len] = '\0';
+ s = xstrdup(t);
+ t[len] = c;
+ return s;
+}
+
void cgit_diff_tree_cb(struct diff_queue_struct *q,
@@ -361,3 +396,3 @@ void cgit_diff_tree(const unsigned char *old_sha1,
- if (old_sha1)
+ if (old_sha1 && !is_null_sha1(old_sha1))
ret = diff_tree_sha1(old_sha1, new_sha1, "", &opt);