diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | cgit.c | 45 | ||||
-rw-r--r-- | cgit.css | 39 | ||||
-rw-r--r-- | cgit.h | 3 | ||||
-rw-r--r-- | cmd.c | 3 | ||||
m--------- | git | 0 | ||||
-rw-r--r-- | shared.c | 5 | ||||
-rwxr-xr-x | tests/t0107-snapshot.sh | 22 | ||||
-rw-r--r-- | ui-log.c | 71 | ||||
-rw-r--r-- | ui-refs.c | 42 | ||||
-rw-r--r-- | ui-repolist.c | 137 | ||||
-rw-r--r-- | ui-shared.c | 29 | ||||
-rw-r--r-- | ui-shared.h | 2 | ||||
-rw-r--r-- | ui-snapshot.c | 100 | ||||
-rw-r--r-- | ui-snapshot.h | 3 | ||||
-rw-r--r-- | ui-tag.c | 11 | ||||
-rw-r--r-- | ui-tree.c | 2 |
17 files changed, 392 insertions, 124 deletions
@@ -4,7 +4,7 @@ CGIT_SCRIPT_PATH = /var/www/htdocs/cgit | |||
4 | CGIT_CONFIG = /etc/cgitrc | 4 | CGIT_CONFIG = /etc/cgitrc |
5 | CACHE_ROOT = /var/cache/cgit | 5 | CACHE_ROOT = /var/cache/cgit |
6 | SHA1_HEADER = <openssl/sha.h> | 6 | SHA1_HEADER = <openssl/sha.h> |
7 | GIT_VER = 1.6.0.3 | 7 | GIT_VER = 1.6.1 |
8 | GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 | 8 | GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 |
9 | 9 | ||
10 | # Define NO_STRCASESTR if you don't have strcasestr. | 10 | # Define NO_STRCASESTR if you don't have strcasestr. |
@@ -154,6 +154,10 @@ static void querystring_cb(const char *name, const char *value) | |||
154 | ctx.qry.name = xstrdup(value); | 154 | ctx.qry.name = xstrdup(value); |
155 | } else if (!strcmp(name, "mimetype")) { | 155 | } else if (!strcmp(name, "mimetype")) { |
156 | ctx.qry.mimetype = xstrdup(value); | 156 | ctx.qry.mimetype = xstrdup(value); |
157 | } else if (!strcmp(name, "s")){ | ||
158 | ctx.qry.sort = xstrdup(value); | ||
159 | } else if (!strcmp(name, "showmsg")) { | ||
160 | ctx.qry.showmsg = atoi(value); | ||
157 | } | 161 | } |
158 | } | 162 | } |
159 | 163 | ||
@@ -434,28 +438,29 @@ int main(int argc, const char **argv) | |||
434 | ctx.repo = NULL; | 438 | ctx.repo = NULL; |
435 | http_parse_querystring(ctx.qry.raw, querystring_cb); | 439 | http_parse_querystring(ctx.qry.raw, querystring_cb); |
436 | 440 | ||
437 | /* If virtual-root isn't specified in cgitrc and no url | 441 | /* If virtual-root isn't specified in cgitrc, lets pretend |
438 | * parameter is specified on the querystring, lets pretend | 442 | * that virtual-root equals SCRIPT_NAME. |
439 | * that virtualroot equals SCRIPT_NAME and use PATH_INFO as | ||
440 | * url. This allows cgit to work with virtual urls without | ||
441 | * the need for rewriterules in the webserver (as long as | ||
442 | * PATH_INFO is included in the cache lookup key). | ||
443 | */ | 443 | */ |
444 | if (!ctx.cfg.virtual_root && !ctx.qry.url) { | 444 | if (!ctx.cfg.virtual_root) |
445 | ctx.cfg.virtual_root = ctx.cfg.script_name; | 445 | ctx.cfg.virtual_root = ctx.cfg.script_name; |
446 | path = getenv("PATH_INFO"); | 446 | |
447 | if (path) { | 447 | /* If no url parameter is specified on the querystring, lets |
448 | if (path[0] == '/') | 448 | * use PATH_INFO as url. This allows cgit to work with virtual |
449 | path++; | 449 | * urls without the need for rewriterules in the webserver (as |
450 | ctx.qry.url = xstrdup(path); | 450 | * long as PATH_INFO is included in the cache lookup key). |
451 | if (ctx.qry.raw) { | 451 | */ |
452 | qry = ctx.qry.raw; | 452 | path = getenv("PATH_INFO"); |
453 | ctx.qry.raw = xstrdup(fmt("%s?%s", path, qry)); | 453 | if (!ctx.qry.url && path) { |
454 | free(qry); | 454 | if (path[0] == '/') |
455 | } else | 455 | path++; |
456 | ctx.qry.raw = ctx.qry.url; | 456 | ctx.qry.url = xstrdup(path); |
457 | cgit_parse_url(ctx.qry.url); | 457 | if (ctx.qry.raw) { |
458 | } | 458 | qry = ctx.qry.raw; |
459 | ctx.qry.raw = xstrdup(fmt("%s?%s", path, qry)); | ||
460 | free(qry); | ||
461 | } else | ||
462 | ctx.qry.raw = ctx.qry.url; | ||
463 | cgit_parse_url(ctx.qry.url); | ||
459 | } | 464 | } |
460 | 465 | ||
461 | ttl = calc_ttl(); | 466 | ttl = calc_ttl(); |
@@ -120,6 +120,10 @@ table.list tr { | |||
120 | background: white; | 120 | background: white; |
121 | } | 121 | } |
122 | 122 | ||
123 | table.list tr.logheader { | ||
124 | background: #eee; | ||
125 | } | ||
126 | |||
123 | table.list tr:hover { | 127 | table.list tr:hover { |
124 | background: #eee; | 128 | background: #eee; |
125 | } | 129 | } |
@@ -143,6 +147,17 @@ table.list td { | |||
143 | padding: 0.1em 0.5em 0.1em 0.5em; | 147 | padding: 0.1em 0.5em 0.1em 0.5em; |
144 | } | 148 | } |
145 | 149 | ||
150 | table.list td.logsubject { | ||
151 | font-family: monospace; | ||
152 | font-weight: bold; | ||
153 | } | ||
154 | |||
155 | table.list td.logmsg { | ||
156 | font-family: monospace; | ||
157 | white-space: pre; | ||
158 | padding: 1em 0em 2em 0em; | ||
159 | } | ||
160 | |||
146 | table.list td a { | 161 | table.list td a { |
147 | color: black; | 162 | color: black; |
148 | } | 163 | } |
@@ -456,3 +471,27 @@ div.footer { | |||
456 | font-size: 80%; | 471 | font-size: 80%; |
457 | color: #ccc; | 472 | color: #ccc; |
458 | } | 473 | } |
474 | a.branch-deco { | ||
475 | margin: 0px 0.5em; | ||
476 | padding: 0px 0.25em; | ||
477 | background-color: #88ff88; | ||
478 | border: solid 1px #007700; | ||
479 | } | ||
480 | a.tag-deco { | ||
481 | margin: 0px 0.5em; | ||
482 | padding: 0px 0.25em; | ||
483 | background-color: #ffff88; | ||
484 | border: solid 1px #777700; | ||
485 | } | ||
486 | a.remote-deco { | ||
487 | margin: 0px 0.5em; | ||
488 | padding: 0px 0.25em; | ||
489 | background-color: #ccccff; | ||
490 | border: solid 1px #000077; | ||
491 | } | ||
492 | a.deco { | ||
493 | margin: 0px 0.5em; | ||
494 | padding: 0px 0.25em; | ||
495 | background-color: #ff8888; | ||
496 | border: solid 1px #770000; | ||
497 | } | ||
@@ -61,6 +61,7 @@ struct cgit_repo { | |||
61 | int snapshots; | 61 | int snapshots; |
62 | int enable_log_filecount; | 62 | int enable_log_filecount; |
63 | int enable_log_linecount; | 63 | int enable_log_linecount; |
64 | time_t mtime; | ||
64 | }; | 65 | }; |
65 | 66 | ||
66 | struct cgit_repolist { | 67 | struct cgit_repolist { |
@@ -121,6 +122,8 @@ struct cgit_query { | |||
121 | char *url; | 122 | char *url; |
122 | int ofs; | 123 | int ofs; |
123 | int nohead; | 124 | int nohead; |
125 | char *sort; | ||
126 | int showmsg; | ||
124 | }; | 127 | }; |
125 | 128 | ||
126 | struct cgit_config { | 129 | struct cgit_config { |
@@ -104,8 +104,7 @@ static void refs_fn(struct cgit_context *ctx) | |||
104 | 104 | ||
105 | static void snapshot_fn(struct cgit_context *ctx) | 105 | static void snapshot_fn(struct cgit_context *ctx) |
106 | { | 106 | { |
107 | cgit_print_snapshot(ctx->qry.head, ctx->qry.sha1, | 107 | cgit_print_snapshot(ctx->qry.head, ctx->qry.sha1, ctx->qry.path, |
108 | cgit_repobasename(ctx->repo->url), ctx->qry.path, | ||
109 | ctx->repo->snapshots, ctx->qry.nohead); | 108 | ctx->repo->snapshots, ctx->qry.nohead); |
110 | } | 109 | } |
111 | 110 | ||
diff --git a/git b/git | |||
Subproject 031e6c898f61db1ae0c0be641eac6532c1000d5 | Subproject 8104ebfe8276657ee803cca7eb8665a78cf3ef8 | ||
@@ -60,6 +60,7 @@ struct cgit_repo *cgit_add_repo(const char *url) | |||
60 | ret->enable_log_linecount = ctx.cfg.enable_log_linecount; | 60 | ret->enable_log_linecount = ctx.cfg.enable_log_linecount; |
61 | ret->module_link = ctx.cfg.module_link; | 61 | ret->module_link = ctx.cfg.module_link; |
62 | ret->readme = NULL; | 62 | ret->readme = NULL; |
63 | ret->mtime = -1; | ||
63 | return ret; | 64 | return ret; |
64 | } | 65 | } |
65 | 66 | ||
@@ -266,10 +267,12 @@ int cgit_diff_files(const unsigned char *old_sha1, | |||
266 | if (!load_mmfile(&file1, old_sha1) || !load_mmfile(&file2, new_sha1)) | 267 | if (!load_mmfile(&file1, old_sha1) || !load_mmfile(&file2, new_sha1)) |
267 | return 1; | 268 | return 1; |
268 | 269 | ||
270 | memset(&diff_params, 0, sizeof(diff_params)); | ||
271 | memset(&emit_params, 0, sizeof(emit_params)); | ||
272 | memset(&emit_cb, 0, sizeof(emit_cb)); | ||
269 | diff_params.flags = XDF_NEED_MINIMAL; | 273 | diff_params.flags = XDF_NEED_MINIMAL; |
270 | emit_params.ctxlen = 3; | 274 | emit_params.ctxlen = 3; |
271 | emit_params.flags = XDL_EMIT_FUNCNAMES; | 275 | emit_params.flags = XDL_EMIT_FUNCNAMES; |
272 | emit_params.find_func = NULL; | ||
273 | emit_cb.outf = filediff_cb; | 276 | emit_cb.outf = filediff_cb; |
274 | emit_cb.priv = fn; | 277 | emit_cb.priv = fn; |
275 | xdl_diff(&file1, &file2, &diff_params, &emit_params, &emit_cb); | 278 | xdl_diff(&file1, &file2, &diff_params, &emit_params, &emit_cb); |
diff --git a/tests/t0107-snapshot.sh b/tests/t0107-snapshot.sh index d97c465..8ab4912 100755 --- a/tests/t0107-snapshot.sh +++ b/tests/t0107-snapshot.sh | |||
@@ -4,36 +4,36 @@ | |||
4 | 4 | ||
5 | prepare_tests "Verify snapshot" | 5 | prepare_tests "Verify snapshot" |
6 | 6 | ||
7 | run_test 'get foo/snapshot/test.tar.gz' ' | 7 | run_test 'get foo/snapshot/master.tar.gz' ' |
8 | cgit_url "foo/snapshot/test.tar.gz" >trash/tmp | 8 | cgit_url "foo/snapshot/master.tar.gz" >trash/tmp |
9 | ' | 9 | ' |
10 | 10 | ||
11 | run_test 'check html headers' ' | 11 | run_test 'check html headers' ' |
12 | head -n 1 trash/tmp | | 12 | head -n 1 trash/tmp | |
13 | grep -e "Content-Type: application/x-tar" && | 13 | grep -e "Content-Type: application/x-gzip" && |
14 | 14 | ||
15 | head -n 2 trash/tmp | | 15 | head -n 2 trash/tmp | |
16 | grep -e "Content-Disposition: inline; filename=.test.tar.gz." | 16 | grep -e "Content-Disposition: inline; filename=.master.tar.gz." |
17 | ' | 17 | ' |
18 | 18 | ||
19 | run_test 'strip off the header lines' ' | 19 | run_test 'strip off the header lines' ' |
20 | tail -n +6 trash/tmp > trash/test.tar.gz | 20 | tail -n +6 trash/tmp > trash/master.tar.gz |
21 | ' | 21 | ' |
22 | 22 | ||
23 | run_test 'verify gzip format' 'gunzip --test trash/test.tar.gz' | 23 | run_test 'verify gzip format' 'gunzip --test trash/master.tar.gz' |
24 | run_test 'untar' ' | 24 | run_test 'untar' ' |
25 | rm -rf trash/foo && | 25 | rm -rf trash/master && |
26 | tar -xf trash/test.tar.gz -C trash | 26 | tar -xf trash/master.tar.gz -C trash |
27 | ' | 27 | ' |
28 | 28 | ||
29 | run_test 'count files' ' | 29 | run_test 'count files' ' |
30 | c=$(ls -1 trash/foo/ | wc -l) && | 30 | c=$(ls -1 trash/master/ | wc -l) && |
31 | test $c = 5 | 31 | test $c = 5 |
32 | ' | 32 | ' |
33 | 33 | ||
34 | run_test 'verify untarred file-5' ' | 34 | run_test 'verify untarred file-5' ' |
35 | grep -e "^5$" trash/foo/file-5 && | 35 | grep -e "^5$" trash/master/file-5 && |
36 | test $(cat trash/foo/file-5 | wc -l) = 1 | 36 | test $(cat trash/master/file-5 | wc -l) = 1 |
37 | ' | 37 | ' |
38 | 38 | ||
39 | tests_done | 39 | tests_done |
@@ -31,21 +31,57 @@ void inspect_files(struct diff_filepair *pair) | |||
31 | cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines); | 31 | cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines); |
32 | } | 32 | } |
33 | 33 | ||
34 | void show_commit_decorations(struct commit *commit) | ||
35 | { | ||
36 | struct name_decoration *deco; | ||
37 | static char buf[1024]; | ||
38 | |||
39 | buf[sizeof(buf) - 1] = 0; | ||
40 | deco = lookup_decoration(&name_decoration, &commit->object); | ||
41 | while (deco) { | ||
42 | if (!prefixcmp(deco->name, "refs/heads/")) { | ||
43 | strncpy(buf, deco->name + 11, sizeof(buf) - 1); | ||
44 | cgit_log_link(buf, NULL, "branch-deco", buf, NULL, NULL, | ||
45 | 0, NULL, NULL, ctx.qry.showmsg); | ||
46 | } | ||
47 | else if (!prefixcmp(deco->name, "tag: refs/tags/")) { | ||
48 | strncpy(buf, deco->name + 15, sizeof(buf) - 1); | ||
49 | cgit_tag_link(buf, NULL, "tag-deco", ctx.qry.head, buf); | ||
50 | } | ||
51 | else if (!prefixcmp(deco->name, "refs/remotes/")) { | ||
52 | strncpy(buf, deco->name + 13, sizeof(buf) - 1); | ||
53 | cgit_log_link(buf, NULL, "remote-deco", NULL, | ||
54 | sha1_to_hex(commit->object.sha1), NULL, | ||
55 | 0, NULL, NULL, ctx.qry.showmsg); | ||
56 | } | ||
57 | else { | ||
58 | strncpy(buf, deco->name, sizeof(buf) - 1); | ||
59 | cgit_commit_link(buf, NULL, "deco", ctx.qry.head, | ||
60 | sha1_to_hex(commit->object.sha1)); | ||
61 | } | ||
62 | deco = deco->next; | ||
63 | } | ||
64 | } | ||
65 | |||
34 | void print_commit(struct commit *commit) | 66 | void print_commit(struct commit *commit) |
35 | { | 67 | { |
36 | struct commitinfo *info; | 68 | struct commitinfo *info; |
37 | char *tmp; | 69 | char *tmp; |
70 | int cols = 2; | ||
38 | 71 | ||
39 | info = cgit_parse_commit(commit); | 72 | info = cgit_parse_commit(commit); |
40 | html("<tr><td>"); | 73 | htmlf("<tr%s><td>", |
74 | ctx.qry.showmsg ? " class='logheader'" : ""); | ||
41 | tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1)); | 75 | tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1)); |
42 | tmp = cgit_pageurl(ctx.repo->url, "commit", tmp); | 76 | tmp = cgit_pageurl(ctx.repo->url, "commit", tmp); |
43 | html_link_open(tmp, NULL, NULL); | 77 | html_link_open(tmp, NULL, NULL); |
44 | cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); | 78 | cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); |
45 | html_link_close(); | 79 | html_link_close(); |
46 | html("</td><td>"); | 80 | htmlf("</td><td%s>", |
81 | ctx.qry.showmsg ? " class='logsubject'" : ""); | ||
47 | cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, | 82 | cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, |
48 | sha1_to_hex(commit->object.sha1)); | 83 | sha1_to_hex(commit->object.sha1)); |
84 | show_commit_decorations(commit); | ||
49 | html("</td><td>"); | 85 | html("</td><td>"); |
50 | html_txt(info->author); | 86 | html_txt(info->author); |
51 | if (ctx.repo->enable_log_filecount) { | 87 | if (ctx.repo->enable_log_filecount) { |
@@ -61,6 +97,17 @@ void print_commit(struct commit *commit) | |||
61 | } | 97 | } |
62 | } | 98 | } |
63 | html("</td></tr>\n"); | 99 | html("</td></tr>\n"); |
100 | if (ctx.qry.showmsg) { | ||
101 | if (ctx.repo->enable_log_filecount) { | ||
102 | cols++; | ||
103 | if (ctx.repo->enable_log_linecount) | ||
104 | cols++; | ||
105 | } | ||
106 | htmlf("<tr class='nohover'><td/><td colspan='%d' class='logmsg'>", | ||
107 | cols); | ||
108 | html_txt(info->msg); | ||
109 | html("</td></tr>\n"); | ||
110 | } | ||
64 | cgit_free_commitinfo(info); | 111 | cgit_free_commitinfo(info); |
65 | } | 112 | } |
66 | 113 | ||
@@ -105,6 +152,8 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern | |||
105 | rev.verbose_header = 1; | 152 | rev.verbose_header = 1; |
106 | rev.show_root_diff = 0; | 153 | rev.show_root_diff = 0; |
107 | setup_revisions(argc, argv, &rev, NULL); | 154 | setup_revisions(argc, argv, &rev, NULL); |
155 | load_ref_decorations(); | ||
156 | rev.show_decorations = 1; | ||
108 | rev.grep_filter.regflags |= REG_ICASE; | 157 | rev.grep_filter.regflags |= REG_ICASE; |
109 | compile_grep_patterns(&rev.grep_filter); | 158 | compile_grep_patterns(&rev.grep_filter); |
110 | prepare_revision_walk(&rev); | 159 | prepare_revision_walk(&rev); |
@@ -113,8 +162,16 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern | |||
113 | html("<table class='list nowrap'>"); | 162 | html("<table class='list nowrap'>"); |
114 | 163 | ||
115 | html("<tr class='nohover'><th class='left'>Age</th>" | 164 | html("<tr class='nohover'><th class='left'>Age</th>" |
116 | "<th class='left'>Commit message</th>" | 165 | "<th class='left'>Commit message"); |
117 | "<th class='left'>Author</th>"); | 166 | if (pager) { |
167 | html(" ("); | ||
168 | cgit_log_link(ctx.qry.showmsg ? "Collapse" : "Expand", NULL, | ||
169 | NULL, ctx.qry.head, ctx.qry.sha1, | ||
170 | ctx.qry.path, ctx.qry.ofs, ctx.qry.grep, | ||
171 | ctx.qry.search, ctx.qry.showmsg ? 0 : 1); | ||
172 | html(")"); | ||
173 | } | ||
174 | html("</th><th class='left'>Author</th>"); | ||
118 | if (ctx.repo->enable_log_filecount) { | 175 | if (ctx.repo->enable_log_filecount) { |
119 | html("<th class='left'>Files</th>"); | 176 | html("<th class='left'>Files</th>"); |
120 | columns++; | 177 | columns++; |
@@ -149,20 +206,20 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern | |||
149 | cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, | 206 | cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, |
150 | ctx.qry.sha1, ctx.qry.path, | 207 | ctx.qry.sha1, ctx.qry.path, |
151 | ofs - cnt, ctx.qry.grep, | 208 | ofs - cnt, ctx.qry.grep, |
152 | ctx.qry.search); | 209 | ctx.qry.search, ctx.qry.showmsg); |
153 | html(" "); | 210 | html(" "); |
154 | } | 211 | } |
155 | if ((commit = get_revision(&rev)) != NULL) { | 212 | if ((commit = get_revision(&rev)) != NULL) { |
156 | cgit_log_link("[next]", NULL, NULL, ctx.qry.head, | 213 | cgit_log_link("[next]", NULL, NULL, ctx.qry.head, |
157 | ctx.qry.sha1, ctx.qry.path, | 214 | ctx.qry.sha1, ctx.qry.path, |
158 | ofs + cnt, ctx.qry.grep, | 215 | ofs + cnt, ctx.qry.grep, |
159 | ctx.qry.search); | 216 | ctx.qry.search, ctx.qry.showmsg); |
160 | } | 217 | } |
161 | html("</div>"); | 218 | html("</div>"); |
162 | } else if ((commit = get_revision(&rev)) != NULL) { | 219 | } else if ((commit = get_revision(&rev)) != NULL) { |
163 | html("<tr class='nohover'><td colspan='3'>"); | 220 | html("<tr class='nohover'><td colspan='3'>"); |
164 | cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, NULL, 0, | 221 | cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, NULL, 0, |
165 | NULL, NULL); | 222 | NULL, NULL, ctx.qry.showmsg); |
166 | html("</td></tr>\n"); | 223 | html("</td></tr>\n"); |
167 | } | 224 | } |
168 | } | 225 | } |
@@ -58,7 +58,8 @@ static int print_branch(struct refinfo *ref) | |||
58 | if (!info) | 58 | if (!info) |
59 | return 1; | 59 | return 1; |
60 | html("<tr><td>"); | 60 | html("<tr><td>"); |
61 | cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0, NULL, NULL); | 61 | cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0, NULL, NULL, |
62 | ctx.qry.showmsg); | ||
62 | html("</td><td>"); | 63 | html("</td><td>"); |
63 | 64 | ||
64 | if (ref->object->type == OBJ_COMMIT) { | 65 | if (ref->object->type == OBJ_COMMIT) { |
@@ -78,12 +79,37 @@ static int print_branch(struct refinfo *ref) | |||
78 | static void print_tag_header() | 79 | static void print_tag_header() |
79 | { | 80 | { |
80 | html("<tr class='nohover'><th class='left'>Tag</th>" | 81 | html("<tr class='nohover'><th class='left'>Tag</th>" |
81 | "<th class='left'>Reference</th>" | 82 | "<th class='left'>Download</th>" |
82 | "<th class='left'>Author</th>" | 83 | "<th class='left'>Author</th>" |
83 | "<th class='left' colspan='2'>Age</th></tr>\n"); | 84 | "<th class='left' colspan='2'>Age</th></tr>\n"); |
84 | header = 1; | 85 | header = 1; |
85 | } | 86 | } |
86 | 87 | ||
88 | static void print_tag_downloads(const struct cgit_repo *repo, const char *ref) | ||
89 | { | ||
90 | const struct cgit_snapshot_format* f; | ||
91 | char *filename; | ||
92 | const char *basename; | ||
93 | |||
94 | if (!ref || strlen(ref) < 2) | ||
95 | return; | ||
96 | |||
97 | basename = cgit_repobasename(repo->url); | ||
98 | if (prefixcmp(ref, basename) != 0) { | ||
99 | if ((ref[0] == 'v' || ref[0] == 'V') && isdigit(ref[1])) | ||
100 | ref++; | ||
101 | if (isdigit(ref[0])) | ||
102 | ref = xstrdup(fmt("%s-%s", basename, ref)); | ||
103 | } | ||
104 | |||
105 | for (f = cgit_snapshot_formats; f->suffix; f++) { | ||
106 | if (!(repo->snapshots & f->bit)) | ||
107 | continue; | ||
108 | filename = fmt("%s%s", ref, f->suffix); | ||
109 | cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename); | ||
110 | html(" "); | ||
111 | } | ||
112 | } | ||
87 | static int print_tag(struct refinfo *ref) | 113 | static int print_tag(struct refinfo *ref) |
88 | { | 114 | { |
89 | struct tag *tag; | 115 | struct tag *tag; |
@@ -98,7 +124,10 @@ static int print_tag(struct refinfo *ref) | |||
98 | html("<tr><td>"); | 124 | html("<tr><td>"); |
99 | cgit_tag_link(name, NULL, NULL, ctx.qry.head, name); | 125 | cgit_tag_link(name, NULL, NULL, ctx.qry.head, name); |
100 | html("</td><td>"); | 126 | html("</td><td>"); |
101 | cgit_object_link(tag->tagged); | 127 | if (ctx.repo->snapshots && (tag->tagged->type == OBJ_COMMIT)) |
128 | print_tag_downloads(ctx.repo, name); | ||
129 | else | ||
130 | cgit_object_link(tag->tagged); | ||
102 | html("</td><td>"); | 131 | html("</td><td>"); |
103 | if (info->tagger) | 132 | if (info->tagger) |
104 | html(info->tagger); | 133 | html(info->tagger); |
@@ -110,9 +139,12 @@ static int print_tag(struct refinfo *ref) | |||
110 | if (!header) | 139 | if (!header) |
111 | print_tag_header(); | 140 | print_tag_header(); |
112 | html("<tr><td>"); | 141 | html("<tr><td>"); |
113 | html_txt(name); | 142 | cgit_tag_link(name, NULL, NULL, ctx.qry.head, name); |
114 | html("</td><td>"); | 143 | html("</td><td>"); |
115 | cgit_object_link(ref->object); | 144 | if (ctx.repo->snapshots && (ref->object->type == OBJ_COMMIT)) |
145 | print_tag_downloads(ctx.repo, name); | ||
146 | else | ||
147 | cgit_object_link(ref->object); | ||
116 | html("</td></tr>\n"); | 148 | html("</td></tr>\n"); |
117 | } | 149 | } |
118 | return 0; | 150 | return 0; |
diff --git a/ui-repolist.c b/ui-repolist.c index 2324273..2c13d50 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
@@ -32,21 +32,38 @@ time_t read_agefile(char *path) | |||
32 | return 0; | 32 | return 0; |
33 | } | 33 | } |
34 | 34 | ||
35 | static void print_modtime(struct cgit_repo *repo) | 35 | static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime) |
36 | { | 36 | { |
37 | char *path; | 37 | char *path; |
38 | struct stat s; | 38 | struct stat s; |
39 | struct cgit_repo *r = (struct cgit_repo *)repo; | ||
39 | 40 | ||
41 | if (repo->mtime != -1) { | ||
42 | *mtime = repo->mtime; | ||
43 | return 1; | ||
44 | } | ||
40 | path = fmt("%s/%s", repo->path, ctx.cfg.agefile); | 45 | path = fmt("%s/%s", repo->path, ctx.cfg.agefile); |
41 | if (stat(path, &s) == 0) { | 46 | if (stat(path, &s) == 0) { |
42 | cgit_print_age(read_agefile(path), -1, NULL); | 47 | *mtime = read_agefile(path); |
43 | return; | 48 | r->mtime = *mtime; |
49 | return 1; | ||
44 | } | 50 | } |
45 | 51 | ||
46 | path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch); |