summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ui-diff.c5
-rw-r--r--ui-shared.c10
2 files changed, 15 insertions, 0 deletions
diff --git a/ui-diff.c b/ui-diff.c
index 1656b77..0dcabe9 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -78,192 +78,197 @@ static void print_fileinfo(struct fileinfo *info)
78 78
79 if (info->old_mode != info->new_mode && 79 if (info->old_mode != info->new_mode &&
80 !is_null_sha1(info->old_sha1) && 80 !is_null_sha1(info->old_sha1) &&
81 !is_null_sha1(info->new_sha1)) { 81 !is_null_sha1(info->new_sha1)) {
82 html("<span class='modechange'>["); 82 html("<span class='modechange'>[");
83 cgit_print_filemode(info->old_mode); 83 cgit_print_filemode(info->old_mode);
84 html("]</span>"); 84 html("]</span>");
85 } 85 }
86 htmlf("</td><td class='%s'>", class); 86 htmlf("</td><td class='%s'>", class);
87 cgit_diff_link(info->new_path, NULL, NULL, ctx.qry.head, ctx.qry.sha1, 87 cgit_diff_link(info->new_path, NULL, NULL, ctx.qry.head, ctx.qry.sha1,
88 ctx.qry.sha2, info->new_path, 0); 88 ctx.qry.sha2, info->new_path, 0);
89 if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED) 89 if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED)
90 htmlf(" (%s from %s)", 90 htmlf(" (%s from %s)",
91 info->status == DIFF_STATUS_COPIED ? "copied" : "renamed", 91 info->status == DIFF_STATUS_COPIED ? "copied" : "renamed",
92 info->old_path); 92 info->old_path);
93 html("</td><td class='right'>"); 93 html("</td><td class='right'>");
94 if (info->binary) { 94 if (info->binary) {
95 htmlf("bin</td><td class='graph'>%d -> %d bytes", 95 htmlf("bin</td><td class='graph'>%d -> %d bytes",
96 info->old_size, info->new_size); 96 info->old_size, info->new_size);
97 return; 97 return;
98 } 98 }
99 htmlf("%d", info->added + info->removed); 99 htmlf("%d", info->added + info->removed);
100 html("</td><td class='graph'>"); 100 html("</td><td class='graph'>");
101 htmlf("<table summary='file diffstat' width='%d%%'><tr>", (max_changes > 100 ? 100 : max_changes)); 101 htmlf("<table summary='file diffstat' width='%d%%'><tr>", (max_changes > 100 ? 100 : max_changes));
102 htmlf("<td class='add' style='width: %.1f%%;'/>", 102 htmlf("<td class='add' style='width: %.1f%%;'/>",
103 info->added * 100.0 / max_changes); 103 info->added * 100.0 / max_changes);
104 htmlf("<td class='rem' style='width: %.1f%%;'/>", 104 htmlf("<td class='rem' style='width: %.1f%%;'/>",
105 info->removed * 100.0 / max_changes); 105 info->removed * 100.0 / max_changes);
106 htmlf("<td class='none' style='width: %.1f%%;'/>", 106 htmlf("<td class='none' style='width: %.1f%%;'/>",
107 (max_changes - info->removed - info->added) * 100.0 / max_changes); 107 (max_changes - info->removed - info->added) * 100.0 / max_changes);
108 html("</tr></table></td></tr>\n"); 108 html("</tr></table></td></tr>\n");
109} 109}
110 110
111static void count_diff_lines(char *line, int len) 111static void count_diff_lines(char *line, int len)
112{ 112{
113 if (line && (len > 0)) { 113 if (line && (len > 0)) {
114 if (line[0] == '+') 114 if (line[0] == '+')
115 lines_added++; 115 lines_added++;
116 else if (line[0] == '-') 116 else if (line[0] == '-')
117 lines_removed++; 117 lines_removed++;
118 } 118 }
119} 119}
120 120
121static void inspect_filepair(struct diff_filepair *pair) 121static void inspect_filepair(struct diff_filepair *pair)
122{ 122{
123 int binary = 0; 123 int binary = 0;
124 unsigned long old_size = 0; 124 unsigned long old_size = 0;
125 unsigned long new_size = 0; 125 unsigned long new_size = 0;
126 files++; 126 files++;
127 lines_added = 0; 127 lines_added = 0;
128 lines_removed = 0; 128 lines_removed = 0;
129 cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, &new_size, 129 cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, &new_size,
130 &binary, 0, ctx.qry.ignorews, count_diff_lines); 130 &binary, 0, ctx.qry.ignorews, count_diff_lines);
131 if (files >= slots) { 131 if (files >= slots) {
132 if (slots == 0) 132 if (slots == 0)
133 slots = 4; 133 slots = 4;
134 else 134 else
135 slots = slots * 2; 135 slots = slots * 2;
136 items = xrealloc(items, slots * sizeof(struct fileinfo)); 136 items = xrealloc(items, slots * sizeof(struct fileinfo));
137 } 137 }
138 items[files-1].status = pair->status; 138 items[files-1].status = pair->status;
139 hashcpy(items[files-1].old_sha1, pair->one->sha1); 139 hashcpy(items[files-1].old_sha1, pair->one->sha1);
140 hashcpy(items[files-1].new_sha1, pair->two->sha1); 140 hashcpy(items[files-1].new_sha1, pair->two->sha1);
141 items[files-1].old_mode = pair->one->mode; 141 items[files-1].old_mode = pair->one->mode;
142 items[files-1].new_mode = pair->two->mode; 142 items[files-1].new_mode = pair->two->mode;
143 items[files-1].old_path = xstrdup(pair->one->path); 143 items[files-1].old_path = xstrdup(pair->one->path);
144 items[files-1].new_path = xstrdup(pair->two->path); 144 items[files-1].new_path = xstrdup(pair->two->path);
145 items[files-1].added = lines_added; 145 items[files-1].added = lines_added;
146 items[files-1].removed = lines_removed; 146 items[files-1].removed = lines_removed;
147 items[files-1].old_size = old_size; 147 items[files-1].old_size = old_size;
148 items[files-1].new_size = new_size; 148 items[files-1].new_size = new_size;
149 items[files-1].binary = binary; 149 items[files-1].binary = binary;
150 if (lines_added + lines_removed > max_changes) 150 if (lines_added + lines_removed > max_changes)
151 max_changes = lines_added + lines_removed; 151 max_changes = lines_added + lines_removed;
152 total_adds += lines_added; 152 total_adds += lines_added;
153 total_rems += lines_removed; 153 total_rems += lines_removed;
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, const char *prefix) 157 const unsigned char *new_sha1, const char *prefix)
158{ 158{
159 int i, save_context = ctx.qry.context; 159 int i, save_context = ctx.qry.context;
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) 164 if (prefix)
165 htmlf(" (limited to '%s')", prefix); 165 htmlf(" (limited to '%s')", prefix);
166 html(" ("); 166 html(" (");
167 ctx.qry.context = (save_context > 0 ? save_context : 3) << 1; 167 ctx.qry.context = (save_context > 0 ? save_context : 3) << 1;
168 cgit_self_link("more", NULL, NULL, &ctx); 168 cgit_self_link("more", NULL, NULL, &ctx);
169 html("/"); 169 html("/");
170 ctx.qry.context = (save_context > 3 ? save_context : 3) >> 1; 170 ctx.qry.context = (save_context > 3 ? save_context : 3) >> 1;
171 cgit_self_link("less", NULL, NULL, &ctx); 171 cgit_self_link("less", NULL, NULL, &ctx);
172 ctx.qry.context = save_context; 172 ctx.qry.context = save_context;
173 html(" context)"); 173 html(" context)");
174 html(" (");
175 ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2;
176 cgit_self_link(ctx.qry.ignorews ? "ignore" : "show", NULL, NULL, &ctx);
177 ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2;
178 html(" whitespace changes)");
174 html("</div>"); 179 html("</div>");
175 html("<table summary='diffstat' class='diffstat'>"); 180 html("<table summary='diffstat' class='diffstat'>");
176 max_changes = 0; 181 max_changes = 0;
177 cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, prefix, 182 cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, prefix,
178 ctx.qry.ignorews); 183 ctx.qry.ignorews);
179 for(i = 0; i<files; i++) 184 for(i = 0; i<files; i++)
180 print_fileinfo(&items[i]); 185 print_fileinfo(&items[i]);
181 html("</table>"); 186 html("</table>");
182 html("<div class='diffstat-summary'>"); 187 html("<div class='diffstat-summary'>");
183 htmlf("%d files changed, %d insertions, %d deletions", 188 htmlf("%d files changed, %d insertions, %d deletions",
184 files, total_adds, total_rems); 189 files, total_adds, total_rems);
185 html("</div>"); 190 html("</div>");
186} 191}
187 192
188 193
189/* 194/*
190 * print a single line returned from xdiff 195 * print a single line returned from xdiff
191 */ 196 */
192static void print_line(char *line, int len) 197static void print_line(char *line, int len)
193{ 198{
194 char *class = "ctx"; 199 char *class = "ctx";
195 char c = line[len-1]; 200 char c = line[len-1];
196 201
197 if (line[0] == '+') 202 if (line[0] == '+')
198 class = "add"; 203 class = "add";
199 else if (line[0] == '-') 204 else if (line[0] == '-')
200 class = "del"; 205 class = "del";
201 else if (line[0] == '@') 206 else if (line[0] == '@')
202 class = "hunk"; 207 class = "hunk";
203 208
204 htmlf("<div class='%s'>", class); 209 htmlf("<div class='%s'>", class);
205 line[len-1] = '\0'; 210 line[len-1] = '\0';
206 html_txt(line); 211 html_txt(line);
207 html("</div>"); 212 html("</div>");
208 line[len-1] = c; 213 line[len-1] = c;
209} 214}
210 215
211static void header(unsigned char *sha1, char *path1, int mode1, 216static void header(unsigned char *sha1, char *path1, int mode1,
212 unsigned char *sha2, char *path2, int mode2) 217 unsigned char *sha2, char *path2, int mode2)
213{ 218{
214 char *abbrev1, *abbrev2; 219 char *abbrev1, *abbrev2;
215 int subproject; 220 int subproject;
216 221
217 subproject = (S_ISGITLINK(mode1) || S_ISGITLINK(mode2)); 222 subproject = (S_ISGITLINK(mode1) || S_ISGITLINK(mode2));
218 html("<div class='head'>"); 223 html("<div class='head'>");
219 html("diff --git a/"); 224 html("diff --git a/");
220 html_txt(path1); 225 html_txt(path1);
221 html(" b/"); 226 html(" b/");
222 html_txt(path2); 227 html_txt(path2);
223 228
224 if (is_null_sha1(sha1)) 229 if (is_null_sha1(sha1))
225 path1 = "dev/null"; 230 path1 = "dev/null";
226 if (is_null_sha1(sha2)) 231 if (is_null_sha1(sha2))
227 path2 = "dev/null"; 232 path2 = "dev/null";
228 233
229 if (mode1 == 0) 234 if (mode1 == 0)
230 htmlf("<br/>new file mode %.6o", mode2); 235 htmlf("<br/>new file mode %.6o", mode2);
231 236
232 if (mode2 == 0) 237 if (mode2 == 0)
233 htmlf("<br/>deleted file mode %.6o", mode1); 238 htmlf("<br/>deleted file mode %.6o", mode1);
234 239
235 if (!subproject) { 240 if (!subproject) {
236 abbrev1 = xstrdup(find_unique_abbrev(sha1, DEFAULT_ABBREV)); 241 abbrev1 = xstrdup(find_unique_abbrev(sha1, DEFAULT_ABBREV));
237 abbrev2 = xstrdup(find_unique_abbrev(sha2, DEFAULT_ABBREV)); 242 abbrev2 = xstrdup(find_unique_abbrev(sha2, DEFAULT_ABBREV));
238 htmlf("<br/>index %s..%s", abbrev1, abbrev2); 243 htmlf("<br/>index %s..%s", abbrev1, abbrev2);
239 free(abbrev1); 244 free(abbrev1);
240 free(abbrev2); 245 free(abbrev2);
241 if (mode1 != 0 && mode2 != 0) { 246 if (mode1 != 0 && mode2 != 0) {
242 htmlf(" %.6o", mode1); 247 htmlf(" %.6o", mode1);
243 if (mode2 != mode1) 248 if (mode2 != mode1)
244 htmlf("..%.6o", mode2); 249 htmlf("..%.6o", mode2);
245 } 250 }
246 html("<br/>--- a/"); 251 html("<br/>--- a/");
247 if (mode1 != 0) 252 if (mode1 != 0)
248 cgit_tree_link(path1, NULL, NULL, ctx.qry.head, 253 cgit_tree_link(path1, NULL, NULL, ctx.qry.head,
249 sha1_to_hex(old_rev_sha1), path1); 254 sha1_to_hex(old_rev_sha1), path1);
250 else 255 else
251 html_txt(path1); 256 html_txt(path1);
252 html("<br/>+++ b/"); 257 html("<br/>+++ b/");
253 if (mode2 != 0) 258 if (mode2 != 0)
254 cgit_tree_link(path2, NULL, NULL, ctx.qry.head, 259 cgit_tree_link(path2, NULL, NULL, ctx.qry.head,
255 sha1_to_hex(new_rev_sha1), path2); 260 sha1_to_hex(new_rev_sha1), path2);
256 else 261 else
257 html_txt(path2); 262 html_txt(path2);
258 } 263 }
259 html("</div>"); 264 html("</div>");
260} 265}
261 266
262static void print_ssdiff_link() 267static void print_ssdiff_link()
263{ 268{
264 if (!strcmp(ctx.qry.page, "diff")) { 269 if (!strcmp(ctx.qry.page, "diff")) {
265 if (use_ssdiff) 270 if (use_ssdiff)
266 cgit_diff_link("Unidiff", NULL, NULL, ctx.qry.head, 271 cgit_diff_link("Unidiff", NULL, NULL, ctx.qry.head,
267 ctx.qry.sha1, ctx.qry.sha2, ctx.qry.path, 1); 272 ctx.qry.sha1, ctx.qry.sha2, ctx.qry.path, 1);
268 else 273 else
269 cgit_diff_link("Side-by-side diff", NULL, NULL, 274 cgit_diff_link("Side-by-side diff", NULL, NULL,
diff --git a/ui-shared.c b/ui-shared.c
index c99bcec..f46c935 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -256,240 +256,250 @@ static void reporevlink(const char *page, const char *name, const char *title,
256 html_txt(name); 256 html_txt(name);
257 html("</a>"); 257 html("</a>");
258} 258}
259 259
260void cgit_summary_link(const char *name, const char *title, const char *class, 260void cgit_summary_link(const char *name, const char *title, const char *class,
261 const char *head) 261 const char *head)
262{ 262{
263 reporevlink(NULL, name, title, class, head, NULL, NULL); 263 reporevlink(NULL, name, title, class, head, NULL, NULL);
264} 264}
265 265
266void cgit_tag_link(const char *name, const char *title, const char *class, 266void cgit_tag_link(const char *name, const char *title, const char *class,
267 const char *head, const char *rev) 267 const char *head, const char *rev)
268{ 268{
269 reporevlink("tag", name, title, class, head, rev, NULL); 269 reporevlink("tag", name, title, class, head, rev, NULL);
270} 270}
271 271
272void cgit_tree_link(const char *name, const char *title, const char *class, 272void cgit_tree_link(const char *name, const char *title, const char *class,
273 const char *head, const char *rev, const char *path) 273 const char *head, const char *rev, const char *path)
274{ 274{
275 reporevlink("tree", name, title, class, head, rev, path); 275 reporevlink("tree", name, title, class, head, rev, path);
276} 276}
277 277
278void cgit_plain_link(const char *name, const char *title, const char *class, 278void cgit_plain_link(const char *name, const char *title, const char *class,
279 const char *head, const char *rev, const char *path) 279 const char *head, const char *rev, const char *path)
280{ 280{
281 reporevlink("plain", name, title, class, head, rev, path); 281 reporevlink("plain", name, title, class, head, rev, path);
282} 282}
283 283
284void cgit_log_link(const char *name, const char *title, const char *class, 284void cgit_log_link(const char *name, const char *title, const char *class,
285 const char *head, const char *rev, const char *path, 285 const char *head, const char *rev, const char *path,
286 int ofs, const char *grep, const char *pattern, int showmsg) 286 int ofs, const char *grep, const char *pattern, int showmsg)
287{ 287{
288 char *delim; 288 char *delim;
289 289
290 delim = repolink(title, class, "log", head, path); 290 delim = repolink(title, class, "log", head, path);
291 if (rev && strcmp(rev, ctx.qry.head)) { 291 if (rev && strcmp(rev, ctx.qry.head)) {
292 html(delim); 292 html(delim);
293 html("id="); 293 html("id=");
294 html_url_arg(rev); 294 html_url_arg(rev);
295 delim = "&"; 295 delim = "&";
296 } 296 }
297 if (grep && pattern) { 297 if (grep && pattern) {
298 html(delim); 298 html(delim);
299 html("qt="); 299 html("qt=");
300 html_url_arg(grep); 300 html_url_arg(grep);
301 delim = "&"; 301 delim = "&";
302 html(delim); 302 html(delim);
303 html("q="); 303 html("q=");
304 html_url_arg(pattern); 304 html_url_arg(pattern);
305 } 305 }
306 if (ofs > 0) { 306 if (ofs > 0) {
307 html(delim); 307 html(delim);
308 html("ofs="); 308 html("ofs=");
309 htmlf("%d", ofs); 309 htmlf("%d", ofs);
310 delim = "&"; 310 delim = "&";
311 } 311 }
312 if (showmsg) { 312 if (showmsg) {
313 html(delim); 313 html(delim);
314 html("showmsg=1"); 314 html("showmsg=1");
315 } 315 }
316 html("'>"); 316 html("'>");
317 html_txt(name); 317 html_txt(name);
318 html("</a>"); 318 html("</a>");
319} 319}
320 320
321void cgit_commit_link(char *name, const char *title, const char *class, 321void cgit_commit_link(char *name, const char *title, const char *class,
322 const char *head, const char *rev, const char *path, 322 const char *head, const char *rev, const char *path,
323 int toggle_ssdiff) 323 int toggle_ssdiff)
324{ 324{
325 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) {
326 name[ctx.cfg.max_msg_len] = '\0'; 326 name[ctx.cfg.max_msg_len] = '\0';
327 name[ctx.cfg.max_msg_len - 1] = '.'; 327 name[ctx.cfg.max_msg_len - 1] = '.';
328 name[ctx.cfg.max_msg_len - 2] = '.'; 328 name[ctx.cfg.max_msg_len - 2] = '.';
329 name[ctx.cfg.max_msg_len - 3] = '.'; 329 name[ctx.cfg.max_msg_len - 3] = '.';
330 } 330 }
331 331
332 char *delim; 332 char *delim;
333 333
334 delim = repolink(title, class, "commit", head, path); 334 delim = repolink(title, class, "commit", head, path);
335 if (rev && strcmp(rev, ctx.qry.head)) { 335 if (rev && strcmp(rev, ctx.qry.head)) {
336 html(delim); 336 html(delim);
337 html("id="); 337 html("id=");
338 html_url_arg(rev); 338 html_url_arg(rev);
339 delim = "&amp;"; 339 delim = "&amp;";
340 } 340 }
341 if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) { 341 if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) {
342 html(delim); 342 html(delim);
343 html("ss=1"); 343 html("ss=1");
344 delim = "&amp;"; 344 delim = "&amp;";
345 } 345 }
346 if (ctx.qry.context > 0 && ctx.qry.context != 3) { 346 if (ctx.qry.context > 0 && ctx.qry.context != 3) {
347 html(delim); 347 html(delim);
348 html("context="); 348 html("context=");
349 htmlf("%d", ctx.qry.context); 349 htmlf("%d", ctx.qry.context);
350 delim = "&amp;"; 350 delim = "&amp;";
351 } 351 }
352 if (ctx.qry.ignorews) {
353 html(delim);
354 html("ignorews=1");
355 delim = "&amp;";
356 }
352 html("'>"); 357 html("'>");
353 html_txt(name); 358 html_txt(name);
354 html("</a>"); 359 html("</a>");
355} 360}
356 361
357void cgit_refs_link(const char *name, const char *title, const char *class, 362void cgit_refs_link(const char *name, const char *title, const char *class,
358 const char *head, const char *rev, const char *path) 363 const char *head, const char *rev, const char *path)
359{ 364{
360 reporevlink("refs", name, title, class, head, rev, path); 365 reporevlink("refs", name, title, class, head, rev, path);
361} 366}
362 367
363void cgit_snapshot_link(const char *name, const char *title, const char *class, 368void cgit_snapshot_link(const char *name, const char *title, const char *class,
364 const char *head, const char *rev, 369 const char *head, const char *rev,
365 const char *archivename) 370 const char *archivename)
366{ 371{
367 reporevlink("snapshot", name, title, class, head, rev, archivename); 372 reporevlink("snapshot", name, title, class, head, rev, archivename);
368} 373}
369 374
370void cgit_diff_link(const char *name, const char *title, const char *class, 375void cgit_diff_link(const char *name, const char *title, const char *class,
371 const char *head, const char *new_rev, const char *old_rev, 376 const char *head, const char *new_rev, const char *old_rev,
372 const char *path, int toggle_ssdiff) 377 const char *path, int toggle_ssdiff)
373{ 378{
374 char *delim; 379 char *delim;
375 380
376 delim = repolink(title, class, "diff", head, path); 381 delim = repolink(title, class, "diff", head, path);
377 if (new_rev && ctx.qry.head != NULL && strcmp(new_rev, ctx.qry.head)) { 382 if (new_rev && ctx.qry.head != NULL && strcmp(new_rev, ctx.qry.head)) {
378 html(delim); 383 html(delim);
379 html("id="); 384 html("id=");
380 html_url_arg(new_rev); 385 html_url_arg(new_rev);
381 delim = "&amp;"; 386 delim = "&amp;";
382 } 387 }
383 if (old_rev) { 388 if (old_rev) {
384 html(delim); 389 html(delim);
385 html("id2="); 390 html("id2=");
386 html_url_arg(old_rev); 391 html_url_arg(old_rev);
387 delim = "&amp;"; 392 delim = "&amp;";
388 } 393 }
389 if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) { 394 if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) {
390 html(delim); 395 html(delim);
391 html("ss=1"); 396 html("ss=1");
392 delim = "&amp;"; 397 delim = "&amp;";
393 } 398 }
394 if (ctx.qry.context > 0 && ctx.qry.context != 3) { 399 if (ctx.qry.context > 0 && ctx.qry.context != 3) {
395 html(delim); 400 html(delim);
396 html("context="); 401 html("context=");
397 htmlf("%d", ctx.qry.context); 402 htmlf("%d", ctx.qry.context);
398 delim = "&amp;"; 403 delim = "&amp;";
399 } 404 }
405 if (ctx.qry.ignorews) {
406 html(delim);
407 html("ignorews=1");
408 delim = "&amp;";
409 }
400 html("'>"); 410 html("'>");
401 html_txt(name); 411 html_txt(name);
402 html("</a>"); 412 html("</a>");
403} 413}
404 414
405void cgit_patch_link(const char *name, const char *title, const char *class, 415void cgit_patch_link(const char *name, const char *title, const char *class,
406 const char *head, const char *rev, const char *path) 416 const char *head, const char *rev, const char *path)
407{ 417{
408 reporevlink("patch", name, title, class, head, rev, path); 418 reporevlink("patch", name, title, class, head, rev, path);
409} 419}
410 420
411void cgit_stats_link(const char *name, const char *title, const char *class, 421void cgit_stats_link(const char *name, const char *title, const char *class,
412 const char *head, const char *path) 422 const char *head, const char *path)
413{ 423{
414 reporevlink("stats", name, title, class, head, NULL, path); 424 reporevlink("stats", name, title, class, head, NULL, path);
415} 425}
416 426
417void cgit_self_link(char *name, const char *title, const char *class, 427void cgit_self_link(char *name, const char *title, const char *class,
418 struct cgit_context *ctx) 428 struct cgit_context *ctx)
419{ 429{
420 if (!strcmp(ctx->qry.page, "repolist")) 430 if (!strcmp(ctx->qry.page, "repolist"))
421 return cgit_index_link(name, title, class, ctx->qry.search, 431 return cgit_index_link(name, title, class, ctx->qry.search,
422 ctx->qry.ofs); 432 ctx->qry.ofs);
423 else if (!strcmp(ctx->qry.page, "summary")) 433 else if (!strcmp(ctx->qry.page, "summary"))
424 return cgit_summary_link(name, title, class, ctx->qry.head); 434 return cgit_summary_link(name, title, class, ctx->qry.head);
425 else if (!strcmp(ctx->qry.page, "tag")) 435 else if (!strcmp(ctx->qry.page, "tag"))
426 return cgit_tag_link(name, title, class, ctx->qry.head, 436 return cgit_tag_link(name, title, class, ctx->qry.head,
427 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL); 437 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL);
428 else if (!strcmp(ctx->qry.page, "tree")) 438 else if (!strcmp(ctx->qry.page, "tree"))
429 return cgit_tree_link(name, title, class, ctx->qry.head, 439 return cgit_tree_link(name, title, class, ctx->qry.head,
430 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, 440 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
431 ctx->qry.path); 441 ctx->qry.path);
432 else if (!strcmp(ctx->qry.page, "plain")) 442 else if (!strcmp(ctx->qry.page, "plain"))
433 return cgit_plain_link(name, title, class, ctx->qry.head, 443 return cgit_plain_link(name, title, class, ctx->qry.head,
434 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, 444 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
435 ctx->qry.path); 445 ctx->qry.path);
436 else if (!strcmp(ctx->qry.page, "log")) 446 else if (!strcmp(ctx->qry.page, "log"))
437 return cgit_log_link(name, title, class, ctx->qry.head, 447 return cgit_log_link(name, title, class, ctx->qry.head,
438 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, 448 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
439 ctx->qry.path, ctx->qry.ofs, 449 ctx->qry.path, ctx->qry.ofs,
440 ctx->qry.grep, ctx->qry.search, 450 ctx->qry.grep, ctx->qry.search,
441 ctx->qry.showmsg); 451 ctx->qry.showmsg);
442 else if (!strcmp(ctx->qry.page, "commit")) 452 else if (!strcmp(ctx->qry.page, "commit"))
443 return cgit_commit_link(name, title, class, ctx->qry.head, 453 return cgit_commit_link(name, title, class, ctx->qry.head,
444 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, 454 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
445 ctx->qry.path, 0); 455 ctx->qry.path, 0);
446 else if (!strcmp(ctx->qry.page, "patch")) 456 else if (!strcmp(ctx->qry.page, "patch"))
447 return cgit_patch_link(name, title, class, ctx->qry.head, 457 return cgit_patch_link(name, title, class, ctx->qry.head,
448 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, 458 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
449 ctx->qry.path); 459 ctx->qry.path);
450 else if (!strcmp(ctx->qry.page, "refs")) 460 else if (!strcmp(ctx->qry.page, "refs"))
451 return cgit_refs_link(name, title, class, ctx->qry.head, 461 return cgit_refs_link(name, title, class, ctx->qry.head,
452 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, 462 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
453 ctx->qry.path); 463 ctx->qry.path);
454 else if (!strcmp(ctx->qry.page, "snapshot")) 464 else if (!strcmp(ctx->qry.page, "snapshot"))
455 return cgit_snapshot_link(name, title, class, ctx->qry.head, 465 return cgit_snapshot_link(name, title, class, ctx->qry.head,
456 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, 466 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
457 ctx->qry.path); 467 ctx->qry.path);
458 else if (!strcmp(ctx->qry.page, "diff")) 468 else if (!strcmp(ctx->qry.page, "diff"))
459 return cgit_diff_link(name, title, class, ctx->qry.head, 469 return cgit_diff_link(name, title, class, ctx->qry.head,
460 ctx->qry.sha1, ctx->qry.sha2, 470 ctx->qry.sha1, ctx->qry.sha2,
461 ctx->qry.path, 0); 471 ctx->qry.path, 0);
462 else if (!strcmp(ctx->qry.page, "stats")) 472 else if (!strcmp(ctx->qry.page, "stats"))
463 return cgit_stats_link(name, title, class, ctx->qry.head, 473 return cgit_stats_link(name, title, class, ctx->qry.head,
464 ctx->qry.path); 474 ctx->qry.path);
465 475
466 /* Don't known how to make link for this page */ 476 /* Don't known how to make link for this page */
467 repolink(title, class, ctx->qry.page, ctx->qry.head, ctx->qry.path); 477 repolink(title, class, ctx->qry.page, ctx->qry.head, ctx->qry.path);
468 html("><!-- cgit_self_link() doesn't know how to make link for page '"); 478 html("><!-- cgit_self_link() doesn't know how to make link for page '");
469 html_txt(ctx->qry.page); 479 html_txt(ctx->qry.page);
470 html("' -->"); 480 html("' -->");
471 html_txt(name); 481 html_txt(name);
472 html("</a>"); 482 html("</a>");
473} 483}
474 484
475void cgit_object_link(struct object *obj) 485void cgit_object_link(struct object *obj)
476{ 486{
477 char *page, *shortrev, *fullrev, *name; 487 char *page, *shortrev, *fullrev, *name;
478 488
479 fullrev = sha1_to_hex(obj->sha1); 489 fullrev = sha1_to_hex(obj->sha1);
480 shortrev = xstrdup(fullrev); 490 shortrev = xstrdup(fullrev);
481 shortrev[10] = '\0'; 491 shortrev[10] = '\0';
482 if (obj->type == OBJ_COMMIT) { 492 if (obj->type == OBJ_COMMIT) {
483 cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL, 493 cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL,
484 ctx.qry.head, fullrev, NULL, 0); 494 ctx.qry.head, fullrev, NULL, 0);
485 return; 495 return;
486 } else if (obj->type == OBJ_TREE) 496 } else if (obj->type == OBJ_TREE)
487 page = "tree"; 497 page = "tree";
488 else if (obj->type == OBJ_TAG) 498 else if (obj->type == OBJ_TAG)
489 page = "tag"; 499 page = "tag";
490 else 500 else
491 page = "blob"; 501 page = "blob";
492 name = fmt("%s %s...", typename(obj->type), shortrev); 502 name = fmt("%s %s...", typename(obj->type), shortrev);
493 reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL); 503 reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL);
494} 504}
495 505