diff options
-rw-r--r-- | cgit.c | 5 | ||||
-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | cgitrc.5.txt | 4 | ||||
-rw-r--r-- | ui-commit.c | 11 | ||||
-rw-r--r-- | ui-diff.c | 22 | ||||
-rw-r--r-- | ui-log.c | 4 | ||||
-rw-r--r-- | ui-refs.c | 2 | ||||
-rw-r--r-- | ui-shared.c | 34 | ||||
-rw-r--r-- | ui-shared.h | 5 |
9 files changed, 73 insertions, 16 deletions
@@ -182,6 +182,8 @@ void config_cb(const char *name, const char *value) | |||
182 | ctx.cfg.summary_branches = atoi(value); | 182 | ctx.cfg.summary_branches = atoi(value); |
183 | else if (!strcmp(name, "summary-tags")) | 183 | else if (!strcmp(name, "summary-tags")) |
184 | ctx.cfg.summary_tags = atoi(value); | 184 | ctx.cfg.summary_tags = atoi(value); |
185 | else if (!strcmp(name, "side-by-side-diffs")) | ||
186 | ctx.cfg.ssdiff = atoi(value); | ||
185 | else if (!strcmp(name, "agefile")) | 187 | else if (!strcmp(name, "agefile")) |
186 | ctx.cfg.agefile = xstrdup(value); | 188 | ctx.cfg.agefile = xstrdup(value); |
187 | else if (!strcmp(name, "renamelimit")) | 189 | else if (!strcmp(name, "renamelimit")) |
@@ -238,6 +240,8 @@ static void querystring_cb(const char *name, const char *value) | |||
238 | ctx.qry.showmsg = atoi(value); | 240 | ctx.qry.showmsg = atoi(value); |
239 | } else if (!strcmp(name, "period")) { | 241 | } else if (!strcmp(name, "period")) { |
240 | ctx.qry.period = xstrdup(value); | 242 | ctx.qry.period = xstrdup(value); |
243 | } else if (!strcmp(name, "ss")) { | ||
244 | ctx.qry.ssdiff = atoi(value); | ||
241 | } | 245 | } |
242 | } | 246 | } |
243 | 247 | ||
@@ -279,6 +283,7 @@ static void prepare_context(struct cgit_context *ctx) | |||
279 | ctx->cfg.summary_branches = 10; | 283 | ctx->cfg.summary_branches = 10; |
280 | ctx->cfg.summary_log = 10; | 284 | ctx->cfg.summary_log = 10; |
281 | ctx->cfg.summary_tags = 10; | 285 | ctx->cfg.summary_tags = 10; |
286 | ctx->cfg.ssdiff = 0; | ||
282 | ctx->env.cgit_config = xstrdupn(getenv("CGIT_CONFIG")); | 287 | ctx->env.cgit_config = xstrdupn(getenv("CGIT_CONFIG")); |
283 | ctx->env.http_host = xstrdupn(getenv("HTTP_HOST")); | 288 | ctx->env.http_host = xstrdupn(getenv("HTTP_HOST")); |
284 | ctx->env.https = xstrdupn(getenv("HTTPS")); | 289 | ctx->env.https = xstrdupn(getenv("HTTPS")); |
@@ -143,6 +143,7 @@ struct cgit_query { | |||
143 | int nohead; | 143 | int nohead; |
144 | char *sort; | 144 | char *sort; |
145 | int showmsg; | 145 | int showmsg; |
146 | int ssdiff; | ||
146 | }; | 147 | }; |
147 | 148 | ||
148 | struct cgit_config { | 149 | struct cgit_config { |
@@ -194,6 +195,7 @@ struct cgit_config { | |||
194 | int summary_branches; | 195 | int summary_branches; |
195 | int summary_log; | 196 | int summary_log; |
196 | int summary_tags; | 197 | int summary_tags; |
198 | int ssdiff; | ||
197 | struct string_list mimetypes; | 199 | struct string_list mimetypes; |
198 | struct cgit_filter *about_filter; | 200 | struct cgit_filter *about_filter; |
199 | struct cgit_filter *commit_filter; | 201 | struct cgit_filter *commit_filter; |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 4dc383d..252d546 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -238,6 +238,10 @@ section:: | |||
238 | after this option will inherit the current section name. Default value: | 238 | after this option will inherit the current section name. Default value: |
239 | none. | 239 | none. |
240 | 240 | ||
241 | side-by-side-diffs:: | ||
242 | If set to "1" shows side-by-side diffs instead of unidiffs per | ||
243 | default. Default value: "0". | ||
244 | |||
241 | snapshots:: | 245 | snapshots:: |
242 | Text which specifies the default set of snapshot formats generated by | 246 | Text which specifies the default set of snapshot formats generated by |
243 | cgit. The value is a space-separated list of zero or more of the | 247 | cgit. The value is a space-separated list of zero or more of the |
diff --git a/ui-commit.c b/ui-commit.c index f5b0ae5..b5e3c01 100644 --- a/ui-commit.c +++ b/ui-commit.c | |||
@@ -58,9 +58,14 @@ 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); | 61 | cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, 0); |
62 | html(" ("); | 62 | html(" ("); |
63 | cgit_patch_link("patch", NULL, NULL, NULL, tmp); | 63 | cgit_patch_link("patch", NULL, NULL, NULL, tmp); |
64 | html(") ("); | ||
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); | ||
67 | else | ||
68 | cgit_commit_link("side-by-side diff", NULL, NULL, ctx.qry.head, tmp, 1); | ||
64 | html(")</td></tr>\n"); | 69 | html(")</td></tr>\n"); |
65 | html("<tr><th>tree</th><td colspan='2' class='sha1'>"); | 70 | html("<tr><th>tree</th><td colspan='2' class='sha1'>"); |
66 | tmp = xstrdup(hex); | 71 | tmp = xstrdup(hex); |
@@ -78,10 +83,10 @@ void cgit_print_commit(char *hex) | |||
78 | html("<tr><th>parent</th>" | 83 | html("<tr><th>parent</th>" |
79 | "<td colspan='2' class='sha1'>"); | 84 | "<td colspan='2' class='sha1'>"); |
80 | cgit_commit_link(sha1_to_hex(p->item->object.sha1), NULL, NULL, | 85 | cgit_commit_link(sha1_to_hex(p->item->object.sha1), NULL, NULL, |
81 | ctx.qry.head, sha1_to_hex(p->item->object.sha1)); | 86 | ctx.qry.head, sha1_to_hex(p->item->object.sha1), 0); |
82 | html(" ("); | 87 | html(" ("); |
83 | cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex, | 88 | cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex, |
84 | sha1_to_hex(p->item->object.sha1), NULL); | 89 | sha1_to_hex(p->item->object.sha1), NULL, 0); |
85 | html(")</td></tr>"); | 90 | html(")</td></tr>"); |
86 | parents++; | 91 | parents++; |
87 | } | 92 | } |
@@ -85,7 +85,7 @@ static void print_fileinfo(struct fileinfo *info) | |||
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); | 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", |
@@ -160,7 +160,7 @@ void cgit_print_diffstat(const unsigned char *old_sha1, | |||
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); | 163 | ctx.qry.sha2, NULL, 0); |
164 | html("</div>"); | 164 | html("</div>"); |
165 | html("<table summary='diffstat' class='diffstat'>"); | 165 | html("<table summary='diffstat' class='diffstat'>"); |
166 | max_changes = 0; | 166 | max_changes = 0; |
@@ -250,6 +250,19 @@ static void header(unsigned char *sha1, char *path1, int mode1, | |||
250 | cgit_ssdiff_header(); | 250 | cgit_ssdiff_header(); |
251 | } | 251 | } |
252 | 252 | ||
253 | static void print_ssdiff_link() | ||
254 | { | ||
255 | if (!strcmp(ctx.qry.page, "diff")) { | ||
256 | if (use_ssdiff) | ||
257 | cgit_diff_link("Unidiff", NULL, NULL, ctx.qry.head, | ||
258 | ctx.qry.sha1, ctx.qry.sha2, NULL, 1); | ||
259 | else | ||
260 | cgit_diff_link("Side-by-side diff", NULL, NULL, | ||
261 | ctx.qry.head, ctx.qry.sha1, | ||
262 | ctx.qry.sha2, NULL, 1); | ||
263 | } | ||
264 | } | ||
265 | |||
253 | static void filepair_cb(struct diff_filepair *pair) | 266 | static void filepair_cb(struct diff_filepair *pair) |
254 | { | 267 | { |
255 | unsigned long old_size = 0; | 268 | unsigned long old_size = 0; |
@@ -314,6 +327,11 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefi | |||
314 | if (!commit2 || parse_commit(commit2)) | 327 | if (!commit2 || parse_commit(commit2)) |
315 | cgit_print_error(fmt("Bad commit: %s", sha1_to_hex(old_rev_sha1))); | 328 | cgit_print_error(fmt("Bad commit: %s", sha1_to_hex(old_rev_sha1))); |
316 | } | 329 | } |
330 | |||
331 | if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff)) | ||
332 | use_ssdiff = 1; | ||
333 | |||
334 | print_ssdiff_link(); | ||
317 | cgit_print_diffstat(old_rev_sha1, new_rev_sha1); | 335 | cgit_print_diffstat(old_rev_sha1, new_rev_sha1); |
318 | 336 | ||
319 | html("<table summary='diff' class='diff'>"); | 337 | html("<table summary='diff' class='diff'>"); |
@@ -66,7 +66,7 @@ void show_commit_decorations(struct commit *commit) | |||
66 | else { | 66 | else { |
67 | strncpy(buf, deco->name, sizeof(buf) - 1); | 67 | strncpy(buf, deco->name, sizeof(buf) - 1); |
68 | cgit_commit_link(buf, NULL, "deco", ctx.qry.head, | 68 | cgit_commit_link(buf, NULL, "deco", ctx.qry.head, |
69 | sha1_to_hex(commit->object.sha1)); | 69 | sha1_to_hex(commit->object.sha1), 0); |
70 | } | 70 | } |
71 | deco = deco->next; | 71 | deco = deco->next; |
72 | } | 72 | } |
@@ -89,7 +89,7 @@ void print_commit(struct commit *commit) | |||
89 | htmlf("</td><td%s>", | 89 | htmlf("</td><td%s>", |
90 | ctx.qry.showmsg ? " class='logsubject'" : ""); | 90 | ctx.qry.showmsg ? " class='logsubject'" : ""); |
91 | cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, | 91 | cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, |
92 | sha1_to_hex(commit->object.sha1)); | 92 | sha1_to_hex(commit->object.sha1), 0); |
93 | show_commit_decorations(commit); | 93 | show_commit_decorations(commit); |
94 | html("</td><td>"); | 94 | html("</td><td>"); |
95 | html_txt(info->author); | 95 | html_txt(info->author); |
@@ -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); | 77 | cgit_commit_link(info->subject, NULL, NULL, name, 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 07d5dd4..de55eff 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -317,7 +317,7 @@ void cgit_log_link(char *name, char *title, char *class, char *head, | |||
317 | } | 317 | } |
318 | 318 | ||
319 | void cgit_commit_link(char *name, char *title, char *class, char *head, | 319 | void cgit_commit_link(char *name, char *title, char *class, char *head, |
320 | char *rev) | 320 | char *rev, int toggle_ssdiff) |
321 | { | 321 | { |
322 | if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) { | 322 | if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) { |
323 | name[ctx.cfg.max_msg_len] = '\0'; | 323 | name[ctx.cfg.max_msg_len] = '\0'; |
@@ -325,7 +325,23 @@ void cgit_commit_link(char *name, char *title, char *class, char *head, | |||
325 | name[ctx.cfg.max_msg_len - 2] = '.'; | 325 | name[ctx.cfg.max_msg_len - 2] = '.'; |
326 | name[ctx.cfg.max_msg_len - 3] = '.'; | 326 | name[ctx.cfg.max_msg_len - 3] = '.'; |
327 | } | 327 | } |
328 | reporevlink("commit", name, title, class, head, rev, NULL); | 328 | |
329 | char *delim; | ||
330 | |||
331 | delim = repolink(title, class, "commit", head, NULL); | ||
332 | if (rev && strcmp(rev, ctx.qry.head)) { | ||
333 | html(delim); | ||
334 | html("id="); | ||
335 | html_url_arg(rev); | ||
336 | delim = "&"; | ||
337 | } | ||
338 | if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) { | ||
339 | html(delim); | ||
340 | html("ss=1"); | ||
341 | } | ||
342 | html("'>"); | ||
343 | html_txt(name); | ||
344 | html("</a>"); | ||
329 | } | 345 | } |
330 | 346 | ||
331 | void cgit_refs_link(char *name, char *title, char *class, char *head, | 347 | void cgit_refs_link(char *name, char *title, char *class, char *head, |
@@ -341,7 +357,8 @@ void cgit_snapshot_link(char *name, char *title, char *class, char *head, | |||
341 | } | 357 | } |
342 | 358 | ||
343 | void cgit_diff_link(char *name, char *title, char *class, char *head, | 359 | void cgit_diff_link(char *name, char *title, char *class, char *head, |
344 | char *new_rev, char *old_rev, char *path) | 360 | char *new_rev, char *old_rev, char *path, |
361 | int toggle_ssdiff) | ||
345 | { | 362 | { |
346 | char *delim; | 363 | char *delim; |
347 | 364 | ||
@@ -356,6 +373,11 @@ void cgit_diff_link(char *name, char *title, char *class, char *head, | |||
356 | html(delim); | 373 | html(delim); |
357 | html("id2="); | 374 | html("id2="); |
358 | html_url_arg(old_rev); | 375 | html_url_arg(old_rev); |
376 | delim = "&"; | ||
377 | } | ||
378 | if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) { | ||
379 | html(delim); | ||
380 | html("ss=1"); | ||
359 | } | 381 | } |
360 | html("'>"); | 382 | html("'>"); |
361 | html_txt(name); | 383 | html_txt(name); |
@@ -383,7 +405,7 @@ void cgit_object_link(struct object *obj) | |||
383 | shortrev[10] = '\0'; | 405 | shortrev[10] = '\0'; |
384 | if (obj->type == OBJ_COMMIT) { | 406 | if (obj->type == OBJ_COMMIT) { |
385 | cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL, | 407 | cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL, |
386 | ctx.qry.head, fullrev); | 408 | ctx.qry.head, fullrev, 0); |
387 | return; | 409 | return; |
388 | } else if (obj->type == OBJ_TREE) | 410 | } else if (obj->type == OBJ_TREE) |
389 | page = "tree"; | 411 | page = "tree"; |
@@ -695,9 +717,9 @@ void cgit_print_pageheader(struct cgit_context *ctx) | |||
695 | cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head, | 717 | cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head, |
696 | ctx->qry.sha1, NULL); | 718 | ctx->qry.sha1, NULL); |
697 | cgit_commit_link("commit", NULL, hc(cmd, "commit"), | 719 | cgit_commit_link("commit", NULL, hc(cmd, "commit"), |
698 | ctx->qry.head, ctx->qry.sha1); | 720 | ctx->qry.head, ctx->qry.sha1, 0); |
699 | cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head, | 721 | cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head, |
700 | ctx->qry.sha1, ctx->qry.sha2, NULL); | 722 | ctx->qry.sha1, ctx->qry.sha2, NULL, 0); |
701 | if (ctx->repo->max_stats) | 723 | if (ctx->repo->max_stats) |
702 | cgit_stats_link("stats", NULL, hc(cmd, "stats"), | 724 | cgit_stats_link("stats", NULL, hc(cmd, "stats"), |
703 | ctx->qry.head, NULL); | 725 | ctx->qry.head, NULL); |
diff --git a/ui-shared.h b/ui-shared.h index bff4826..166246d 100644 --- a/ui-shared.h +++ b/ui-shared.h | |||
@@ -22,7 +22,7 @@ extern void cgit_log_link(char *name, char *title, char *class, char *head, | |||
22 | char *rev, char *path, int ofs, char *grep, | 22 | char *rev, char *path, int ofs, char *grep, |
23 | char *pattern, int showmsg); | 23 | char *pattern, int showmsg); |
24 | extern void cgit_commit_link(char *name, char *title, char *class, char *head, | 24 | extern void cgit_commit_link(char *name, char *title, char *class, char *head, |
25 | char *rev); | 25 | char *rev, int toggle_ssdiff); |
26 | extern void cgit_patch_link(char *name, char *title, char *class, char *head, | 26 | extern void cgit_patch_link(char *name, char *title, char *class, char *head, |
27 | char *rev); | 27 | char *rev); |
28 | extern void cgit_refs_link(char *name, char *title, char *class, char *head, | 28 | extern void cgit_refs_link(char *name, char *title, char *class, char *head, |
@@ -30,7 +30,8 @@ extern void cgit_refs_link(char *name, char *title, char *class, char *head, | |||
30 | extern void cgit_snapshot_link(char *name, char *title, char *class, | 30 | extern void cgit_snapshot_link(char *name, char *title, char *class, |
31 | char *head, char *rev, char *archivename); | 31 | char *head, char *rev, char *archivename); |
32 | extern void cgit_diff_link(char *name, char *title, char *class, char *head, | 32 | extern void cgit_diff_link(char *name, char *title, char *class, char *head, |
33 | char *new_rev, char *old_rev, char *path); | 33 | char *new_rev, char *old_rev, char *path, |
34 | int toggle_ssdiff); | ||
34 | extern void cgit_stats_link(char *name, char *title, char *class, char *head, | 35 | extern void cgit_stats_link(char *name, char *title, char *class, char *head, |
35 | char *path); | 36 | char *path); |
36 | extern void cgit_object_link(struct object *obj); | 37 | extern void cgit_object_link(struct object *obj); |