summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c3
-rw-r--r--cgit.h2
-rw-r--r--cgitrc5
-rw-r--r--shared.c6
-rw-r--r--ui-commit.c12
5 files changed, 22 insertions, 6 deletions
diff --git a/cgit.c b/cgit.c
index 2795ecc..7b7afba 100644
--- a/cgit.c
+++ b/cgit.c
@@ -78,9 +78,10 @@ static void cgit_print_repo_page(struct cacheitem *item)
title = fmt("%s - %s", cgit_repo->name, cgit_repo->desc);
show_search = 0;
setenv("GIT_DIR", cgit_repo->path, 1);
- if (cgit_query_page && !strcmp(cgit_query_page, "snapshot")) {
+ if (cgit_repo->snapshots && cgit_query_page &&
+ !strcmp(cgit_query_page, "snapshot")) {
cgit_print_snapshot(item, cgit_query_sha1, "zip",
cgit_repo->url, cgit_query_name);
return;
}
diff --git a/cgit.h b/cgit.h
index 03c2fdb..6e95673 100644
--- a/cgit.h
+++ b/cgit.h
@@ -20,8 +20,9 @@ struct repoinfo {
char *name;
char *path;
char *desc;
char *owner;
+ int snapshots;
};
struct repolist {
int length;
@@ -60,8 +61,9 @@ extern char *cgit_logo_link;
extern char *cgit_virtual_root;
extern char *cgit_cache_root;
extern int cgit_nocache;
+extern int cgit_snapshots;
extern int cgit_max_lock_attempts;
extern int cgit_cache_root_ttl;
extern int cgit_cache_repo_ttl;
extern int cgit_cache_dynamic_ttl;
diff --git a/cgitrc b/cgitrc
index d45f9c2..3bae642 100644
--- a/cgitrc
+++ b/cgitrc
@@ -7,8 +7,12 @@
## usefull for testing.
#nocache=0
+## Enable/disable snapshots by default. This can be overridden per repo
+#snapshots=0
+
+
## Specify a root for virtual urls. This makes cgit generate urls like
##
## http://localhost/git/repo/log/?id=master
##
@@ -76,4 +80,5 @@
#repo.name=cgit
#repo.desc=the caching cgi for git
#repo.path=/pub/git/cgit
#repo.owner=Lars Hjemli
+#repo.snapshots=1 # override a sitewide snapshot-setting
diff --git a/shared.c b/shared.c
index 5757d0c..531d8c0 100644
--- a/shared.c
+++ b/shared.c
@@ -19,8 +19,9 @@ char *cgit_virtual_root = NULL;
char *cgit_cache_root = "/var/cache/cgit";
int cgit_nocache = 0;
+int cgit_snapshots = 0;
int cgit_max_lock_attempts = 5;
int cgit_cache_root_ttl = 5;
int cgit_cache_repo_ttl = 5;
int cgit_cache_dynamic_ttl = 5;
@@ -82,8 +83,9 @@ struct repoinfo *add_repo(const char *url)
ret->name = ret->url;
ret->path = NULL;
ret->desc = NULL;
ret->owner = NULL;
+ ret->snapshots = cgit_snapshots;
return ret;
}
void cgit_global_config_cb(const char *name, const char *value)
@@ -99,8 +101,10 @@ void cgit_global_config_cb(const char *name, const char *value)
else if (!strcmp(name, "virtual-root"))
cgit_virtual_root = xstrdup(value);
else if (!strcmp(name, "nocache"))
cgit_nocache = atoi(value);
+ else if (!strcmp(name, "snapshots"))
+ cgit_snapshots = atoi(value);
else if (!strcmp(name, "cache-root"))
cgit_cache_root = xstrdup(value);
else if (!strcmp(name, "cache-root-ttl"))
cgit_cache_root_ttl = atoi(value);
@@ -121,8 +125,10 @@ void cgit_global_config_cb(const char *name, const char *value)
else if (cgit_repo && !strcmp(name, "repo.desc"))
cgit_repo->desc = xstrdup(value);
else if (cgit_repo && !strcmp(name, "repo.owner"))
cgit_repo->owner = xstrdup(value);
+ else if (cgit_repo && !strcmp(name, "repo.snapshots"))
+ cgit_repo->snapshots = atoi(value);
}
void cgit_repo_config_cb(const char *name, const char *value)
{
diff --git a/ui-commit.c b/ui-commit.c
index de3f2cf..3618800 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -168,13 +168,15 @@ void cgit_print_commit(const char *hex)
html_attr(cgit_pageurl(cgit_query_repo, "commit", query));
htmlf("'>%s</a></td></tr>\n",
sha1_to_hex(p->item->object.sha1));
}
- htmlf("<tr><th>download</th><td colspan='2' class='sha1'><a href='");
- filename = fmt("%s-%s.zip", cgit_query_repo, hex);
- html_attr(cgit_pageurl(cgit_query_repo, "snapshot",
- fmt("id=%s&name=%s", hex, filename)));
- htmlf("'>%s</a></td></tr>", filename);
+ if (cgit_repo->snapshots) {
+ htmlf("<tr><th>download</th><td colspan='2' class='sha1'><a href='");
+ filename = fmt("%s-%s.zip", cgit_query_repo, hex);
+ html_attr(cgit_pageurl(cgit_query_repo, "snapshot",
+ fmt("id=%s&name=%s", hex, filename)));
+ htmlf("'>%s</a></td></tr>", filename);
+ }
html("</table>\n");
html("<div class='commit-subject'>");
html_txt(info->subject);