aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cgit.c6
-rw-r--r--cgit.css10
-rw-r--r--cgit.h1
-rw-r--r--cgitrc.5.txt2
-rw-r--r--cmd.c46
-rw-r--r--cmd.h3
-rw-r--r--shared.c1
-rw-r--r--ui-commit.c20
-rw-r--r--ui-commit.h2
-rw-r--r--ui-diff.c8
-rw-r--r--ui-log.c27
-rw-r--r--ui-patch.c6
-rw-r--r--ui-patch.h2
-rw-r--r--ui-refs.c2
-rw-r--r--ui-shared.c216
-rw-r--r--ui-shared.h72
-rw-r--r--ui-tree.c15
17 files changed, 275 insertions, 164 deletions
diff --git a/cgit.c b/cgit.c
index 38bc136..d4fcfa7 100644
--- a/cgit.c
+++ b/cgit.c
@@ -433,6 +433,12 @@ static void process_request(void *cbdata)
433 return; 433 return;
434 } 434 }
435 435
436 /* If cmd->want_vpath is set, assume ctx->qry.path contains a "virtual"
437 * in-project path limit to be made available at ctx->qry.vpath.
438 * Otherwise, no path limit is in effect (ctx->qry.vpath = NULL).
439 */
440 ctx->qry.vpath = cmd->want_vpath ? ctx->qry.path : NULL;
441
436 if (cmd->want_repo && !ctx->repo) { 442 if (cmd->want_repo && !ctx->repo) {
437 cgit_print_http_headers(ctx); 443 cgit_print_http_headers(ctx);
438 cgit_print_docstart(ctx); 444 cgit_print_docstart(ctx);
diff --git a/cgit.css b/cgit.css
index 6198403..6e47eb3 100644
--- a/cgit.css
+++ b/cgit.css
@@ -64,7 +64,7 @@ table#header td.sub {
64} 64}
65 65
66table.tabs { 66table.tabs {
67 /* border-bottom: solid 2px #ccc; */ 67 border-bottom: solid 3px #ccc;
68 border-collapse: collapse; 68 border-collapse: collapse;
69 margin-top: 2em; 69 margin-top: 2em;
70 margin-bottom: 0px; 70 margin-bottom: 0px;
@@ -102,10 +102,16 @@ table.tabs td.form select {
102 font-size: 90%; 102 font-size: 90%;
103} 103}
104 104
105div.path {
106 margin: 0px;
107 padding: 5px 2em 2px 2em;
108 color: #000;
109 background-color: #eee;
110}
111
105div.content { 112div.content {
106 margin: 0px; 113 margin: 0px;
107 padding: 2em; 114 padding: 2em;
108 border-top: solid 3px #ccc;
109 border-bottom: solid 3px #ccc; 115 border-bottom: solid 3px #ccc;
110} 116}
111 117
diff --git a/cgit.h b/cgit.h
index 8884f9e..80c3902 100644
--- a/cgit.h
+++ b/cgit.h
@@ -147,6 +147,7 @@ struct cgit_query {
147 int showmsg; 147 int showmsg;
148 int ssdiff; 148 int ssdiff;
149 int show_all; 149 int show_all;
150 char *vpath;
150}; 151};
151 152
152struct cgit_config { 153struct cgit_config {
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 5c24381..a853522 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -444,7 +444,7 @@ snapshots=tar.gz tar.bz2 zip
444## List of common mimetypes 444## List of common mimetypes
445## 445##
446 446
447mimetype.git=image/git 447mimetype.gif=image/gif
448mimetype.html=text/html 448mimetype.html=text/html
449mimetype.jpg=image/jpeg 449mimetype.jpg=image/jpeg
450mimetype.jpeg=image/jpeg 450mimetype.jpeg=image/jpeg
diff --git a/cmd.c b/cmd.c
index ad784fc..6dc9f5e 100644
--- a/cmd.c
+++ b/cmd.c
@@ -51,7 +51,7 @@ static void blob_fn(struct cgit_context *ctx)
51 51
52static void commit_fn(struct cgit_context *ctx) 52static void commit_fn(struct cgit_context *ctx)
53{ 53{
54 cgit_print_commit(ctx->qry.sha1); 54 cgit_print_commit(ctx->qry.sha1, ctx->qry.path);
55} 55}
56 56
57static void diff_fn(struct cgit_context *ctx) 57static void diff_fn(struct cgit_context *ctx)
@@ -90,7 +90,7 @@ static void repolist_fn(struct cgit_context *ctx)
90 90
91static void patch_fn(struct cgit_context *ctx) 91static void patch_fn(struct cgit_context *ctx)
92{ 92{
93 cgit_print_patch(ctx->qry.sha1); 93 cgit_print_patch(ctx->qry.sha1, ctx->qry.path);
94} 94}
95 95
96static void plain_fn(struct cgit_context *ctx) 96static void plain_fn(struct cgit_context *ctx)
@@ -129,31 +129,31 @@ static void tree_fn(struct cgit_context *ctx)
129 cgit_print_tree(ctx->qry.sha1, ctx->qry.path); 129 cgit_print_tree(ctx->qry.sha1, ctx->qry.path);
130} 130}
131 131
132#define def_cmd(name, want_repo, want_layout) \ 132#define def_cmd(name, want_repo, want_layout, want_vpath) \
133 {#name, name##_fn, want_repo, want_layout} 133 {#name, name##_fn, want_repo, want_layout, want_vpath}
134 134
135struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx) 135struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx)
136{ 136{
137 static struct cgit_cmd cmds[] = { 137 static struct cgit_cmd cmds[] = {
138 def_cmd(HEAD, 1, 0), 138 def_cmd(HEAD, 1, 0, 0),
139 def_cmd(atom, 1, 0), 139 def_cmd(atom, 1, 0, 0),
140 def_cmd(about, 0, 1), 140 def_cmd(about, 0, 1, 0),
141 def_cmd(blob, 1, 0), 141 def_cmd(blob, 1, 0, 0),
142 def_cmd(commit, 1, 1), 142 def_cmd(commit, 1, 1, 1),
143 def_cmd(diff, 1, 1), 143 def_cmd(diff, 1, 1, 1),
144 def_cmd(info, 1, 0), 144 def_cmd(info, 1, 0, 0),
145 def_cmd(log, 1, 1), 145 def_cmd(log, 1, 1, 1),
146 def_cmd(ls_cache, 0, 0), 146 def_cmd(ls_cache, 0, 0, 0),
147 def_cmd(objects, 1, 0), 147 def_cmd(objects, 1, 0, 0),
148 def_cmd(patch, 1, 0), 148 def_cmd(patch, 1, 0, 1),
149 def_cmd(plain, 1, 0), 149 def_cmd(plain, 1, 0, 0),
150 def_cmd(refs, 1, 1), 150 def_cmd(refs, 1, 1, 0),
151 def_cmd(repolist, 0, 0), 151 def_cmd(repolist, 0, 0, 0),
152 def_cmd(snapshot, 1, 0), 152 def_cmd(snapshot, 1, 0, 0),
153 def_cmd(stats, 1, 1), 153 def_cmd(stats, 1, 1, 1),
154 def_cmd(summary, 1, 1), 154 def_cmd(summary, 1, 1, 0),
155 def_cmd(tag, 1, 1), 155 def_cmd(tag, 1, 1, 0),
156 def_cmd(tree, 1, 1), 156 def_cmd(tree, 1, 1, 1),
157 }; 157 };
158 int i; 158 int i;
159 159
diff --git a/cmd.h b/cmd.h
index ec9e691..8dc01bd 100644
--- a/cmd.h
+++ b/cmd.h
@@ -7,7 +7,8 @@ struct cgit_cmd {
7 const char *name; 7 const char *name;
8 cgit_cmd_fn fn; 8 cgit_cmd_fn fn;
9 unsigned int want_repo:1, 9 unsigned int want_repo:1,
10 want_layout:1; 10 want_layout:1,
11 want_vpath:1;
11}; 12};
12 13
13extern struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx); 14extern struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx);
diff --git a/shared.c b/shared.c
index 8b3a045..58837dc 100644
--- a/shared.c
+++ b/shared.c
@@ -10,7 +10,6 @@
10 10
11struct cgit_repolist cgit_repolist; 11struct cgit_repolist cgit_repolist;
12struct cgit_context ctx; 12struct cgit_context ctx;
13int cgit_cmd;
14 13
15int chk_zero(int result, char *msg) 14int chk_zero(int result, char *msg)
16{ 15{
diff --git a/ui-commit.c b/ui-commit.c
index 41313b9..a11bc5f 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -12,7 +12,7 @@
12#include "ui-diff.h" 12#include "ui-diff.h"
13#include "ui-log.h" 13#include "ui-log.h"
14 14
15void cgit_print_commit(char *hex) 15void cgit_print_commit(char *hex, const char *prefix)
16{ 16{
17 struct commit *commit, *parent; 17 struct commit *commit, *parent;
18 struct commitinfo *info, *parent_info; 18 struct commitinfo *info, *parent_info;
@@ -58,19 +58,23 @@ void cgit_print_commit(char *hex)
58 html("</td></tr>\n"); 58 html("</td></tr>\n");
59 html("<tr><th>commit</th><td colspan='2' class='sha1'>"); 59 html("<tr><th>commit</th><td colspan='2' class='sha1'>");
60 tmp = sha1_to_hex(commit->object.sha1); 60 tmp = sha1_to_hex(commit->object.sha1);
61 cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, 0); 61 cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, prefix, 0);
62 html(" ("); 62 html(" (");
63 cgit_patch_link("patch", NULL, NULL, NULL, tmp); 63 cgit_patch_link("patch", NULL, NULL, NULL, tmp, prefix);
64 html(") ("); 64 html(") (");
65 if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff)) 65 if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff))
66 cgit_commit_link("unidiff", NULL, NULL, ctx.qry.head, tmp, 1); 66 cgit_commit_link("unidiff", NULL, NULL, ctx.qry.head, tmp, prefix, 1);
67 else 67 else
68 cgit_commit_link("side-by-side diff", NULL, NULL, ctx.qry.head, tmp, 1); 68 cgit_commit_link("side-by-side diff", NULL, NULL, ctx.qry.head, tmp, prefix, 1);
69 html(")</td></tr>\n"); 69 html(")</td></tr>\n");
70 html("<tr><th>tree</th><td colspan='2' class='sha1'>"); 70 html("<tr><th>tree</th><td colspan='2' class='sha1'>");
71 tmp = xstrdup(hex); 71 tmp = xstrdup(hex);
72 cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL, 72 cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL,
73 ctx.qry.head, tmp, NULL); 73 ctx.qry.head, tmp, NULL);
74 if (prefix) {
75 html(" /");
76 cgit_tree_link(prefix, NULL, NULL, ctx.qry.head, tmp, prefix);
77 }
74 html("</td></tr>\n"); 78 html("</td></tr>\n");
75 for (p = commit->parents; p ; p = p->next) { 79 for (p = commit->parents; p ; p = p->next) {
76 parent = lookup_commit_reference(p->item->object.sha1); 80 parent = lookup_commit_reference(p->item->object.sha1);
@@ -87,10 +91,10 @@ void cgit_print_commit(char *hex)
87 parent_info = cgit_parse_commit(parent); 91 parent_info = cgit_parse_commit(parent);
88 tmp2 = parent_info->subject; 92 tmp2 = parent_info->subject;
89 } 93 }
90 cgit_commit_link(tmp2, NULL, NULL, ctx.qry.head, tmp, 0); 94 cgit_commit_link(tmp2, NULL, NULL, ctx.qry.head, tmp, prefix, 0);
91 html(" ("); 95 html(" (");
92 cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex, 96 cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex,
93 sha1_to_hex(p->item->object.sha1), NULL, 0); 97 sha1_to_hex(p->item->object.sha1), prefix, 0);
94 html(")</td></tr>"); 98 html(")</td></tr>");
95 parents++; 99 parents++;
96 } 100 }
@@ -121,7 +125,7 @@ void cgit_print_commit(char *hex)
121 tmp = sha1_to_hex(commit->parents->item->object.sha1); 125 tmp = sha1_to_hex(commit->parents->item->object.sha1);
122 else 126 else
123 tmp = NULL; 127 tmp = NULL;
124 cgit_print_diff(ctx.qry.sha1, tmp, NULL); 128 cgit_print_diff(ctx.qry.sha1, tmp, prefix);
125 } 129 }
126 cgit_free_commitinfo(info); 130 cgit_free_commitinfo(info);
127} 131}
diff --git a/ui-commit.h b/ui-commit.h
index 40bcb31..8198b4b 100644
--- a/ui-commit.h
+++ b/ui-commit.h
@@ -1,6 +1,6 @@
1#ifndef UI_COMMIT_H 1#ifndef UI_COMMIT_H
2#define UI_COMMIT_H 2#define UI_COMMIT_H
3 3
4extern void cgit_print_commit(char *hex); 4extern void cgit_print_commit(char *hex, const char *prefix);
5 5
6#endif /* UI_COMMIT_H */ 6#endif /* UI_COMMIT_H */
diff --git a/ui-diff.c b/ui-diff.c
index a92a768..fb836df 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -154,17 +154,19 @@ static void inspect_filepair(struct diff_filepair *pair)
154} 154}
155 155
156void cgit_print_diffstat(const unsigned char *old_sha1, 156void cgit_print_diffstat(const unsigned char *old_sha1,
157 const unsigned char *new_sha1) 157 const unsigned char *new_sha1, const char *prefix)
158{ 158{
159 int i; 159 int i;
160 160
161 html("<div class='diffstat-header'>"); 161 html("<div class='diffstat-header'>");
162 cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1, 162 cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1,
163 ctx.qry.sha2, NULL, 0); 163 ctx.qry.sha2, NULL, 0);
164 if (prefix)
165 htmlf(" (limited to '%s')", prefix);
164 html("</div>"); 166 html("</div>");
165 html("<table summary='diffstat' class='diffstat'>"); 167 html("<table summary='diffstat' class='diffstat'>");
166 max_changes = 0; 168 max_changes = 0;
167 cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, NULL); 169 cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, prefix);
168 for(i = 0; i<files; i++) 170 for(i = 0; i<files; i++)
169 print_fileinfo(&items[i]); 171 print_fileinfo(&items[i]);
170 html("</table>"); 172 html("</table>");
@@ -338,7 +340,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefi
338 use_ssdiff = 1; 340 use_ssdiff = 1;
339 341
340 print_ssdiff_link(); 342 print_ssdiff_link();
341 cgit_print_diffstat(old_rev_sha1, new_rev_sha1); 343 cgit_print_diffstat(old_rev_sha1, new_rev_sha1, prefix);
342 344
343 if (use_ssdiff) { 345 if (use_ssdiff) {
344 html("<table summary='ssdiff' class='ssdiff'>"); 346 html("<table summary='ssdiff' class='ssdiff'>");
diff --git a/ui-log.c b/ui-log.c
index 0947604..bfbe436 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -46,8 +46,9 @@ void show_commit_decorations(struct commit *commit)
46 while (deco) { 46 while (deco) {
47 if (!prefixcmp(deco->name, "refs/heads/")) { 47 if (!prefixcmp(deco->name, "refs/heads/")) {
48 strncpy(buf, deco->name + 11, sizeof(buf) - 1); 48 strncpy(buf, deco->name + 11, sizeof(buf) - 1);
49 cgit_log_link(buf, NULL, "branch-deco", buf, NULL, NULL, 49 cgit_log_link(buf, NULL, "branch-deco", buf, NULL,
50 0, NULL, NULL, ctx.qry.showmsg); 50 ctx.qry.vpath, 0, NULL, NULL,
51 ctx.qry.showmsg);
51 } 52 }
52 else if (!prefixcmp(deco->name, "tag: refs/tags/")) { 53 else if (!prefixcmp(deco->name, "tag: refs/tags/")) {
53 strncpy(buf, deco->name + 15, sizeof(buf) - 1); 54 strncpy(buf, deco->name + 15, sizeof(buf) - 1);
@@ -60,13 +61,15 @@ void show_commit_decorations(struct commit *commit)
60 else if (!prefixcmp(deco->name, "refs/remotes/")) { 61 else if (!prefixcmp(deco->name, "refs/remotes/")) {
61 strncpy(buf, deco->name + 13, sizeof(buf) - 1); 62 strncpy(buf, deco->name + 13, sizeof(buf) - 1);
62 cgit_log_link(buf, NULL, "remote-deco", NULL, 63 cgit_log_link(buf, NULL, "remote-deco", NULL,
63 sha1_to_hex(commit->object.sha1), NULL, 64 sha1_to_hex(commit->object.sha1),
64 0, NULL, NULL, ctx.qry.showmsg); 65 ctx.qry.vpath, 0, NULL, NULL,
66 ctx.qry.showmsg);
65 } 67 }
66 else { 68 else {
67 strncpy(buf, deco->name, sizeof(buf) - 1); 69 strncpy(buf, deco->name, sizeof(buf) - 1);
68 cgit_commit_link(buf, NULL, "deco", ctx.qry.head, 70 cgit_commit_link(buf, NULL, "deco", ctx.qry.head,
69 sha1_to_hex(commit->object.sha1), 0); 71 sha1_to_hex(commit->object.sha1),
72 ctx.qry.vpath, 0);
70 } 73 }
71 deco = deco->next; 74 deco = deco->next;
72 } 75 }
@@ -82,14 +85,14 @@ void print_commit(struct commit *commit)
82 htmlf("<tr%s><td>", 85 htmlf("<tr%s><td>",
83 ctx.qry.showmsg ? " class='logheader'" : ""); 86 ctx.qry.showmsg ? " class='logheader'" : "");
84 tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1)); 87 tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1));
85 tmp = cgit_pageurl(ctx.repo->url, "commit", tmp); 88 tmp = cgit_fileurl(ctx.repo->url, "commit", ctx.qry.vpath, tmp);
86 html_link_open(tmp, NULL, NULL); 89 html_link_open(tmp, NULL, NULL);
87 cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); 90 cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE);
88 html_link_close(); 91 html_link_close();
89 htmlf("</td><td%s>", 92 htmlf("</td><td%s>",
90 ctx.qry.showmsg ? " class='logsubject'" : ""); 93 ctx.qry.showmsg ? " class='logsubject'" : "");
91 cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, 94 cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head,
92 sha1_to_hex(commit->object.sha1), 0); 95 sha1_to_hex(commit->object.sha1), ctx.qry.vpath, 0);
93 show_commit_decorations(commit); 96 show_commit_decorations(commit);
94 html("</td><td>"); 97 html("</td><td>");
95 html_txt(info->author); 98 html_txt(info->author);
@@ -176,7 +179,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
176 html(" ("); 179 html(" (");
177 cgit_log_link(ctx.qry.showmsg ? "Collapse" : "Expand", NULL, 180 cgit_log_link(ctx.qry.showmsg ? "Collapse" : "Expand", NULL,
178 NULL, ctx.qry.head, ctx.qry.sha1, 181 NULL, ctx.qry.head, ctx.qry.sha1,
179 ctx.qry.path, ctx.qry.ofs, ctx.qry.grep, 182 ctx.qry.vpath, ctx.qry.ofs, ctx.qry.grep,
180 ctx.qry.search, ctx.qry.showmsg ? 0 : 1); 183 ctx.qry.search, ctx.qry.showmsg ? 0 : 1);
181 html(")"); 184 html(")");
182 } 185 }
@@ -213,22 +216,22 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
213 columns); 216 columns);
214 if (ofs > 0) { 217 if (ofs > 0) {
215 cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, 218 cgit_log_link("[prev]", NULL, NULL, ctx.qry.head,
216 ctx.qry.sha1, ctx.qry.path, 219 ctx.qry.sha1, ctx.qry.vpath,
217 ofs - cnt, ctx.qry.grep, 220 ofs - cnt, ctx.qry.grep,
218 ctx.qry.search, ctx.qry.showmsg); 221 ctx.qry.search, ctx.qry.showmsg);
219 html("&nbsp;"); 222 html("&nbsp;");
220 } 223 }
221 if ((commit = get_revision(&rev)) != NULL) { 224 if ((commit = get_revision(&rev)) != NULL) {
222 cgit_log_link("[next]", NULL, NULL, ctx.qry.head, 225 cgit_log_link("[next]", NULL, NULL, ctx.qry.head,
223 ctx.qry.sha1, ctx.qry.path, 226 ctx.qry.sha1, ctx.qry.vpath,
224 ofs + cnt, ctx.qry.grep, 227 ofs + cnt, ctx.qry.grep,
225 ctx.qry.search, ctx.qry.showmsg); 228 ctx.qry.search, ctx.qry.showmsg);
226 } 229 }
227 html("</div>"); 230 html("</div>");
228 } else if ((commit = get_revision(&rev)) != NULL) { 231 } else if ((commit = get_revision(&rev)) != NULL) {
229 html("<tr class='nohover'><td colspan='3'>"); 232 html("<tr class='nohover'><td colspan='3'>");
230 cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, NULL, 0, 233 cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL,
231 NULL, NULL, ctx.qry.showmsg); 234 ctx.qry.vpath, 0, NULL, NULL, ctx.qry.showmsg);
232 html("</td></tr>\n"); 235 html("</td></tr>\n");
233 } 236 }
234} 237}
diff --git a/ui-patch.c b/ui-patch.c
index 2a8f7a5..25dc9fe 100644
--- a/ui-patch.c
+++ b/ui-patch.c
@@ -77,7 +77,7 @@ static void filepair_cb(struct diff_filepair *pair)
77 html("Binary files differ\n"); 77 html("Binary files differ\n");
78} 78}
79 79
80void cgit_print_patch(char *hex) 80void cgit_print_patch(char *hex, const char *prefix)
81{ 81{
82 struct commit *commit; 82 struct commit *commit;
83 struct commitinfo *info; 83 struct commitinfo *info;
@@ -122,7 +122,9 @@ void cgit_print_patch(char *hex)
122 html("\n"); 122 html("\n");
123 } 123 }
124 html("---\n"); 124 html("---\n");
125 cgit_diff_tree(old_sha1, sha1, filepair_cb, NULL); 125 if (prefix)
126 htmlf("(limited to '%s')\n\n", prefix);
127 cgit_diff_tree(old_sha1, sha1, filepair_cb, prefix);
126 html("--\n"); 128 html("--\n");
127 htmlf("cgit %s\n", CGIT_VERSION); 129 htmlf("cgit %s\n", CGIT_VERSION);
128 cgit_free_commitinfo(info); 130 cgit_free_commitinfo(info);
diff --git a/ui-patch.h b/ui-patch.h
index 9f68212..1641cea 100644
--- a/ui-patch.h
+++ b/ui-patch.h
@@ -1,6 +1,6 @@
1#ifndef UI_PATCH_H 1#ifndef UI_PATCH_H
2#define UI_PATCH_H 2#define UI_PATCH_H
3 3
4extern void cgit_print_patch(char *hex); 4extern void cgit_print_patch(char *hex, const char *prefix);
5 5
6#endif /* UI_PATCH_H */ 6#endif /* UI_PATCH_H */
diff --git a/ui-refs.c b/ui-refs.c
index 98738db..94ff6be 100644
--- a/ui-refs.c
+++ b/ui-refs.c
@@ -74,7 +74,7 @@ static int print_branch(struct refinfo *ref)
74 html("</td><td>"); 74 html("</td><td>");
75 75
76 if (ref->object->type == OBJ_COMMIT) { 76 if (ref->object->type == OBJ_COMMIT) {
77 cgit_commit_link(info->subject, NULL, NULL, name, NULL, 0); 77 cgit_commit_link(info->subject, NULL, NULL, name, NULL, NULL, 0);
78 html("</td><td>"); 78 html("</td><td>");
79 html_txt(info->author); 79 html_txt(info->author);
80 html("</td><td colspan='2'>"); 80 html("</td><td colspan='2'>");
diff --git a/ui-shared.c b/ui-shared.c
index 8827fff..e991799 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -27,7 +27,7 @@ static char *http_date(time_t t)
27 tm->tm_hour, tm->tm_min, tm->tm_sec); 27 tm->tm_hour, tm->tm_min, tm->tm_sec);
28} 28}
29 29
30void cgit_print_error(char *msg) 30void cgit_print_error(const char *msg)
31{ 31{
32 html("<div class='error'>"); 32 html("<div class='error'>");
33 html_txt(msg); 33 html_txt(msg);
@@ -133,7 +133,7 @@ char *cgit_currurl()
133 return fmt("%s/", ctx.cfg.virtual_root); 133 return fmt("%s/", ctx.cfg.virtual_root);
134} 134}
135 135
136static void site_url(char *page, char *search, int ofs) 136static void site_url(const char *page, const char *search, int ofs)
137{ 137{
138 char *delim = "?"; 138 char *delim = "?";
139 139
@@ -160,8 +160,8 @@ static void site_url(char *page, char *search, int ofs)
160 } 160 }
161} 161}
162 162
163static void site_link(char *page, char *name, char *title, char *class, 163static void site_link(const char *page, const char *name, const char *title,
164 char *search, int ofs) 164 const char *class, const char *search, int ofs)
165{ 165{
166 html("<a"); 166 html("<a");
167 if (title) { 167 if (title) {
@@ -181,14 +181,14 @@ static void site_link(char *page, char *name, char *title, char *class,
181 html("</a>"); 181 html("</a>");
182} 182}
183 183
184void cgit_index_link(char *name, char *title, char *class, char *pattern, 184void cgit_index_link(const char *name, const char *title, const char *class,
185 int ofs) 185 const char *pattern, int ofs)
186{ 186{
187 site_link(NULL, name, title, class, pattern, ofs); 187 site_link(NULL, name, title, class, pattern, ofs);
188} 188}
189 189
190static char *repolink(char *title, char *class, char *page, char *head, 190static char *repolink(const char *title, const char *class, const char *page,
191 char *path) 191 const char *head, const char *path)
192{ 192{
193 char *delim = "?"; 193 char *delim = "?";
194 194
@@ -240,8 +240,9 @@ static char *repolink(char *title, char *class, char *page, char *head,
240 return fmt("%s", delim); 240 return fmt("%s", delim);
241} 241}
242 242
243static void reporevlink(char *page, char *name, char *title, char *class, 243static void reporevlink(const char *page, const char *name, const char *title,
244 char *head, char *rev, char *path) 244 const char *class, const char *head, const char *rev,
245 const char *path)
245{ 246{
246 char *delim; 247 char *delim;
247 248
@@ -256,32 +257,33 @@ static void reporevlink(char *page, char *name, char *title, char *class,
256 html("</a>"); 257 html("</a>");
257} 258}
258 259
259void cgit_summary_link(char *name, char *title, char *class, char *head) 260void cgit_summary_link(const char *name, const char *title, const char *class,
261 const char *head)
260{ 262{
261 reporevlink(NULL, name, title, class, head, NULL, NULL); 263 reporevlink(NULL, name, title, class, head, NULL, NULL);
262} 264}
263 265
264void cgit_tag_link(char *name, char *title, char *class, char *head, 266void cgit_tag_link(const char *name, const char *title, const char *class,
265 char *rev) 267 const char *head, const char *rev)
266{ 268{
267 reporevlink("tag", name, title, class, head, rev, NULL); 269 reporevlink("tag", name, title, class, head, rev, NULL);
268} 270}
269 271
270void cgit_tree_link(char *name, char *title, char *class, char *head, 272void cgit_tree_link(const char *name, const char *title, const char *class,
271 char *rev, char *path) 273 const char *head, const char *rev, const char *path)
272{ 274{
273 reporevlink("tree", name, title, class, head, rev, path); 275 reporevlink("tree", name, title, class, head, rev, path);
274} 276}
275 277
276void cgit_plain_link(char *name, char *title, char *class, char *head, 278void cgit_plain_link(const char *name, const char *title, const char *class,
277 char *rev, char *path) 279 const char *head, const char *rev, const char *path)
278{ 280{
279 reporevlink("plain", name, title, class, head, rev, path); 281 reporevlink("plain", name, title, class, head, rev, path);
280} 282}
281 283
282void cgit_log_link(char *name, char *title, char *class, char *head, 284void cgit_log_link(const char *name, const char *title, const char *class,
283 char *rev, char *path, int ofs, char *grep, char *pattern, 285 const char *head, const char *rev, const char *path,
284 int showmsg) 286 int ofs, const char *grep, const char *pattern, int showmsg)
285{ 287{
286 char *delim; 288 char *delim;
287 289
@@ -316,8 +318,9 @@ void cgit_log_link(char *name, char *title, char *class, char *head,
316 html("</a>"); 318 html("</a>");
317} 319}
318 320
319void cgit_commit_link(char *name, char *title, char *class, char *head, 321void cgit_commit_link(char *name, const char *title, const char *class,
320 char *rev, int toggle_ssdiff) 322 const char *head, const char *rev, const char *path,
323 int toggle_ssdiff)
321{ 324{
322 if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) { 325 if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) {
323 name[ctx.cfg.max_msg_len] = '\0'; 326 name[ctx.cfg.max_msg_len] = '\0';
@@ -328,7 +331,7 @@ void cgit_commit_link(char *name, char *title, char *class, char *head,
328 331
329 char *delim; 332 char *delim;
330 333
331 delim = repolink(title, class, "commit", head, NULL); 334 delim = repolink(title, class, "commit", head, path);
332 if (rev && strcmp(rev, ctx.qry.head)) { 335 if (rev && strcmp(rev, ctx.qry.head)) {
333 html(delim); 336 html(delim);
334 html("id="); 337 html("id=");
@@ -344,21 +347,22 @@ void cgit_commit_link(char *name, char *title, char *class, char *head,
344 html("</a>"); 347 html("</a>");
345} 348}
346 349
347void cgit_refs_link(char *name, char *title, char *class, char *head, 350void cgit_refs_link(const char *name, const char *title, const char *class,
348 char *rev, char *path) 351 const char *head, const char *rev, const char *path)
349{ 352{
350 reporevlink("refs", name, title, class, head, rev, path); 353 reporevlink("refs", name, title, class, head, rev, path);
351} 354}
352 355
353void cgit_snapshot_link(char *name, char *title, char *class, char *head, 356void cgit_snapshot_link(const char *name, const char *title, const char *class,
354 char *rev, char *archivename) 357 const char *head, const char *rev,
358 const char *archivename)
355{ 359{
356 reporevlink("snapshot", name, title, class, head, rev, archivename); 360 reporevlink("snapshot", name, title, class, head, rev, archivename);
357} 361}
358 362
359void cgit_diff_link(char *name, char *title, char *class, char *head, 363void cgit_diff_link(const char *name, const char *title, const char *class,
360 char *new_rev, char *old_rev, char *path, 364 const char *head, const char *new_rev, const char *old_rev,
361 int toggle_ssdiff) 365 const char *path, int toggle_ssdiff)
362{ 366{
363 char *delim; 367 char *delim;
364 368
@@ -384,18 +388,76 @@ void cgit_diff_link(char *name, char *title, char *class, char *head,
384 html("</a>"); 388 html("</a>");
385} 389}
386 390
387void cgit_patch_link(char *name, char *title, char *class, char *head, 391void cgit_patch_link(const char *name, const char *title, const char *class,
388 char *rev) 392 const char *head, const char *rev, const char *path)
389{ 393{
390 reporevlink("patch", name, title, class, head, rev, NULL); 394 reporevlink("patch", name, title, class, head, rev, path);
391} 395}
392 396
393void cgit_stats_link(char *name, char *title, char *class, char *head, 397void cgit_stats_link(const char *name, const char *title, const char *class,
394 char *path) 398 const char *head, const char *path)
395{ 399{
396 reporevlink("stats", name, title, class, head, NULL, path); 400 reporevlink("stats", name, title, class, head, NULL, path);
397} 401}
398 402
403void cgit_self_link(char *name, const char *title, const char *class,
404 struct cgit_context *ctx)
405{
406 if (!strcmp(ctx->qry.page, "repolist"))
407 return cgit_index_link(name, title, class, ctx->qry.search,
408 ctx->qry.ofs);
409 else if (!strcmp(ctx->qry.page, "summary"))
410 return cgit_summary_link(name, title, class, ctx->qry.head);
411 else if (!strcmp(ctx->qry.page, "tag"))
412 return cgit_tag_link(name, title, class, ctx->qry.head,
413 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL);
414 else if (!strcmp(ctx->qry.page, "tree"))
415 return cgit_tree_link(name, title, class, ctx->qry.head,
416 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
417 ctx->qry.path);
418 else if (!strcmp(ctx->qry.page, "plain"))
419 return cgit_plain_link(name, title, class, ctx->qry.head,
420 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
421 ctx->qry.path);
422 else if (!strcmp(ctx->qry.page, "log"))
423 return cgit_log_link(name, title, class, ctx->qry.head,
424 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
425 ctx->qry.path, ctx->qry.ofs,
426 ctx->qry.grep, ctx->qry.search,
427 ctx->qry.showmsg);
428 else if (!strcmp(ctx->qry.page, "commit"))
429 return cgit_commit_link(name, title, class, ctx->qry.head,
430 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
431 ctx->qry.path, 0);
432 else if (!strcmp(ctx->qry.page, "patch"))
433 return cgit_patch_link(name, title, class, ctx->qry.head,
434 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
435 ctx->qry.path);
436 else if (!strcmp(ctx->qry.page, "refs"))
437 return cgit_refs_link(name, title, class, ctx->qry.head,
438 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
439 ctx->qry.path);
440 else if (!strcmp(ctx->qry.page, "snapshot"))
441 return cgit_snapshot_link(name, title, class, ctx->qry.head,
442 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
443 ctx->qry.path);
444 else if (!strcmp(ctx->qry.page, "diff"))
445 return cgit_diff_link(name, title, class, ctx->qry.head,
446 ctx->qry.sha1, ctx->qry.sha2,
447 ctx->qry.path, 0);
448 else if (!strcmp(ctx->qry.page, "stats"))
449 return cgit_stats_link(name, title, class, ctx->qry.head,
450 ctx->qry.path);
451
452 /* Don't known how to make link for this page */
453 repolink(title, class, ctx->qry.page, ctx->qry.head, ctx->qry.path);
454 html("><!-- cgit_self_link() doesn't know how to make link for page '");
455 html_txt(ctx->qry.page);
456 html("' -->");
457 html_txt(name);
458 html("</a>");
459}
460
399void cgit_object_link(struct object *obj) 461void cgit_object_link(struct object *obj)
400{ 462{
401 char *page, *shortrev, *fullrev, *name; 463 char *page, *shortrev, *fullrev, *name;
@@ -405,7 +467,7 @@ void cgit_object_link(struct object *obj)
405 shortrev[10] = '\0'; 467 shortrev[10] = '\0';
406 if (obj->type == OBJ_COMMIT) { 468 if (obj->type == OBJ_COMMIT) {
407 cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL, 469 cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL,
408 ctx.qry.head, fullrev, 0); 470 ctx.qry.head, fullrev, NULL, 0);
409 return; 471 return;
410 } else if (obj->type == OBJ_TREE) 472 } else if (obj->type == OBJ_TREE)
411 page = "tree"; 473 page = "tree";
@@ -417,7 +479,7 @@ void cgit_object_link(struct object *obj)
417 reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL); 479 reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL);
418} 480}
419 481
420void cgit_print_date(time_t secs, char *format, int local_time) 482void cgit_print_date(time_t secs, const char *format, int local_time)
421{ 483{
422 char buf[64]; 484 char buf[64];
423 struct tm *time; 485 struct tm *time;
@@ -432,7 +494,7 @@ void cgit_print_date(time_t secs, char *format, int local_time)
432 html_txt(buf); 494 html_txt(buf);
433} 495}
434 496
435void cgit_print_age(time_t t, time_t max_relative, char *format) 497void cgit_print_age(time_t t, time_t max_relative, const char *format)
436{ 498{
437 time_t now, secs; 499 time_t now, secs;
438 500
@@ -531,7 +593,7 @@ void cgit_print_docstart(struct cgit_context *ctx)
531 html("<link rel='alternate' title='Atom feed' href='"); 593 html("<link rel='alternate' title='Atom feed' href='");
532 html(cgit_httpscheme()); 594 html(cgit_httpscheme());
533 html_attr(cgit_hosturl()); 595 html_attr(cgit_hosturl());
534 html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, 596 html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.vpath,
535 fmt("h=%s", ctx->qry.head))); 597 fmt("h=%s", ctx->qry.head)));
536 html("' type='application/atom+xml'/>\n"); 598 html("' type='application/atom+xml'/>\n");
537 } 599 }
@@ -611,14 +673,15 @@ int print_archive_ref(const char *refname, const unsigned char *sha1,
611 return 0; 673 return 0;
612} 674}
613 675
614void cgit_add_hidden_formfields(int incl_head, int incl_search, char *page) 676void cgit_add_hidden_formfields(int incl_head, int incl_search,
677 const char *page)
615{ 678{
616 char *url; 679 char *url;
617 680
618 if (!ctx.cfg.virtual_root) { 681 if (!ctx.cfg.virtual_root) {
619 url = fmt("%s/%s", ctx.qry.repo, page); 682 url = fmt("%s/%s", ctx.qry.repo, page);
620 if (ctx.qry.path) 683 if (ctx.qry.vpath)
621 url = fmt("%s/%s", url, ctx.qry.path); 684 url = fmt("%s/%s", url, ctx.qry.vpath);
622 html_hidden("url", url); 685 html_hidden("url", url);
623 } 686 }
624 687
@@ -641,11 +704,30 @@ void cgit_add_hidden_formfields(int incl_head, int incl_search, char *page)
641 } 704 }
642} 705}
643 706
644const char *fallback_cmd = "repolist"; 707static const char *hc(struct cgit_context *ctx, const char *page)
708{
709 return strcmp(ctx->qry.page, page) ? NULL : "active";
710}
645 711
646char *hc(struct cgit_cmd *cmd, const char *page) 712static void cgit_print_path_crumbs(struct cgit_context *ctx, char *path)
647{ 713{
648 return (strcmp(cmd ? cmd->name : fallback_cmd, page) ? NULL : "active"); 714 char *old_path = ctx->qry.path;
715 char *p = path, *q, *end = path + strlen(path);
716
717 ctx->qry.path = NULL;
718 cgit_self_link("root", NULL, NULL, ctx);
719 ctx->qry.path = p = path;
720 while (p < end) {
721 if (!(q = strchr(p, '/')))
722 q = end;
723 *q = '\0';
724 html_txt("/");
725 cgit_self_link(p, NULL, NULL, ctx);
726 if (q < end)
727 *q = '/';
728 p = q + 1;
729 }
730 ctx->qry.path = old_path;
649} 731}
650 732
651static void print_header(struct cgit_context *ctx) 733static void print_header(struct cgit_context *ctx)
@@ -697,41 +779,37 @@ static void print_header(struct cgit_context *ctx)
697 779
698void cgit_print_pageheader(struct cgit_context *ctx) 780void cgit_print_pageheader(struct cgit_context *ctx)
699{ 781{
700 struct cgit_cmd *cmd = cgit_get_cmd(ctx);
701
702 if (!cmd && ctx->repo)
703 fallback_cmd = "summary";
704
705 html("<div id='cgit'>"); 782 html("<div id='cgit'>");
706 if (!ctx->cfg.noheader) 783 if (!ctx->cfg.noheader)
707 print_header(ctx); 784 print_header(ctx);
708 785
709 html("<table class='tabs'><tr><td>\n"); 786 html("<table class='tabs'><tr><td>\n");
710 if (ctx->repo) { 787 if (ctx->repo) {
711 cgit_summary_link("summary", NULL, hc(cmd, "summary"), 788 cgit_summary_link("summary", NULL, hc(ctx, "summary"),
712 ctx->qry.head); 789 ctx->qry.head);
713 cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head, 790 cgit_refs_link("refs", NULL, hc(ctx, "refs"), ctx->qry.head,
714 ctx->qry.sha1, NULL);
715 cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head,
716 NULL, NULL, 0, NULL, NULL, ctx->qry.showmsg);
717 cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head,
718 ctx->qry.sha1, NULL); 791 ctx->qry.sha1, NULL);
719 cgit_commit_link("commit", NULL, hc(cmd, "commit"), 792 cgit_log_link("log", NULL, hc(ctx, "log"), ctx->qry.head,
720 ctx->qry.head, ctx->qry.sha1, 0); 793 NULL, ctx->qry.vpath, 0, NULL, NULL,
721 cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head, 794 ctx->qry.showmsg);
722 ctx->qry.sha1, ctx->qry.sha2, NULL, 0); 795 cgit_tree_link("tree", NULL, hc(ctx, "tree"), ctx->qry.head,
796 ctx->qry.sha1, ctx->qry.vpath);
797 cgit_commit_link("commit", NULL, hc(ctx, "commit"),
798 ctx->qry.head, ctx->qry.sha1, ctx->qry.vpath, 0);
799 cgit_diff_link("diff", NULL, hc(ctx, "diff"), ctx->qry.head,
800 ctx->qry.sha1, ctx->qry.sha2, ctx->qry.vpath, 0);
723 if (ctx->repo->max_stats) 801 if (ctx->repo->max_stats)
724 cgit_stats_link("stats", NULL, hc(cmd, "stats"), 802 cgit_stats_link("stats", NULL, hc(ctx, "stats"),
725 ctx->qry.head, NULL); 803 ctx->qry.head, ctx->qry.vpath);
726 if (ctx->repo->readme) 804 if (ctx->repo->readme)
727 reporevlink("about", "about", NULL, 805 reporevlink("about", "about", NULL,
728 hc(cmd, "about"), ctx->qry.head, NULL, 806 hc(ctx, "about"), ctx->qry.head, NULL,
729 NULL); 807 NULL);
730 html("</td><td class='form'>"); 808 html("</td><td class='form'>");
731 html("<form class='right' method='get' action='"); 809 html("<form class='right' method='get' action='");
732 if (ctx->cfg.virtual_root) 810 if (ctx->cfg.virtual_root)
733 html_url_path(cgit_fileurl(ctx->qry.repo, "log", 811 html_url_path(cgit_fileurl(ctx->qry.repo, "log",
734 ctx->qry.path, NULL)); 812 ctx->qry.vpath, NULL));
735 html("'>\n"); 813 html("'>\n");
736 cgit_add_hidden_formfields(1, 0, "log"); 814 cgit_add_hidden_formfields(1, 0, "log");
737 html("<select name='qt'>\n"); 815 html("<select name='qt'>\n");
@@ -745,9 +823,9 @@ void cgit_print_pageheader(struct cgit_context *ctx)
745 html("<input type='submit' value='search'/>\n"); 823 html("<input type='submit' value='search'/>\n");
746 html("</form>\n"); 824 html("</form>\n");
747 } else { 825 } else {
748 site_link(NULL, "index", NULL, hc(cmd, "repolist"), NULL, 0); 826 site_link(NULL, "index", NULL, hc(ctx, "repolist"), NULL, 0);
749 if (ctx->cfg.root_readme) 827 if (ctx->cfg.root_readme)
750 site_link("about", "about", NULL, hc(cmd, "about"), 828 site_link("about", "about", NULL, hc(ctx, "about"),
751 NULL, 0); 829 NULL, 0);
752 html("</td><td class='form'>"); 830 html("</td><td class='form'>");
753 html("<form method='get' action='"); 831 html("<form method='get' action='");
@@ -760,6 +838,12 @@ void cgit_print_pageheader(struct cgit_context *ctx)
760 html("</form>"); 838 html("</form>");
761 } 839 }
762 html("</td></tr></table>\n"); 840 html("</td></tr></table>\n");
841 if (ctx->qry.vpath) {
842 html("<div class='path'>");
843 html("path: ");
844 cgit_print_path_crumbs(ctx, ctx->qry.vpath);
845 html("</div>");
846 }
763 html("<div class='content'>"); 847 html("<div class='content'>");
764} 848}
765 849
diff --git a/ui-shared.h b/ui-shared.h
index 9ebc1f9..3cc1258 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -10,36 +10,50 @@ extern char *cgit_fileurl(const char *reponame, const char *pagename,
10extern char *cgit_pageurl(const char *reponame, const char *pagename, 10extern char *cgit_pageurl(const char *reponame, const char *pagename,
11 const char *query); 11 const char *query);
12 12
13extern void cgit_index_link(char *name, char *title, char *class, 13extern void cgit_index_link(const char *name, const char *title,
14 char *pattern, int ofs); 14 const char *class, const char *pattern, int ofs);
15extern void cgit_summary_link(char *name, char *title, char *class, char *head); 15extern void cgit_summary_link(const char *name, const char *title,
16extern void cgit_tag_link(char *name, char *title, char *class, char *head, 16 const char *class, const char *head);
17 char *rev); 17extern void cgit_tag_link(const char *name, const char *title,
18extern void cgit_tree_link(char *name, char *title, char *class, char *head, 18 const char *class, const char *head,
19 char *rev, char *path); 19 const char *rev);
20extern void cgit_plain_link(char *name, char *title, char *class, char *head, 20extern void cgit_tree_link(const char *name, const char *title,
21 char *rev, char *path); 21 const char *class, const char *head,
22extern void cgit_log_link(char *name, char *title, char *class, char *head, 22 const char *rev, const char *path);
23 char *rev, char *path, int ofs, char *grep, 23extern void cgit_plain_link(const char *name, const char *title,
24 char *pattern, int showmsg); 24 const char *class, const char *head,
25extern void cgit_commit_link(char *name, char *title, char *class, char *head, 25 const char *rev, const char *path);
26 char *rev, int toggle_ssdiff); 26extern void cgit_log_link(const char *name, const char *title,
27extern void cgit_patch_link(char *name, char *title, char *class, char *head, 27 const char *class, const char *head, const char *rev,
28 char *rev); 28 const char *path, int ofs, const char *grep,
29extern void cgit_refs_link(char *name, char *title, char *class, char *head, 29 const char *pattern, int showmsg);
30 char *rev, char *path); 30extern void cgit_commit_link(char *name, const char *title,
31extern void cgit_snapshot_link(char *name, char *title, char *class, 31 const char *class, const char *head,
32 char *head, char *rev, char *archivename); 32 const char *rev, const char *path,
33extern void cgit_diff_link(char *name, char *title, char *class, char *head, 33 int toggle_ssdiff);
34 char *new_rev, char *old_rev, char *path, 34extern void cgit_patch_link(const char *name, const char *title,
35 int toggle_ssdiff); 35 const char *class, const char *head,
36extern void cgit_stats_link(char *name, char *title, char *class, char *head, 36 const char *rev, const char *path);
37 char *path); 37extern void cgit_refs_link(const char *name, const char *title,
38 const char *class, const char *head,
39 const char *rev, const char *path);
40extern void cgit_snapshot_link(const char *name, const char *title,
41 const char *class, const char *head,
42 const char *rev, const char *archivename);
43extern void cgit_diff_link(const char *name, const char *title,
44 const char *class, const char *head,
45 const char *new_rev, const char *old_rev,
46 const char *path, int toggle_ssdiff);
47extern void cgit_stats_link(const char *name, const char *title,
48 const char *class, const char *head,
49 const char *path);
50extern void cgit_self_link(char *name, const char *title,
51 const char *class, struct cgit_context *ctx);
38extern void cgit_object_link(struct object *obj); 52extern void cgit_object_link(struct object *obj);
39 53
40extern void cgit_print_error(char *msg); 54extern void cgit_print_error(const char *msg);
41extern void cgit_print_date(time_t secs, char *format, int local_time); 55extern void cgit_print_date(time_t secs, const char *format, int local_time);
42extern void cgit_print_age(time_t t, time_t max_relative, char *format); 56extern void cgit_print_age(time_t t, time_t max_relative, const char *format);
43extern void cgit_print_http_headers(struct cgit_context *ctx); 57extern void cgit_print_http_headers(struct cgit_context *ctx);
44extern void cgit_print_docstart(struct cgit_context *ctx); 58extern void cgit_print_docstart(struct cgit_context *ctx);
45extern void cgit_print_docend(); 59extern void cgit_print_docend();
@@ -48,5 +62,5 @@ extern void cgit_print_filemode(unsigned short mode);
48extern void cgit_print_snapshot_links(const char *repo, const char *head, 62extern void cgit_print_snapshot_links(const char *repo, const char *head,
49 const char *hex, int snapshots); 63 const char *hex, int snapshots);
50extern void cgit_add_hidden_formfields(int incl_head, int incl_search, 64extern void cgit_add_hidden_formfields(int incl_head, int incl_search,
51 char *page); 65 const char *page);
52#endif /* UI_SHARED_H */ 66#endif /* UI_SHARED_H */
diff --git a/ui-tree.c b/ui-tree.c
index 0ee38f2..75ec9cb 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -102,10 +102,10 @@ static void print_object(const unsigned char *sha1, char *path, const char *base
102 return; 102 return;
103 } 103 }
104 104
105 html(" ("); 105 htmlf("blob: %s (", sha1_to_hex(sha1));
106 cgit_plain_link("plain", NULL, NULL, ctx.qry.head, 106 cgit_plain_link("plain", NULL, NULL, ctx.qry.head,
107 curr_rev, path); 107 curr_rev, path);
108 htmlf(")<br/>blob: %s\n", sha1_to_hex(sha1)); 108 html(")\n");
109 109
110 if (ctx.cfg.max_blob_size && size / 1024 > ctx.cfg.max_blob_size) { 110 if (ctx.cfg.max_blob_size && size / 1024 > ctx.cfg.max_blob_size) {
111 htmlf("<div class='error'>blob size (%dKB) exceeds display size limit (%dKB).</div>", 111 htmlf("<div class='error'>blob size (%dKB) exceeds display size limit (%dKB).</div>",
@@ -225,17 +225,10 @@ static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
225{ 225{
226 static int state; 226 static int state;
227 static char buffer[PATH_MAX]; 227 static char buffer[PATH_MAX];
228 char *url;
229 228
230 if (state == 0) { 229 if (state == 0) {
231 memcpy(buffer, base, baselen); 230 memcpy(buffer, base, baselen);
232 strcpy(buffer+baselen, pathname); 231 strcpy(buffer+baselen, pathname);
233 url = cgit_pageurl(ctx.qry.repo, "tree",
234 fmt("h=%s&amp;path=%s", curr_rev, buffer));
235 html("/");
236 cgit_tree_link(xstrdup(pathname), NULL, NULL, ctx.qry.head,
237 curr_rev, buffer);
238
239 if (strcmp(match_path, buffer)) 232 if (strcmp(match_path, buffer))
240 return READ_TREE_RECURSIVE; 233 return READ_TREE_RECURSIVE;
241 234
@@ -278,10 +271,6 @@ void cgit_print_tree(const char *rev, char *path)
278 return; 271 return;
279 } 272 }
280 273
281 html("path: <a href='");
282 html_attr(cgit_pageurl(ctx.qry.repo, "tree", fmt("h=%s", rev)));
283 html("'>root</a>");
284
285 if (path == NULL) { 274 if (path == NULL) {
286 ls_tree(commit->tree->object.sha1, NULL); 275 ls_tree(commit->tree->object.sha1, NULL);
287 return; 276 return;