diff options
| -rw-r--r-- | Makefile | 1 | ||||
| -rw-r--r-- | cgit.c | 5 | ||||
| -rw-r--r-- | cgit.css | 99 | ||||
| -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 | 62 | ||||
| -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 | ||||
| -rw-r--r-- | ui-ssdiff.c | 369 | ||||
| -rw-r--r-- | ui-ssdiff.h | 13 |
13 files changed, 586 insertions, 25 deletions
| @@ -93,6 +93,7 @@ OBJECTS += ui-refs.o | |||
| 93 | OBJECTS += ui-repolist.o | 93 | OBJECTS += ui-repolist.o |
| 94 | OBJECTS += ui-shared.o | 94 | OBJECTS += ui-shared.o |
| 95 | OBJECTS += ui-snapshot.o | 95 | OBJECTS += ui-snapshot.o |
| 96 | OBJECTS += ui-ssdiff.o | ||
| 96 | OBJECTS += ui-stats.o | 97 | OBJECTS += ui-stats.o |
| 97 | OBJECTS += ui-summary.o | 98 | OBJECTS += ui-summary.o |
| 98 | OBJECTS += ui-tag.o | 99 | OBJECTS += ui-tag.o |
| @@ -184,6 +184,8 @@ void config_cb(const char *name, const char *value) | |||
| 184 | ctx.cfg.summary_branches = atoi(value); | 184 | ctx.cfg.summary_branches = atoi(value); |
| 185 | else if (!strcmp(name, "summary-tags")) | 185 | else if (!strcmp(name, "summary-tags")) |
| 186 | ctx.cfg.summary_tags = atoi(value); | 186 | ctx.cfg.summary_tags = atoi(value); |
| 187 | else if (!strcmp(name, "side-by-side-diffs")) | ||
| 188 | ctx.cfg.ssdiff = atoi(value); | ||
| 187 | else if (!strcmp(name, "agefile")) | 189 | else if (!strcmp(name, "agefile")) |
| 188 | ctx.cfg.agefile = xstrdup(value); | 190 | ctx.cfg.agefile = xstrdup(value); |
| 189 | else if (!strcmp(name, "renamelimit")) | 191 | else if (!strcmp(name, "renamelimit")) |
| @@ -242,6 +244,8 @@ static void querystring_cb(const char *name, const char *value) | |||
| 242 | ctx.qry.showmsg = atoi(value); | 244 | ctx.qry.showmsg = atoi(value); |
| 243 | } else if (!strcmp(name, "period")) { | 245 | } else if (!strcmp(name, "period")) { |
| 244 | ctx.qry.period = xstrdup(value); | 246 | ctx.qry.period = xstrdup(value); |
| 247 | } else if (!strcmp(name, "ss")) { | ||
| 248 | ctx.qry.ssdiff = atoi(value); | ||
| 245 | } | 249 | } |
| 246 | } | 250 | } |
| 247 | 251 | ||
| @@ -284,6 +288,7 @@ static void prepare_context(struct cgit_context *ctx) | |||
| 284 | ctx->cfg.summary_branches = 10; | 288 | ctx->cfg.summary_branches = 10; |
| 285 | ctx->cfg.summary_log = 10; | 289 | ctx->cfg.summary_log = 10; |
| 286 | ctx->cfg.summary_tags = 10; | 290 | ctx->cfg.summary_tags = 10; |
| 291 | ctx->cfg.ssdiff = 0; | ||
| 287 | ctx->env.cgit_config = xstrdupn(getenv("CGIT_CONFIG")); | 292 | ctx->env.cgit_config = xstrdupn(getenv("CGIT_CONFIG")); |
| 288 | ctx->env.http_host = xstrdupn(getenv("HTTP_HOST")); | 293 | ctx->env.http_host = xstrdupn(getenv("HTTP_HOST")); |
| 289 | ctx->env.https = xstrdupn(getenv("HTTPS")); | 294 | ctx->env.https = xstrdupn(getenv("HTTPS")); |
| @@ -606,3 +606,102 @@ table.hgraph div.bar { | |||
| 606 | background-color: #eee; | 606 | background-color: #eee; |
| 607 | height: 1em; | 607 | height: 1em; |
| 608 | } | 608 | } |
| 609 | |||
| 610 | table.ssdiff { | ||
| 611 | width: 100%; | ||
| 612 | } | ||
| 613 | |||
| 614 | table.ssdiff td { | ||
| 615 | font-size: 75%; | ||
| 616 | font-family: monospace; | ||
| 617 | white-space: pre; | ||
| 618 | padding: 1px 4px 1px 4px; | ||
| 619 | border-left: solid 1px #aaa; | ||
| 620 | border-right: solid 1px #aaa; | ||
| 621 | } | ||
| 622 | |||
| 623 | table.ssdiff td.add { | ||
| 624 | color: black; | ||
| 625 | background: #cfc; | ||
| 626 | min-width: 50%; | ||
| 627 | } | ||
| 628 | |||
| 629 | table.ssdiff td.add_dark { | ||
| 630 | color: black; | ||
| 631 | background: #aca; | ||
| 632 | min-width: 50%; | ||
| 633 | } | ||
| 634 | |||
| 635 | table.ssdiff span.add { | ||
| 636 | background: #cfc; | ||
| 637 | font-weight: bold; | ||
| 638 | } | ||
| 639 | |||
| 640 | table.ssdiff td.del { | ||
| 641 | color: black; | ||
| 642 | background: #fcc; | ||
| 643 | min-width: 50%; | ||
| 644 | } | ||
| 645 | |||
| 646 | table.ssdiff td.del_dark { | ||
| 647 | color: black; | ||
| 648 | background: #caa; | ||
| 649 | min-width: 50%; | ||
| 650 | } | ||
| 651 | |||
| 652 | table.ssdiff span.del { | ||
| 653 | background: #fcc; | ||
| 654 | font-weight: bold; | ||
| 655 | } | ||
| 656 | |||
| 657 | table.ssdiff td.changed { | ||
| 658 | color: black; | ||
| 659 | background: #ffc; | ||
| 660 | min-width: 50%; | ||
| 661 | } | ||
| 662 | |||
| 663 | table.ssdiff td.changed_dark { | ||
| 664 | color: black; | ||
| 665 | background: #cca; | ||
| 666 | min-width: 50%; | ||
| 667 | } | ||
| 668 | |||
| 669 | table.ssdiff td.lineno { | ||
| 670 | color: black; | ||
| 671 | background: #eee; | ||
| 672 | text-align: right; | ||
| 673 | width: 3em; | ||
| 674 | min-width: 3em; | ||
| 675 | } | ||
| 676 | |||
| 677 | table.ssdiff td.hunk { | ||
| 678 | color: #black; | ||
| 679 | background: #ccf; | ||
| 680 | border-top: solid 1px #aaa; | ||
| 681 | border-bottom: solid 1px #aaa; | ||
| 682 | } | ||
| 683 | |||
| 684 | table.ssdiff td.head { | ||
| 685 | border-top: solid 1px #aaa; | ||
| 686 | border-bottom: solid 1px #aaa; | ||
| 687 | } | ||
| 688 | |||
| 689 | table.ssdiff td.head div.head { | ||
| 690 | font-weight: bold; | ||
| 691 | color: black; | ||
| 692 | } | ||
| 693 | |||
| 694 | table.ssdiff td.foot { | ||
| 695 | border-top: solid 1px #aaa; | ||
| 696 | border-left: none; | ||
| 697 | border-right: none; | ||
| 698 | border-bottom: none; | ||
| 699 | } | ||
| 700 | |||
| 701 | table.ssdiff td.space { | ||
| 702 | border: none; | ||
| 703 | } | ||
| 704 | |||
| 705 | table.ssdiff td.space div { | ||
| 706 | min-height: 3em; | ||
| 707 | } \ No newline at end of file | ||
| @@ -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 { |
| @@ -195,6 +196,7 @@ struct cgit_config { | |||
| 195 | int summary_branches; | 196 | int summary_branches; |
| 196 | int summary_log; | 197 | int summary_log; |
| 197 | int summary_tags; | 198 | int summary_tags; |
| 199 | int ssdiff; | ||
| 198 | struct string_list mimetypes; | 200 | struct string_list mimetypes; |
| 199 | struct cgit_filter *about_filter; | 201 | struct cgit_filter *about_filter; |
| 200 | struct cgit_filter *commit_filter; | 202 | struct cgit_filter *commit_filter; |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index e69140b..70e4c78 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
| @@ -245,6 +245,10 @@ section:: | |||
| 245 | after this option will inherit the current section name. Default value: | 245 | after this option will inherit the current section name. Default value: |
| 246 | none. | 246 | none. |
| 247 | 247 | ||
| 248 | side-by-side-diffs:: | ||
| 249 | If set to "1" shows side-by-side diffs instead of unidiffs per | ||
| 250 | default. Default value: "0". | ||
| 251 | |||
| 248 | snapshots:: | 252 | snapshots:: |
| 249 | Text which specifies the default set of snapshot formats generated by | 253 | Text which specifies the default set of snapshot formats generated by |
| 250 | cgit. The value is a space-separated list of zero or more of the | 254 | 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 | } |
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "cgit.h" | 9 | #include "cgit.h" |
| 10 | #include "html.h" | 10 | #include "html.h" |
| 11 | #include "ui-shared.h" | 11 | #include "ui-shared.h" |
| 12 | #include "ui-ssdiff.h" | ||
| 12 | 13 | ||
| 13 | unsigned char old_rev_sha1[20]; | 14 | unsigned char old_rev_sha1[20]; |
| 14 | unsigned char new_rev_sha1[20]; | 15 | unsigned char new_rev_sha1[20]; |
| @@ -32,6 +33,7 @@ static struct fileinfo { | |||
| 32 | int binary:1; | 33 | int binary:1; |
| 33 | } *items; | 34 | } *items; |
| 34 | 35 | ||
| 36 | static int use_ssdiff = 0; | ||
| 35 | 37 | ||
| 36 | static void print_fileinfo(struct fileinfo *info) | 38 | static void print_fileinfo(struct fileinfo *info) |
| 37 | { | 39 | { |
| @@ -83,7 +85,7 @@ static void print_fileinfo(struct fileinfo *info) | |||
| 83 | } | 85 | } |
| 84 | htmlf("</td><td class='%s'>", class); | 86 | htmlf("</td><td class='%s'>", class); |
| 85 | 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, |
| 86 | ctx.qry.sha2, info->new_path); | 88 | ctx.qry.sha2, info->new_path, 0); |
| 87 | if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED) | 89 | if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED) |
| 88 | htmlf(" (%s from %s)", | 90 | htmlf(" (%s from %s)", |
| 89 | info->status == DIFF_STATUS_COPIED ? "copied" : "renamed", | 91 | info->status == DIFF_STATUS_COPIED ? "copied" : "renamed", |
| @@ -158,7 +160,7 @@ void cgit_print_diffstat(const unsigned char *old_sha1, | |||
| 158 | 160 | ||
| 159 | html("<div class='diffstat-header'>"); | 161 | html("<div class='diffstat-header'>"); |
| 160 | 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, |
| 161 | ctx.qry.sha2, NULL); | 163 | ctx.qry.sha2, NULL, 0); |
| 162 | html("</div>"); | 164 | html("</div>"); |
| 163 | html("<table summary='diffstat' class='diffstat'>"); | 165 | html("<table summary='diffstat' class='diffstat'>"); |
| 164 | max_changes = 0; | 166 | max_changes = 0; |
| @@ -246,26 +248,54 @@ static void header(unsigned char *sha1, char *path1, int mode1, | |||
| 246 | html("</div>"); | 248 | html("</div>"); |
| 247 | } | 249 | } |
| 248 | 250 | ||
| 251 | static void print_ssdiff_link() | ||
| 252 | { | ||
| 253 | if (!strcmp(ctx.qry.page, "diff")) { | ||
| 254 | if (use_ssdiff) | ||
| 255 | cgit_diff_link("Unidiff", NULL, NULL, ctx.qry.head, | ||
| 256 | ctx.qry.sha1, ctx.qry.sha2, ctx.qry.path, 1); | ||
| 257 | else | ||
| 258 | cgit_diff_link("Side-by-side diff", NULL, NULL, | ||
| 259 | ctx.qry.head, ctx.qry.sha1, | ||
| 260 | ctx.qry.sha2, ctx.qry.path, 1); | ||
| 261 | } | ||
| 262 | } | ||
| 263 | |||
| 249 | static void filepair_cb(struct diff_filepair *pair) | 264 | static void filepair_cb(struct diff_filepair *pair) |
| 250 | { | 265 | { |
| 251 | unsigned long old_size = 0; | 266 | unsigned long old_size = 0; |
| 252 | unsigned long new_size = 0; | 267 | unsigned long new_size = 0; |
| 253 | int binary = 0; | 268 | int binary = 0; |
| 269 | linediff_fn print_line_fn = print_line; | ||
| 254 | 270 | ||
| 271 | if (use_ssdiff) { | ||
| 272 | cgit_ssdiff_header_begin(); | ||
| 273 | print_line_fn = cgit_ssdiff_line_cb; | ||
| 274 | } | ||
| 255 | header(pair->one->sha1, pair->one->path, pair->one->mode, | 275 | header(pair->one->sha1, pair->one->path, pair->one->mode, |
| 256 | pair->two->sha1, pair->two->path, pair->two->mode); | 276 | pair->two->sha1, pair->two->path, pair->two->mode); |
| 277 | if (use_ssdiff) | ||
| 278 | cgit_ssdiff_header_end(); | ||
| 257 | if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) { | 279 | if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) { |
| 258 | if (S_ISGITLINK(pair->one->mode)) | 280 | if (S_ISGITLINK(pair->one->mode)) |
| 259 | print_line(fmt("-Subproject %s", sha1_to_hex(pair->one->sha1)), 52); | 281 | print_line_fn(fmt("-Subproject %s", sha1_to_hex(pair->one->sha1)), 52); |
| 260 | if (S_ISGITLINK(pair->two->mode)) | 282 | if (S_ISGITLINK(pair->two->mode)) |
| 261 | print_line(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52); | 283 | print_line_fn(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52); |
| 284 | if (use_ssdiff) | ||
| 285 | cgit_ssdiff_footer(); | ||
| 262 | return; | 286 | return; |
| 263 | } | 287 | } |
| 264 | if (cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, | 288 | if (cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, |
| 265 | &new_size, &binary, print_line)) | 289 | &new_size, &binary, print_line_fn)) |
| 266 | cgit_print_error("Error running diff"); | 290 | cgit_print_error("Error running diff"); |
| 267 | if (binary) | 291 | if (binary) { |
| 268 | html("Binary files differ"); | ||
