-rw-r--r-- | cgit.c | 3 | ||||
-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | cgitrc | 5 | ||||
-rw-r--r-- | shared.c | 6 | ||||
-rw-r--r-- | ui-commit.c | 12 |
5 files changed, 22 insertions, 6 deletions
@@ -78,9 +78,10 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
78 | title = fmt("%s - %s", cgit_repo->name, cgit_repo->desc); | 78 | title = fmt("%s - %s", cgit_repo->name, cgit_repo->desc); |
79 | show_search = 0; | 79 | show_search = 0; |
80 | setenv("GIT_DIR", cgit_repo->path, 1); | 80 | setenv("GIT_DIR", cgit_repo->path, 1); |
81 | 81 | ||
82 | if (cgit_query_page && !strcmp(cgit_query_page, "snapshot")) { | 82 | if (cgit_repo->snapshots && cgit_query_page && |
83 | !strcmp(cgit_query_page, "snapshot")) { | ||
83 | cgit_print_snapshot(item, cgit_query_sha1, "zip", | 84 | cgit_print_snapshot(item, cgit_query_sha1, "zip", |
84 | cgit_repo->url, cgit_query_name); | 85 | cgit_repo->url, cgit_query_name); |
85 | return; | 86 | return; |
86 | } | 87 | } |
@@ -20,8 +20,9 @@ struct repoinfo { | |||
20 | char *name; | 20 | char *name; |
21 | char *path; | 21 | char *path; |
22 | char *desc; | 22 | char *desc; |
23 | char *owner; | 23 | char *owner; |
24 | int snapshots; | ||
24 | }; | 25 | }; |
25 | 26 | ||
26 | struct repolist { | 27 | struct repolist { |
27 | int length; | 28 | int length; |
@@ -60,8 +61,9 @@ extern char *cgit_logo_link; | |||
60 | extern char *cgit_virtual_root; | 61 | extern char *cgit_virtual_root; |
61 | extern char *cgit_cache_root; | 62 | extern char *cgit_cache_root; |
62 | 63 | ||
63 | extern int cgit_nocache; | 64 | extern int cgit_nocache; |
65 | extern int cgit_snapshots; | ||
64 | extern int cgit_max_lock_attempts; | 66 | extern int cgit_max_lock_attempts; |
65 | extern int cgit_cache_root_ttl; | 67 | extern int cgit_cache_root_ttl; |
66 | extern int cgit_cache_repo_ttl; | 68 | extern int cgit_cache_repo_ttl; |
67 | extern int cgit_cache_dynamic_ttl; | 69 | extern int cgit_cache_dynamic_ttl; |
@@ -7,8 +7,12 @@ | |||
7 | ## usefull for testing. | 7 | ## usefull for testing. |
8 | #nocache=0 | 8 | #nocache=0 |
9 | 9 | ||
10 | 10 | ||
11 | ## Enable/disable snapshots by default. This can be overridden per repo | ||
12 | #snapshots=0 | ||
13 | |||
14 | |||
11 | ## Specify a root for virtual urls. This makes cgit generate urls like | 15 | ## Specify a root for virtual urls. This makes cgit generate urls like |
12 | ## | 16 | ## |
13 | ## http://localhost/git/repo/log/?id=master | 17 | ## http://localhost/git/repo/log/?id=master |
14 | ## | 18 | ## |
@@ -76,4 +80,5 @@ | |||
76 | #repo.name=cgit | 80 | #repo.name=cgit |
77 | #repo.desc=the caching cgi for git | 81 | #repo.desc=the caching cgi for git |
78 | #repo.path=/pub/git/cgit | 82 | #repo.path=/pub/git/cgit |
79 | #repo.owner=Lars Hjemli | 83 | #repo.owner=Lars Hjemli |
84 | #repo.snapshots=1 # override a sitewide snapshot-setting | ||
@@ -19,8 +19,9 @@ char *cgit_virtual_root = NULL; | |||
19 | 19 | ||
20 | char *cgit_cache_root = "/var/cache/cgit"; | 20 | char *cgit_cache_root = "/var/cache/cgit"; |
21 | 21 | ||
22 | int cgit_nocache = 0; | 22 | int cgit_nocache = 0; |
23 | int cgit_snapshots = 0; | ||
23 | int cgit_max_lock_attempts = 5; | 24 | int cgit_max_lock_attempts = 5; |
24 | int cgit_cache_root_ttl = 5; | 25 | int cgit_cache_root_ttl = 5; |
25 | int cgit_cache_repo_ttl = 5; | 26 | int cgit_cache_repo_ttl = 5; |
26 | int cgit_cache_dynamic_ttl = 5; | 27 | int cgit_cache_dynamic_ttl = 5; |
@@ -82,8 +83,9 @@ struct repoinfo *add_repo(const char *url) | |||
82 | ret->name = ret->url; | 83 | ret->name = ret->url; |
83 | ret->path = NULL; | 84 | ret->path = NULL; |
84 | ret->desc = NULL; | 85 | ret->desc = NULL; |
85 | ret->owner = NULL; | 86 | ret->owner = NULL; |
87 | ret->snapshots = cgit_snapshots; | ||
86 | return ret; | 88 | return ret; |
87 | } | 89 | } |
88 | 90 | ||
89 | void cgit_global_config_cb(const char *name, const char *value) | 91 | 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) | |||
99 | else if (!strcmp(name, "virtual-root")) | 101 | else if (!strcmp(name, "virtual-root")) |
100 | cgit_virtual_root = xstrdup(value); | 102 | cgit_virtual_root = xstrdup(value); |
101 | else if (!strcmp(name, "nocache")) | 103 | else if (!strcmp(name, "nocache")) |
102 | cgit_nocache = atoi(value); | 104 | cgit_nocache = atoi(value); |
105 | else if (!strcmp(name, "snapshots")) | ||
106 | cgit_snapshots = atoi(value); | ||
103 | else if (!strcmp(name, "cache-root")) | 107 | else if (!strcmp(name, "cache-root")) |
104 | cgit_cache_root = xstrdup(value); | 108 | cgit_cache_root = xstrdup(value); |
105 | else if (!strcmp(name, "cache-root-ttl")) | 109 | else if (!strcmp(name, "cache-root-ttl")) |
106 | cgit_cache_root_ttl = atoi(value); | 110 | cgit_cache_root_ttl = atoi(value); |
@@ -121,8 +125,10 @@ void cgit_global_config_cb(const char *name, const char *value) | |||
121 | else if (cgit_repo && !strcmp(name, "repo.desc")) | 125 | else if (cgit_repo && !strcmp(name, "repo.desc")) |
122 | cgit_repo->desc = xstrdup(value); | 126 | cgit_repo->desc = xstrdup(value); |
123 | else if (cgit_repo && !strcmp(name, "repo.owner")) | 127 | else if (cgit_repo && !strcmp(name, "repo.owner")) |
124 | cgit_repo->owner = xstrdup(value); | 128 | cgit_repo->owner = xstrdup(value); |
129 | else if (cgit_repo && !strcmp(name, "repo.snapshots")) | ||
130 | cgit_repo->snapshots = atoi(value); | ||
125 | } | 131 | } |
126 | 132 | ||
127 | void cgit_repo_config_cb(const char *name, const char *value) | 133 | void cgit_repo_config_cb(const char *name, const char *value) |
128 | { | 134 | { |
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) | |||
168 | html_attr(cgit_pageurl(cgit_query_repo, "commit", query)); | 168 | html_attr(cgit_pageurl(cgit_query_repo, "commit", query)); |
169 | htmlf("'>%s</a></td></tr>\n", | 169 | htmlf("'>%s</a></td></tr>\n", |
170 | sha1_to_hex(p->item->object.sha1)); | 170 | sha1_to_hex(p->item->object.sha1)); |
171 | } | 171 | } |
172 | htmlf("<tr><th>download</th><td colspan='2' class='sha1'><a href='"); | 172 | if (cgit_repo->snapshots) { |
173 | filename = fmt("%s-%s.zip", cgit_query_repo, hex); | 173 | htmlf("<tr><th>download</th><td colspan='2' class='sha1'><a href='"); |
174 | html_attr(cgit_pageurl(cgit_query_repo, "snapshot", | 174 | filename = fmt("%s-%s.zip", cgit_query_repo, hex); |
175 | fmt("id=%s&name=%s", hex, filename))); | 175 | html_attr(cgit_pageurl(cgit_query_repo, "snapshot", |
176 | htmlf("'>%s</a></td></tr>", filename); | 176 | fmt("id=%s&name=%s", hex, filename))); |
177 | htmlf("'>%s</a></td></tr>", filename); | ||
178 | } | ||
177 | 179 | ||
178 | html("</table>\n"); | 180 | html("</table>\n"); |
179 | html("<div class='commit-subject'>"); | 181 | html("<div class='commit-subject'>"); |
180 | html_txt(info->subject); | 182 | html_txt(info->subject); |