Make snapshot feature configurable Snapshots can now be enabled/disabled by default for all repositories in cgitrc with param "snapshots". Additionally, any repo can override the default setting with param "repo.snapshots". By default, no snapshotting is enabled. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Lars Hjemli hjemli@gmail.com
Thu, 08 Feb 2007 14:47:56 +0100
5 files changed,
22 insertions(+),
6 deletions(-)
M
cgit.c
→
cgit.c
@@ -79,7 +79,8 @@ 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;
M
cgit.h
→
cgit.h
@@ -21,6 +21,7 @@ char *name;
char *path; char *desc; char *owner; + int snapshots; }; struct repolist {@@ -61,6 +62,7 @@ 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;
M
cgitrc
→
cgitrc
@@ -8,6 +8,10 @@ ## 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@@ -77,3 +81,4 @@ #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
M
ui-commit.c
→
ui-commit.c
@@ -169,11 +169,13 @@ 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'>");