diff options
-rw-r--r-- | Makefile | 16 | ||||
-rw-r--r-- | cgit.c | 14 | ||||
-rw-r--r-- | cgit.css | 104 | ||||
-rw-r--r-- | cgit.h | 5 | ||||
-rw-r--r-- | cgitrc.5.txt | 17 | ||||
-rwxr-xr-x | filters/syntax-highlighting.sh | 29 | ||||
-rw-r--r-- | shared.c | 1 | ||||
-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 | 4 | ||||
-rw-r--r-- | ui-shared.c | 43 | ||||
-rw-r--r-- | ui-shared.h | 5 | ||||
-rw-r--r-- | ui-snapshot.c | 14 | ||||
-rw-r--r-- | ui-ssdiff.c | 369 | ||||
-rw-r--r-- | ui-ssdiff.h | 13 | ||||
-rw-r--r-- | ui-tag.c | 24 | ||||
-rw-r--r-- | ui-tree.c | 6 |
18 files changed, 684 insertions, 57 deletions
@@ -11,6 +11,9 @@ INSTALL = install | |||
11 | 11 | ||
12 | # Define NO_STRCASESTR if you don't have strcasestr. | 12 | # Define NO_STRCASESTR if you don't have strcasestr. |
13 | # | 13 | # |
14 | # Define NO_OPENSSL to disable linking with OpenSSL and use bundled SHA1 | ||
15 | # implementation (slower). | ||
16 | # | ||
14 | # Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin). | 17 | # Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin). |
15 | # | 18 | # |
16 | 19 | ||
@@ -68,7 +71,7 @@ endif | |||
68 | $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $< | 71 | $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $< |
69 | 72 | ||
70 | 73 | ||
71 | EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto | 74 | EXTLIBS = git/libgit.a git/xdiff/lib.a -lz |
72 | OBJECTS = | 75 | OBJECTS = |
73 | OBJECTS += cache.o | 76 | OBJECTS += cache.o |
74 | OBJECTS += cgit.o | 77 | OBJECTS += cgit.o |
@@ -90,6 +93,7 @@ OBJECTS += ui-refs.o | |||
90 | OBJECTS += ui-repolist.o | 93 | OBJECTS += ui-repolist.o |
91 | OBJECTS += ui-shared.o | 94 | OBJECTS += ui-shared.o |
92 | OBJECTS += ui-snapshot.o | 95 | OBJECTS += ui-snapshot.o |
96 | OBJECTS += ui-ssdiff.o | ||
93 | OBJECTS += ui-stats.o | 97 | OBJECTS += ui-stats.o |
94 | OBJECTS += ui-summary.o | 98 | OBJECTS += ui-summary.o |
95 | OBJECTS += ui-tag.o | 99 | OBJECTS += ui-tag.o |
@@ -123,6 +127,12 @@ endif | |||
123 | ifdef NO_STRCASESTR | 127 | ifdef NO_STRCASESTR |
124 | CFLAGS += -DNO_STRCASESTR | 128 | CFLAGS += -DNO_STRCASESTR |
125 | endif | 129 | endif |
130 | ifdef NO_OPENSSL | ||
131 | CFLAGS += -DNO_OPENSSL | ||
132 | GIT_OPTIONS += NO_OPENSSL=1 | ||
133 | else | ||
134 | EXTLIBS += -lcrypto | ||
135 | endif | ||
126 | 136 | ||
127 | cgit: $(OBJECTS) libgit | 137 | cgit: $(OBJECTS) libgit |
128 | $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o cgit $(OBJECTS) $(EXTLIBS) | 138 | $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o cgit $(OBJECTS) $(EXTLIBS) |
@@ -132,8 +142,8 @@ cgit.o: VERSION | |||
132 | -include $(OBJECTS:.o=.d) | 142 | -include $(OBJECTS:.o=.d) |
133 | 143 | ||
134 | libgit: | 144 | libgit: |
135 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 libgit.a | 145 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) libgit.a |
136 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 xdiff/lib.a | 146 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) xdiff/lib.a |
137 | 147 | ||
138 | test: all | 148 | test: all |
139 | $(QUIET_SUBDIR0)tests $(QUIET_SUBDIR1) all | 149 | $(QUIET_SUBDIR0)tests $(QUIET_SUBDIR1) all |
@@ -60,6 +60,8 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value) | |||
60 | repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); | 60 | repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); |
61 | else if (!strcmp(name, "enable-log-linecount")) | 61 | else if (!strcmp(name, "enable-log-linecount")) |
62 | repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); | 62 | repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); |
63 | else if (!strcmp(name, "enable-remote-branches")) | ||
64 | repo->enable_remote_branches = atoi(value); | ||
63 | else if (!strcmp(name, "max-stats")) | 65 | else if (!strcmp(name, "max-stats")) |
64 | repo->max_stats = cgit_find_stats_period(value, NULL); | 66 | repo->max_stats = cgit_find_stats_period(value, NULL); |
65 | else if (!strcmp(name, "module-link")) | 67 | else if (!strcmp(name, "module-link")) |
@@ -137,6 +139,8 @@ void config_cb(const char *name, const char *value) | |||
137 | ctx.cfg.enable_log_filecount = atoi(value); | 139 | ctx.cfg.enable_log_filecount = atoi(value); |
138 | else if (!strcmp(name, "enable-log-linecount")) | 140 | else if (!strcmp(name, "enable-log-linecount")) |
139 | ctx.cfg.enable_log_linecount = atoi(value); | 141 | ctx.cfg.enable_log_linecount = atoi(value); |
142 | else if (!strcmp(name, "enable-remote-branches")) | ||
143 | ctx.cfg.enable_remote_branches = atoi(value); | ||
140 | else if (!strcmp(name, "enable-tree-linenumbers")) | 144 | else if (!strcmp(name, "enable-tree-linenumbers")) |
141 | ctx.cfg.enable_tree_linenumbers = atoi(value); | 145 | ctx.cfg.enable_tree_linenumbers = atoi(value); |
142 | else if (!strcmp(name, "max-stats")) | 146 | else if (!strcmp(name, "max-stats")) |
@@ -165,6 +169,8 @@ void config_cb(const char *name, const char *value) | |||
165 | ctx.cfg.max_msg_len = atoi(value); | 169 | ctx.cfg.max_msg_len = atoi(value); |
166 | else if (!strcmp(name, "max-repodesc-length")) | 170 | else if (!strcmp(name, "max-repodesc-length")) |
167 | ctx.cfg.max_repodesc_len = atoi(value); | 171 | ctx.cfg.max_repodesc_len = atoi(value); |
172 | else if (!strcmp(name, "max-blob-size")) | ||
173 | ctx.cfg.max_blob_size = atoi(value); | ||
168 | else if (!strcmp(name, "max-repo-count")) | 174 | else if (!strcmp(name, "max-repo-count")) |
169 | ctx.cfg.max_repo_count = atoi(value); | 175 | ctx.cfg.max_repo_count = atoi(value); |
170 | else if (!strcmp(name, "max-commit-count")) | 176 | else if (!strcmp(name, "max-commit-count")) |
@@ -182,6 +188,8 @@ void config_cb(const char *name, const char *value) | |||
182 | ctx.cfg.summary_branches = atoi(value); | 188 | ctx.cfg.summary_branches = atoi(value); |
183 | else if (!strcmp(name, "summary-tags")) | 189 | else if (!strcmp(name, "summary-tags")) |
184 | ctx.cfg.summary_tags = atoi(value); | 190 | ctx.cfg.summary_tags = atoi(value); |
191 | else if (!strcmp(name, "side-by-side-diffs")) | ||
192 | ctx.cfg.ssdiff = atoi(value); | ||
185 | else if (!strcmp(name, "agefile")) | 193 | else if (!strcmp(name, "agefile")) |
186 | ctx.cfg.agefile = xstrdup(value); | 194 | ctx.cfg.agefile = xstrdup(value); |
187 | else if (!strcmp(name, "renamelimit")) | 195 | else if (!strcmp(name, "renamelimit")) |
@@ -209,6 +217,8 @@ static void querystring_cb(const char *name, const char *value) | |||
209 | } else if (!strcmp(name, "p")) { | 217 | } else if (!strcmp(name, "p")) { |
210 | ctx.qry.page = xstrdup(value); | 218 | ctx.qry.page = xstrdup(value); |
211 | } else if (!strcmp(name, "url")) { | 219 | } else if (!strcmp(name, "url")) { |
220 | if (*value == '/') | ||
221 | value++; | ||
212 | ctx.qry.url = xstrdup(value); | 222 | ctx.qry.url = xstrdup(value); |
213 | cgit_parse_url(value); | 223 | cgit_parse_url(value); |
214 | } else if (!strcmp(name, "qt")) { | 224 | } else if (!strcmp(name, "qt")) { |
@@ -238,6 +248,8 @@ static void querystring_cb(const char *name, const char *value) | |||
238 | ctx.qry.showmsg = atoi(value); | 248 | ctx.qry.showmsg = atoi(value); |
239 | } else if (!strcmp(name, "period")) { | 249 | } else if (!strcmp(name, "period")) { |
240 | ctx.qry.period = xstrdup(value); | 250 | ctx.qry.period = xstrdup(value); |
251 | } else if (!strcmp(name, "ss")) { | ||
252 | ctx.qry.ssdiff = atoi(value); | ||
241 | } | 253 | } |
242 | } | 254 | } |
243 | 255 | ||
@@ -268,6 +280,7 @@ static void prepare_context(struct cgit_context *ctx) | |||
268 | ctx->cfg.max_lock_attempts = 5; | 280 | ctx->cfg.max_lock_attempts = 5; |
269 | ctx->cfg.max_msg_len = 80; | 281 | ctx->cfg.max_msg_len = 80; |
270 | ctx->cfg.max_repodesc_len = 80; | 282 | ctx->cfg.max_repodesc_len = 80; |
283 | ctx->cfg.max_blob_size = 0; | ||
271 | ctx->cfg.max_stats = 0; | 284 | ctx->cfg.max_stats = 0; |
272 | ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; | 285 | ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; |
273 | ctx->cfg.renamelimit = -1; | 286 | ctx->cfg.renamelimit = -1; |
@@ -279,6 +292,7 @@ static void prepare_context(struct cgit_context *ctx) | |||
279 | ctx->cfg.summary_branches = 10; | 292 | ctx->cfg.summary_branches = 10; |
280 | ctx->cfg.summary_log = 10; | 293 | ctx->cfg.summary_log = 10; |
281 | ctx->cfg.summary_tags = 10; | 294 | ctx->cfg.summary_tags = 10; |
295 | ctx->cfg.ssdiff = 0; | ||
282 | ctx->env.cgit_config = xstrdupn(getenv("CGIT_CONFIG")); | 296 | ctx->env.cgit_config = xstrdupn(getenv("CGIT_CONFIG")); |
283 | ctx->env.http_host = xstrdupn(getenv("HTTP_HOST")); | 297 | ctx->env.http_host = xstrdupn(getenv("HTTP_HOST")); |
284 | ctx->env.https = xstrdupn(getenv("HTTPS")); | 298 | ctx->env.https = xstrdupn(getenv("HTTPS")); |
@@ -162,6 +162,11 @@ table.list td a { | |||
162 | color: black; | 162 | color: black; |
163 | } | 163 | } |
164 | 164 | ||
165 | table.list td a.ls-dir { | ||
166 | font-weight: bold; | ||
167 | color: #00f; | ||
168 | } | ||
169 | |||
165 | table.list td a:hover { | 170 | table.list td a:hover { |
166 | color: #00f; | 171 | color: #00f; |
167 | } | 172 | } |
@@ -601,3 +606,102 @@ table.hgraph div.bar { | |||
601 | background-color: #eee; | 606 | background-color: #eee; |
602 | height: 1em; | 607 | height: 1em; |
603 | } | 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 | ||
@@ -72,6 +72,7 @@ struct cgit_repo { | |||
72 | int snapshots; | 72 | int snapshots; |
73 | int enable_log_filecount; | 73 | int enable_log_filecount; |
74 | int enable_log_linecount; | 74 | int enable_log_linecount; |
75 | int enable_remote_branches; | ||
75 | int max_stats; | 76 | int max_stats; |
76 | time_t mtime; | 77 | time_t mtime; |
77 | struct cgit_filter *about_filter; | 78 | struct cgit_filter *about_filter; |
@@ -143,6 +144,7 @@ struct cgit_query { | |||
143 | int nohead; | 144 | int nohead; |
144 | char *sort; | 145 | char *sort; |
145 | int showmsg; | 146 | int showmsg; |
147 | int ssdiff; | ||
146 | }; | 148 | }; |
147 | 149 | ||
148 | struct cgit_config { | 150 | struct cgit_config { |
@@ -178,6 +180,7 @@ struct cgit_config { | |||
178 | int enable_index_links; | 180 | int enable_index_links; |
179 | int enable_log_filecount; | 181 | int enable_log_filecount; |
180 | int enable_log_linecount; | 182 | int enable_log_linecount; |
183 | int enable_remote_branches; | ||
181 | int enable_tree_linenumbers; | 184 | int enable_tree_linenumbers; |
182 | int local_time; | 185 | int local_time; |
183 | int max_repo_count; | 186 | int max_repo_count; |
@@ -185,6 +188,7 @@ struct cgit_config { | |||
185 | int max_lock_attempts; | 188 | int max_lock_attempts; |
186 | int max_msg_len; | 189 | int max_msg_len; |
187 | int max_repodesc_len; | 190 | int max_repodesc_len; |
191 | int max_blob_size; | ||
188 | int max_stats; | 192 | int max_stats; |
189 | int nocache; | 193 | int nocache; |
190 | int noplainemail; | 194 | int noplainemail; |
@@ -194,6 +198,7 @@ struct cgit_config { | |||
194 | int summary_branches; | 198 | int summary_branches; |
195 | int summary_log; | 199 | int summary_log; |
196 | int summary_tags; | 200 | int summary_tags; |
201 | int ssdiff; | ||
197 | struct string_list mimetypes; | 202 | struct string_list mimetypes; |
198 | struct cgit_filter *about_filter; | 203 | struct cgit_filter *about_filter; |
199 | struct cgit_filter *commit_filter; | 204 | struct cgit_filter *commit_filter; |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 0c13485..d74d9e7 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -110,6 +110,11 @@ enable-log-linecount:: | |||
110 | and removed lines for each commit on the repository log page. Default | 110 | and removed lines for each commit on the repository log page. Default |
111 | value: "0". | 111 | value: "0". |
112 | 112 | ||
113 | enable-remote-branches:: | ||
114 | Flag which, when set to "1", will make cgit display remote branches | ||
115 | in the summary and refs views. Default value: "0". See also: | ||
116 | "repo.enable-remote-branches". | ||
117 | |||
113 | enable-tree-linenumbers:: | 118 | enable-tree-linenumbers:: |
114 | Flag which, when set to "1", will make cgit generate linenumber links | 119 | Flag which, when set to "1", will make cgit generate linenumber links |
115 | for plaintext blobs printed in the tree view. Default value: "1". | 120 | for plaintext blobs printed in the tree view. Default value: "1". |
@@ -177,6 +182,10 @@ max-repodesc-length:: | |||
177 | Specifies the maximum number of repo description characters to display | 182 | Specifies the maximum number of repo description characters to display |
178 | on the repository index page. Default value: "80". | 183 | on the repository index page. Default value: "80". |
179 | 184 | ||
185 | max-blob-size:: | ||
186 | Specifies the maximum size of a blob to display HTML for in KBytes. | ||
187 | Default value: "0" (limit disabled). | ||
188 | |||
180 | max-stats:: | 189 | max-stats:: |
181 | Set the default maximum statistics period. Valid values are "week", | 190 | Set the default maximum statistics period. Valid values are "week", |
182 | "month", "quarter" and "year". If unspecified, statistics are | 191 | "month", "quarter" and "year". If unspecified, statistics are |
@@ -241,6 +250,10 @@ section:: | |||
241 | after this option will inherit the current section name. Default value: | 250 | after this option will inherit the current section name. Default value: |
242 | none. | 251 | none. |
243 | 252 | ||
253 | side-by-side-diffs:: | ||
254 | If set to "1" shows side-by-side diffs instead of unidiffs per | ||
255 | default. Default value: "0". | ||
256 | |||
244 | snapshots:: | 257 | snapshots:: |
245 | Text which specifies the default set of snapshot formats generated by | 258 | Text which specifies the default set of snapshot formats generated by |
246 | cgit. The value is a space-separated list of zero or more of the | 259 | cgit. The value is a space-separated list of zero or more of the |
@@ -304,6 +317,10 @@ repo.enable-log-linecount:: | |||
304 | A flag which can be used to disable the global setting | 317 | A flag which can be used to disable the global setting |
305 | `enable-log-linecount'. Default value: none. | 318 | `enable-log-linecount'. Default value: none. |
306 | 319 | ||
320 | repo.enable-remote-branches:: | ||
321 | Flag which, when set to "1", will make cgit display remote branches | ||
322 | in the summary and refs views. Default value: <enable-remote-branches>. | ||
323 | |||
307 | repo.max-stats:: | 324 | repo.max-stats:: |
308 | Override the default maximum statistics period. Valid values are equal | 325 | Override the default maximum statistics period. Valid values are equal |
309 | to the values specified for the global "max-stats" setting. Default | 326 | to the values specified for the global "max-stats" setting. Default |
diff --git a/filters/syntax-highlighting.sh b/filters/syntax-highlighting.sh index 999ad0c..6b1c576 100755 --- a/filters/syntax-highlighting.sh +++ b/filters/syntax-highlighting.sh | |||
@@ -3,6 +3,10 @@ | |||
3 | # tree-view by refering to this file with the source-filter or repo.source- | 3 | # tree-view by refering to this file with the source-filter or repo.source- |
4 | # filter options in cgitrc. | 4 | # filter options in cgitrc. |
5 | # | 5 | # |
6 | # This script requires a shell supporting the ${var##pattern} syntax. | ||
7 | # It is supported by at least dash and bash, however busybox environments | ||
8 | # might have to use an external call to sed instead. | ||
9 | # | ||
6 | # Note: the highlight command (http://www.andre-simon.de/) uses css for syntax | 10 | # Note: the highlight command (http://www.andre-simon.de/) uses css for syntax |
7 | # highlighting, so you'll probably want something like the following included | 11 | # highlighting, so you'll probably want something like the following included |
8 | # in your css file (generated by highlight 2.4.8 and adapted for cgit): | 12 | # in your css file (generated by highlight 2.4.8 and adapted for cgit): |
@@ -20,20 +24,11 @@ | |||
20 | # table.blob .kwc { color:#000000; font-weight:bold; } | 24 | # table.blob .kwc { color:#000000; font-weight:bold; } |
21 | # table.blob .kwd { color:#010181; } | 25 | # table.blob .kwd { color:#010181; } |
22 | 26 | ||
23 | case "$1" in | 27 | # store filename and extension in local vars |
24 | *.c) | 28 | BASENAME="$1" |
25 | highlight -f -I -X -S c | 29 | EXTENSION="${BASENAME##*.}" |
26 | ;; | 30 | |
27 | *.h) | 31 | # map Makefile and Makefile.* to .mk |
28 | highlight -f -I -X -S c | 32 | [ "${BASENAME%%.*}" == "Makefile" ] && EXTENSION=mk |
29 | ;; | 33 | |
30 | *.sh) | 34 | exec highlight --force -f -I -X -S $EXTENSION 2>/dev/null |
31 | highlight -f -I -X -S sh | ||
32 | ;; | ||
33 | *.css) | ||
34 | highlight -f -I -X -S css | ||
35 | ;; | ||
36 | *) | ||
37 | highlight -f -I -X -S txt | ||
38 | ;; | ||
39 | esac | ||
@@ -59,6 +59,7 @@ struct cgit_repo *cgit_add_repo(const char *url) | |||
59 | ret->snapshots = ctx.cfg.snapshots; | 59 | ret->snapshots = ctx.cfg.snapshots; |
60 | ret->enable_log_filecount = ctx.cfg.enable_log_filecount; | 60 | ret->enable_log_filecount = ctx.cfg.enable_log_filecount; |
61 | ret->enable_log_linecount = ctx.cfg.enable_log_linecount; | 61 | ret->enable_log_linecount = ctx.cfg.enable_log_linecount; |
62 | ret->enable_remote_branches = ctx.cfg.enable_remote_branches; | ||
62 | ret->max_stats = ctx.cfg.max_stats; | 63 | ret->max_stats = ctx.cfg.max_stats; |
63 | ret->module_link = ctx.cfg.module_link; | 64 | ret->module_link = ctx.cfg.module_link; |
64 | ret->readme = NULL; | 65 | ret->readme = NULL; |
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"); | 292 | if (use_ssdiff) |
293 | html("<tr><td colspan='4'>Binary files differ</td></tr>"); | ||
294 | else | ||
295 | html("Binary files differ"); | ||
296 | } | ||
297 | if (use_ssdiff) | ||
298 | cgit_ssdiff_footer(); | ||
269 | } | 299 | } |
270 | 300 | ||
271 | void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefix) | 301 | void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefix) |
@@ -303,11 +333,21 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefi | |||
303 | if (!commit2 || parse_commit(commit2)) | 333 | if (!commit2 || parse_commit(commit2)) |
304 | cgit_print_error(fmt("Bad commit: %s", sha1_to_hex(old_rev_sha1))); | 334 | cgit_print_error(fmt("Bad commit: %s", sha1_to_hex(old_rev_sha1))); |
305 | } | 335 | } |
336 | |||
337 | if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff)) | ||
338 | use_ssdiff = 1; | ||
339 | |||
340 | print_ssdiff_link(); | ||
306 | cgit_print_diffstat(old_rev_sha1, new_rev_sha1); | 341 | cgit_print_diffstat(old_rev_sha1, new_rev_sha1); |
307 | 342 | ||
308 | html("<table summary='diff' class='diff'>"); | 343 | if (use_ssdiff) { |
309 | html("<tr><td>"); | 344 | html("<table summary='ssdiff' class='ssdiff'>"); |
345 | } else { | ||
346 | html("<table summary='diff' class='diff'>"); | ||
347 | html("<tr><td>"); | ||
348 | } | ||
310 | cgit_diff_tree(old_rev_sha1, new_rev_sha1, filepair_cb, prefix); | 349 | cgit_diff_tree(old_rev_sha1, new_rev_sha1, filepair_cb, prefix); |
311 | html("</td></tr>"); | 350 | if (!use_ssdiff) |
351 | html("</td></tr>"); | ||
312 | html("</table>"); | 352 | html("</table>"); |
313 | } | 353 | } |
@@ -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'>"); |
@@ -187,6 +187,8 @@ void cgit_print_branches(int maxcount) | |||
187 | list.refs = NULL; | 187 | list.refs = NULL; |
188 | list.alloc = list.count = 0; | 188 | list.alloc = list.count = 0; |
189 | for_each_branch_ref(cgit_refs_cb, &list); | 189 | for_each_branch_ref(cgit_refs_cb, &list); |
190 | if (ctx.repo->enable_remote_branches) | ||
191 | for_each_remote_ref(cgit_refs_cb, &list); | ||
190 | 192 | ||
191 | if (maxcount == 0 || maxcount > list.count) | 193 | if (maxcount == 0 || maxcount > list.count) |
192 | maxcount = list.count; | 194 | maxcount = list.count; |
diff --git a/ui-shared.c b/ui-shared.c index 4049a2b..08ea003 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 |