diff options
-rw-r--r-- | Makefile | 30 | ||||
-rw-r--r-- | cache.h | 1 | ||||
-rw-r--r-- | cgit.c | 86 | ||||
-rw-r--r-- | cgit.css | 148 | ||||
-rw-r--r-- | cgit.h | 26 | ||||
-rw-r--r-- | cgitrc.5.txt | 68 | ||||
-rw-r--r-- | cmd.c | 48 | ||||
-rw-r--r-- | cmd.h | 3 | ||||
-rwxr-xr-x | filters/commit-links.sh | 16 | ||||
-rwxr-xr-x | filters/syntax-highlighting.sh | 29 | ||||
-rw-r--r-- | html.c | 84 | ||||
-rw-r--r-- | html.h | 21 | ||||
-rw-r--r-- | scan-tree.c | 123 | ||||
-rw-r--r-- | scan-tree.h | 3 | ||||
-rw-r--r-- | shared.c | 90 | ||||
-rw-r--r-- | ui-atom.c | 4 | ||||
-rw-r--r-- | ui-blob.c | 37 | ||||
-rw-r--r-- | ui-blob.h | 1 | ||||
-rw-r--r-- | ui-commit.c | 46 | ||||
-rw-r--r-- | ui-commit.h | 2 | ||||
-rw-r--r-- | ui-diff.c | 94 | ||||
-rw-r--r-- | ui-log.c | 56 | ||||
-rw-r--r-- | ui-patch.c | 8 | ||||
-rw-r--r-- | ui-patch.h | 2 | ||||
-rw-r--r-- | ui-plain.c | 68 | ||||
-rw-r--r-- | ui-refs.c | 4 | ||||
-rw-r--r-- | ui-repolist.c | 6 | ||||
-rw-r--r-- | ui-shared.c | 270 | ||||
-rw-r--r-- | ui-shared.h | 71 | ||||
-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-stats.c | 18 | ||||
-rw-r--r-- | ui-summary.c | 42 | ||||
-rw-r--r-- | ui-tag.c | 24 | ||||
-rw-r--r-- | ui-tree.c | 27 |
36 files changed, 1614 insertions, 338 deletions
@@ -11,8 +11,16 @@ 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 | # |
19 | # Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.) | ||
20 | # do not support the 'size specifiers' introduced by C99, namely ll, hh, | ||
21 | # j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t). | ||
22 | # some C compilers supported these specifiers prior to C99 as an extension. | ||
23 | # | ||
16 | 24 | ||
17 | #-include config.mak | 25 | #-include config.mak |
18 | 26 | ||
@@ -59,7 +67,7 @@ endif | |||
59 | # Define a pattern rule for automatic dependency building | 67 | # Define a pattern rule for automatic dependency building |
60 | # | 68 | # |
61 | %.d: %.c | 69 | %.d: %.c |
62 | $(QUIET_MM)$(CC) $(CFLAGS) -MM $< | sed -e 's/\($*\)\.o:/\1.o $@:/g' >$@ | 70 | $(QUIET_MM)$(CC) $(CFLAGS) -MM -MP $< | sed -e 's/\($*\)\.o:/\1.o $@:/g' >$@ |
63 | 71 | ||
64 | # | 72 | # |
65 | # Define a pattern rule for silent object building | 73 | # Define a pattern rule for silent object building |
@@ -68,7 +76,7 @@ endif | |||
68 | $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $< | 76 | $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $< |
69 | 77 | ||
70 | 78 | ||
71 | EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto -lpthread | 79 | EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lpthread |
72 | OBJECTS = | 80 | OBJECTS = |
73 | OBJECTS += cache.o | 81 | OBJECTS += cache.o |
74 | OBJECTS += cgit.o | 82 | OBJECTS += cgit.o |
@@ -90,6 +98,7 @@ OBJECTS += ui-refs.o | |||
90 | OBJECTS += ui-repolist.o | 98 | OBJECTS += ui-repolist.o |
91 | OBJECTS += ui-shared.o | 99 | OBJECTS += ui-shared.o |
92 | OBJECTS += ui-snapshot.o | 100 | OBJECTS += ui-snapshot.o |
101 | OBJECTS += ui-ssdiff.o | ||
93 | OBJECTS += ui-stats.o | 102 | OBJECTS += ui-stats.o |
94 | OBJECTS += ui-summary.o | 103 | OBJECTS += ui-summary.o |
95 | OBJECTS += ui-tag.o | 104 | OBJECTS += ui-tag.o |
@@ -123,17 +132,28 @@ endif | |||
123 | ifdef NO_STRCASESTR | 132 | ifdef NO_STRCASESTR |
124 | CFLAGS += -DNO_STRCASESTR | 133 | CFLAGS += -DNO_STRCASESTR |
125 | endif | 134 | endif |
135 | ifdef NO_C99_FORMAT | ||
136 | CFLAGS += -DNO_C99_FORMAT | ||
137 | endif | ||
138 | ifdef NO_OPENSSL | ||
139 | CFLAGS += -DNO_OPENSSL | ||
140 | GIT_OPTIONS += NO_OPENSSL=1 | ||
141 | else | ||
142 | EXTLIBS += -lcrypto | ||
143 | endif | ||
126 | 144 | ||
127 | cgit: $(OBJECTS) libgit | 145 | cgit: $(OBJECTS) libgit |
128 | $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o cgit $(OBJECTS) $(EXTLIBS) | 146 | $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o cgit $(OBJECTS) $(EXTLIBS) |
129 | 147 | ||
130 | cgit.o: VERSION | 148 | cgit.o: VERSION |
131 | 149 | ||
132 | -include $(OBJECTS:.o=.d) | 150 | ifneq "$(MAKECMDGOALS)" "clean" |
151 | -include $(OBJECTS:.o=.d) | ||
152 | endif | ||
133 | 153 | ||
134 | libgit: | 154 | libgit: |
135 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 libgit.a | 155 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) libgit.a |
136 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 xdiff/lib.a | 156 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) xdiff/lib.a |
137 | 157 | ||
138 | test: all | 158 | test: all |
139 | $(QUIET_SUBDIR0)tests $(QUIET_SUBDIR1) all | 159 | $(QUIET_SUBDIR0)tests $(QUIET_SUBDIR1) all |
@@ -30,6 +30,7 @@ extern int cache_process(int size, const char *path, const char *key, int ttl, | |||
30 | extern int cache_ls(const char *path); | 30 | extern int cache_ls(const char *path); |
31 | 31 | ||
32 | /* Print a message to stdout */ | 32 | /* Print a message to stdout */ |
33 | __attribute__((format (printf,1,2))) | ||
33 | extern void cache_log(const char *format, ...); | 34 | extern void cache_log(const char *format, ...); |
34 | 35 | ||
35 | extern unsigned long hash_str(const char *str); | 36 | extern unsigned long hash_str(const char *str); |
@@ -1,6 +1,7 @@ | |||
1 | /* cgit.c: cgi for the git scm | 1 | /* cgit.c: cgi for the git scm |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * Copyright (C) 2010 Jason A. Donenfeld <Jason@zx2c4.com> | ||
4 | * | 5 | * |
5 | * Licensed under GNU General Public License v2 | 6 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 7 | * (see COPYING for full license text) |
@@ -60,6 +61,10 @@ 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); | 61 | repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); |
61 | else if (!strcmp(name, "enable-log-linecount")) | 62 | else if (!strcmp(name, "enable-log-linecount")) |
62 | repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); | 63 | repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); |
64 | else if (!strcmp(name, "enable-remote-branches")) | ||
65 | repo->enable_remote_branches = atoi(value); | ||
66 | else if (!strcmp(name, "enable-subject-links")) | ||
67 | repo->enable_subject_links = atoi(value); | ||
63 | else if (!strcmp(name, "max-stats")) | 68 | else if (!strcmp(name, "max-stats")) |
64 | repo->max_stats = cgit_find_stats_period(value, NULL); | 69 | repo->max_stats = cgit_find_stats_period(value, NULL); |
65 | else if (!strcmp(name, "module-link")) | 70 | else if (!strcmp(name, "module-link")) |
@@ -67,10 +72,7 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value) | |||
67 | else if (!strcmp(name, "section")) | 72 | else if (!strcmp(name, "section")) |
68 | repo->section = xstrdup(value); | 73 | repo->section = xstrdup(value); |
69 | else if (!strcmp(name, "readme") && value != NULL) { | 74 | else if (!strcmp(name, "readme") && value != NULL) { |
70 | if (*value == '/') | 75 | repo->readme = xstrdup(value); |
71 | repo->readme = xstrdup(value); | ||
72 | else | ||
73 | repo->readme = xstrdup(fmt("%s/%s", repo->path, value)); | ||
74 | } else if (ctx.cfg.enable_filter_overrides) { | 76 | } else if (ctx.cfg.enable_filter_overrides) { |
75 | if (!strcmp(name, "about-filter")) | 77 | if (!strcmp(name, "about-filter")) |
76 | repo->about_filter = new_filter(value, 0); | 78 | repo->about_filter = new_filter(value, 0); |
@@ -91,6 +93,8 @@ void config_cb(const char *name, const char *value) | |||
91 | ctx.repo->path = trim_end(value, '/'); | 93 | ctx.repo->path = trim_end(value, '/'); |
92 | else if (ctx.repo && !prefixcmp(name, "repo.")) | 94 | else if (ctx.repo && !prefixcmp(name, "repo.")) |
93 | repo_config(ctx.repo, name + 5, value); | 95 | repo_config(ctx.repo, name + 5, value); |
96 | else if (!strcmp(name, "readme")) | ||
97 | ctx.cfg.readme = xstrdup(value); | ||
94 | else if (!strcmp(name, "root-title")) | 98 | else if (!strcmp(name, "root-title")) |
95 | ctx.cfg.root_title = xstrdup(value); | 99 | ctx.cfg.root_title = xstrdup(value); |
96 | else if (!strcmp(name, "root-desc")) | 100 | else if (!strcmp(name, "root-desc")) |
@@ -131,12 +135,18 @@ void config_cb(const char *name, const char *value) | |||
131 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); | 135 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); |
132 | else if (!strcmp(name, "enable-filter-overrides")) | 136 | else if (!strcmp(name, "enable-filter-overrides")) |
133 | ctx.cfg.enable_filter_overrides = atoi(value); | 137 | ctx.cfg.enable_filter_overrides = atoi(value); |
138 | else if (!strcmp(name, "enable-gitweb-owner")) | ||
139 | ctx.cfg.enable_gitweb_owner = atoi(value); | ||
134 | else if (!strcmp(name, "enable-index-links")) | 140 | else if (!strcmp(name, "enable-index-links")) |
135 | ctx.cfg.enable_index_links = atoi(value); | 141 | ctx.cfg.enable_index_links = atoi(value); |
136 | else if (!strcmp(name, "enable-log-filecount")) | 142 | else if (!strcmp(name, "enable-log-filecount")) |
137 | ctx.cfg.enable_log_filecount = atoi(value); | 143 | ctx.cfg.enable_log_filecount = atoi(value); |
138 | else if (!strcmp(name, "enable-log-linecount")) | 144 | else if (!strcmp(name, "enable-log-linecount")) |
139 | ctx.cfg.enable_log_linecount = atoi(value); | 145 | ctx.cfg.enable_log_linecount = atoi(value); |
146 | else if (!strcmp(name, "enable-remote-branches")) | ||
147 | ctx.cfg.enable_remote_branches = atoi(value); | ||
148 | else if (!strcmp(name, "enable-subject-links")) | ||
149 | ctx.cfg.enable_subject_links = atoi(value); | ||
140 | else if (!strcmp(name, "enable-tree-linenumbers")) | 150 | else if (!strcmp(name, "enable-tree-linenumbers")) |
141 | ctx.cfg.enable_tree_linenumbers = atoi(value); | 151 | ctx.cfg.enable_tree_linenumbers = atoi(value); |
142 | else if (!strcmp(name, "max-stats")) | 152 | else if (!strcmp(name, "max-stats")) |
@@ -144,7 +154,7 @@ void config_cb(const char *name, const char *value) | |||
144 | else if (!strcmp(name, "cache-size")) | 154 | else if (!strcmp(name, "cache-size")) |
145 | ctx.cfg.cache_size = atoi(value); | 155 | ctx.cfg.cache_size = atoi(value); |
146 | else if (!strcmp(name, "cache-root")) | 156 | else if (!strcmp(name, "cache-root")) |
147 | ctx.cfg.cache_root = xstrdup(value); | 157 | ctx.cfg.cache_root = xstrdup(expand_macros(value)); |
148 | else if (!strcmp(name, "cache-root-ttl")) | 158 | else if (!strcmp(name, "cache-root-ttl")) |
149 | ctx.cfg.cache_root_ttl = atoi(value); | 159 | ctx.cfg.cache_root_ttl = atoi(value); |
150 | else if (!strcmp(name, "cache-repo-ttl")) | 160 | else if (!strcmp(name, "cache-repo-ttl")) |
@@ -161,19 +171,30 @@ void config_cb(const char *name, const char *value) | |||
161 | ctx.cfg.commit_filter = new_filter(value, 0); | 171 | ctx.cfg.commit_filter = new_filter(value, 0); |
162 | else if (!strcmp(name, "embedded")) | 172 | else if (!strcmp(name, "embedded")) |
163 | ctx.cfg.embedded = atoi(value); | 173 | ctx.cfg.embedded = atoi(value); |
174 | else if (!strcmp(name, "max-atom-items")) | ||
175 | ctx.cfg.max_atom_items = atoi(value); | ||
164 | else if (!strcmp(name, "max-message-length")) | 176 | else if (!strcmp(name, "max-message-length")) |
165 | ctx.cfg.max_msg_len = atoi(value); | 177 | ctx.cfg.max_msg_len = atoi(value); |
166 | else if (!strcmp(name, "max-repodesc-length")) | 178 | else if (!strcmp(name, "max-repodesc-length")) |
167 | ctx.cfg.max_repodesc_len = atoi(value); | 179 | ctx.cfg.max_repodesc_len = atoi(value); |
180 | else if (!strcmp(name, "max-blob-size")) | ||
181 | ctx.cfg.max_blob_size = atoi(value); | ||
168 | else if (!strcmp(name, "max-repo-count")) | 182 | else if (!strcmp(name, "max-repo-count")) |
169 | ctx.cfg.max_repo_count = atoi(value); | 183 | ctx.cfg.max_repo_count = atoi(value); |
170 | else if (!strcmp(name, "max-commit-count")) | 184 | else if (!strcmp(name, "max-commit-count")) |
171 | ctx.cfg.max_commit_count = atoi(value); | 185 | ctx.cfg.max_commit_count = atoi(value); |
186 | else if (!strcmp(name, "project-list")) | ||
187 | ctx.cfg.project_list = xstrdup(expand_macros(value)); | ||
172 | else if (!strcmp(name, "scan-path")) | 188 | else if (!strcmp(name, "scan-path")) |
173 | if (!ctx.cfg.nocache && ctx.cfg.cache_size) | 189 | if (!ctx.cfg.nocache && ctx.cfg.cache_size) |
174 | process_cached_repolist(value); | 190 | process_cached_repolist(expand_macros(value)); |
191 | else if (ctx.cfg.project_list) | ||
192 | scan_projects(expand_macros(value), | ||
193 | ctx.cfg.project_list, repo_config); | ||
175 | else | 194 | else |
176 | scan_tree(value, repo_config); | 195 | scan_tree(expand_macros(value), repo_config); |
196 | else if (!strcmp(name, "section-from-path")) | ||
197 | ctx.cfg.section_from_path = atoi(value); | ||
177 | else if (!strcmp(name, "source-filter")) | 198 | else if (!strcmp(name, "source-filter")) |
178 | ctx.cfg.source_filter = new_filter(value, 1); | 199 | ctx.cfg.source_filter = new_filter(value, 1); |
179 | else if (!strcmp(name, "summary-log")) | 200 | else if (!strcmp(name, "summary-log")) |
@@ -182,10 +203,14 @@ void config_cb(const char *name, const char *value) | |||
182 | ctx.cfg.summary_branches = atoi(value); | 203 | ctx.cfg.summary_branches = atoi(value); |
183 | else if (!strcmp(name, "summary-tags")) | 204 | else if (!strcmp(name, "summary-tags")) |
184 | ctx.cfg.summary_tags = atoi(value); | 205 | ctx.cfg.summary_tags = atoi(value); |
206 | else if (!strcmp(name, "side-by-side-diffs")) | ||
207 | ctx.cfg.ssdiff = atoi(value); | ||
185 | else if (!strcmp(name, "agefile")) | 208 | else if (!strcmp(name, "agefile")) |
186 | ctx.cfg.agefile = xstrdup(value); | 209 | ctx.cfg.agefile = xstrdup(value); |
187 | else if (!strcmp(name, "renamelimit")) | 210 | else if (!strcmp(name, "renamelimit")) |
188 | ctx.cfg.renamelimit = atoi(value); | 211 | ctx.cfg.renamelimit = atoi(value); |
212 | else if (!strcmp(name, "remove-suffix")) | ||
213 | ctx.cfg.remove_suffix = atoi(value); | ||
189 | else if (!strcmp(name, "robots")) | 214 | else if (!strcmp(name, "robots")) |
190 | ctx.cfg.robots = xstrdup(value); | 215 | ctx.cfg.robots = xstrdup(value); |
191 | else if (!strcmp(name, "clone-prefix")) | 216 | else if (!strcmp(name, "clone-prefix")) |
@@ -195,7 +220,7 @@ void config_cb(const char *name, const char *value) | |||
195 | else if (!prefixcmp(name, "mimetype.")) | 220 | else if (!prefixcmp(name, "mimetype.")) |
196 | add_mimetype(name + 9, value); | 221 | add_mimetype(name + 9, value); |
197 | else if (!strcmp(name, "include")) | 222 | else if (!strcmp(name, "include")) |
198 | parse_configfile(value, config_cb); | 223 | parse_configfile(expand_macros(value), config_cb); |
199 | } | 224 | } |
200 | 225 | ||
201 | static void querystring_cb(const char *name, const char *value) | 226 | static void querystring_cb(const char *name, const char *value) |
@@ -209,6 +234,8 @@ static void querystring_cb(const char *name, const char *value) | |||
209 | } else if (!strcmp(name, "p")) { | 234 | } else if (!strcmp(name, "p")) { |
210 | ctx.qry.page = xstrdup(value); | 235 | ctx.qry.page = xstrdup(value); |
211 | } else if (!strcmp(name, "url")) { | 236 | } else if (!strcmp(name, "url")) { |
237 | if (*value == '/') | ||
238 | value++; | ||
212 | ctx.qry.url = xstrdup(value); | 239 | ctx.qry.url = xstrdup(value); |
213 | cgit_parse_url(value); | 240 | cgit_parse_url(value); |
214 | } else if (!strcmp(name, "qt")) { | 241 | } else if (!strcmp(name, "qt")) { |
@@ -238,6 +265,14 @@ static void querystring_cb(const char *name, const char *value) | |||
238 | ctx.qry.showmsg = atoi(value); | 265 | ctx.qry.showmsg = atoi(value); |
239 | } else if (!strcmp(name, "period")) { | 266 | } else if (!strcmp(name, "period")) { |
240 | ctx.qry.period = xstrdup(value); | 267 | ctx.qry.period = xstrdup(value); |
268 | } else if (!strcmp(name, "ss")) { | ||
269 | ctx.qry.ssdiff = atoi(value); | ||
270 | } else if (!strcmp(name, "all")) { | ||
271 | ctx.qry.show_all = atoi(value); | ||
272 | } else if (!strcmp(name, "context")) { | ||
273 | ctx.qry.context = atoi(value); | ||
274 | } else if (!strcmp(name, "ignorews")) { | ||
275 | ctx.qry.ignorews = atoi(value); | ||
241 | } | 276 | } |
242 | } | 277 | } |
243 | 278 | ||
@@ -262,15 +297,19 @@ static void prepare_context(struct cgit_context *ctx) | |||
262 | ctx->cfg.css = "/cgit.css"; | 297 | ctx->cfg.css = "/cgit.css"; |
263 | ctx->cfg.logo = "/cgit.png"; | 298 | ctx->cfg.logo = "/cgit.png"; |
264 | ctx->cfg.local_time = 0; | 299 | ctx->cfg.local_time = 0; |
300 | ctx->cfg.enable_gitweb_owner = 1; | ||
265 | ctx->cfg.enable_tree_linenumbers = 1; | 301 | ctx->cfg.enable_tree_linenumbers = 1; |
266 | ctx->cfg.max_repo_count = 50; | 302 | ctx->cfg.max_repo_count = 50; |
267 | ctx->cfg.max_commit_count = 50; | 303 | ctx->cfg.max_commit_count = 50; |
268 | ctx->cfg.max_lock_attempts = 5; | 304 | ctx->cfg.max_lock_attempts = 5; |
269 | ctx->cfg.max_msg_len = 80; | 305 | ctx->cfg.max_msg_len = 80; |
270 | ctx->cfg.max_repodesc_len = 80; | 306 | ctx->cfg.max_repodesc_len = 80; |
307 | ctx->cfg.max_blob_size = 0; | ||
271 | ctx->cfg.max_stats = 0; | 308 | ctx->cfg.max_stats = 0; |
272 | ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; | 309 | ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; |
310 | ctx->cfg.project_list = NULL; | ||
273 | ctx->cfg.renamelimit = -1; | 311 | ctx->cfg.renamelimit = -1; |
312 | ctx->cfg.remove_suffix = 0; | ||
274 | ctx->cfg.robots = "index, nofollow"; | 313 | ctx->cfg.robots = "index, nofollow"; |
275 | ctx->cfg.root_title = "Git repository browser"; | 314 | ctx->cfg.root_title = "Git repository browser"; |
276 | ctx->cfg.root_desc = "a fast webinterface for the git dscm"; | 315 | ctx->cfg.root_desc = "a fast webinterface for the git dscm"; |
@@ -279,6 +318,8 @@ static void prepare_context(struct cgit_context *ctx) | |||
279 | ctx->cfg.summary_branches = 10; | 318 | ctx->cfg.summary_branches = 10; |
280 | ctx->cfg.summary_log = 10; | 319 | ctx->cfg.summary_log = 10; |
281 | ctx->cfg.summary_tags = 10; | 320 | ctx->cfg.summary_tags = 10; |
321 | ctx->cfg.max_atom_items = 10; | ||
322 | ctx->cfg.ssdiff = 0; | ||
282 | ctx->env.cgit_config = xstrdupn(getenv("CGIT_CONFIG")); | 323 | ctx->env.cgit_config = xstrdupn(getenv("CGIT_CONFIG")); |
283 | ctx->env.http_host = xstrdupn(getenv("HTTP_HOST")); | 324 | ctx->env.http_host = xstrdupn(getenv("HTTP_HOST")); |
284 | ctx->env.https = xstrdupn(getenv("HTTPS")); | 325 | ctx->env.https = xstrdupn(getenv("HTTPS")); |
@@ -410,6 +451,12 @@ static void process_request(void *cbdata) | |||
410 | return; | 451 | return; |
411 | } | 452 | } |
412 | 453 | ||
454 | /* If cmd->want_vpath is set, assume ctx->qry.path contains a "virtual" | ||
455 | * in-project path limit to be made available at ctx->qry.vpath. | ||
456 | * Otherwise, no path limit is in effect (ctx->qry.vpath = NULL). | ||
457 | */ | ||
458 | ctx->qry.vpath = cmd->want_vpath ? ctx->qry.path : NULL; | ||
459 | |||
413 | if (cmd->want_repo && !ctx->repo) { | 460 | if (cmd->want_repo && !ctx->repo) { |
414 | cgit_print_http_headers(ctx); | 461 | cgit_print_http_headers(ctx); |
415 | cgit_print_docstart(ctx); | 462 | cgit_print_docstart(ctx); |
@@ -541,7 +588,10 @@ static int generate_cached_repolist(const char *path, const char *cached_rc) | |||
541 | return errno; | 588 | return errno; |
542 | } | 589 | } |
543 | idx = cgit_repolist.count; | 590 | idx = cgit_repolist.count; |
544 | scan_tree(path, repo_config); | 591 | if (ctx.cfg.project_list) |
592 | scan_projects(path, ctx.cfg.project_list, repo_config); | ||
593 | else | ||
594 | scan_tree(path, repo_config); | ||
545 | print_repolist(f, &cgit_repolist, idx); | 595 | print_repolist(f, &cgit_repolist, idx); |
546 | if (rename(locked_rc, cached_rc)) | 596 | if (rename(locked_rc, cached_rc)) |
547 | fprintf(stderr, "[cgit] Error renaming %s to %s: %s (%d)\n", | 597 | fprintf(stderr, "[cgit] Error renaming %s to %s: %s (%d)\n", |
@@ -555,17 +605,25 @@ static void process_cached_repolist(const char *path) | |||
555 | struct stat st; | 605 | struct stat st; |
556 | char *cached_rc; | 606 | char *cached_rc; |
557 | time_t age; | 607 | time_t age; |
608 | unsigned long hash; | ||
558 | 609 | ||
559 | cached_rc = xstrdup(fmt("%s/rc-%8x", ctx.cfg.cache_root, | 610 | hash = hash_str(path); |
560 | hash_str(path))); | 611 | if (ctx.cfg.project_list) |
612 | hash += hash_str(ctx.cfg.project_list); | ||
613 | cached_rc = xstrdup(fmt("%s/rc-%8lx", ctx.cfg.cache_root, hash)); | ||
561 | 614 | ||
562 | if (stat(cached_rc, &st)) { | 615 | if (stat(cached_rc, &st)) { |
563 | /* Nothing is cached, we need to scan without forking. And | 616 | /* Nothing is cached, we need to scan without forking. And |
564 | * if we fail to generate a cached repolist, we need to | 617 | * if we fail to generate a cached repolist, we need to |
565 | * invoke scan_tree manually. | 618 | * invoke scan_tree manually. |
566 | */ | 619 | */ |
567 | if (generate_cached_repolist(path, cached_rc)) | 620 | if (generate_cached_repolist(path, cached_rc)) { |
568 | scan_tree(path, repo_config); | 621 | if (ctx.cfg.project_list) |
622 | scan_projects(path, ctx.cfg.project_list, | ||
623 | repo_config); | ||
624 | else | ||
625 | scan_tree(path, repo_config); | ||
626 | } | ||
569 | return; | 627 | return; |
570 | } | 628 | } |
571 | 629 | ||
@@ -674,7 +732,7 @@ int main(int argc, const char **argv) | |||
674 | cgit_repolist.repos = NULL; | 732 | cgit_repolist.repos = NULL; |
675 | 733 | ||
676 | cgit_parse_args(argc, argv); | 734 | cgit_parse_args(argc, argv); |
677 | parse_configfile(ctx.env.cgit_config, config_cb); | 735 | parse_configfile(expand_macros(ctx.env.cgit_config), config_cb); |
678 | ctx.repo = NULL; | 736 | ctx.repo = NULL; |
679 | http_parse_querystring(ctx.qry.raw, querystring_cb); | 737 | http_parse_querystring(ctx.qry.raw, querystring_cb); |
680 | 738 | ||
@@ -64,7 +64,7 @@ table#header td.sub { | |||
64 | } | 64 | } |
65 | 65 | ||
66 | table.tabs { | 66 | table.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 | ||
105 | div.path { | ||
106 | margin: 0px; | ||
107 | padding: 5px 2em 2px 2em; | ||
108 | color: #000; | ||
109 | background-color: #eee; | ||
110 | } | ||
111 | |||
105 | div.content { | 112 | div.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 | ||
@@ -158,10 +164,26 @@ table.list td.logmsg { | |||
158 | padding: 1em 0.5em 2em 0.5em; | 164 | padding: 1em 0.5em 2em 0.5em; |
159 | } | 165 | } |
160 | 166 | ||
167 | table.list td.lognotes-label { | ||
168 | text-align:right; | ||
169 | vertical-align:top; | ||
170 | } | ||
171 | |||
172 | table.list td.lognotes { | ||
173 | font-family: monospace; | ||
174 | white-space: pre; | ||
175 | padding: 0em 0.5em 2em 0.5em; | ||
176 | } | ||
177 | |||
161 | table.list td a { | 178 | table.list td a { |
162 | color: black; | 179 | color: black; |
163 | } | 180 | } |
164 | 181 | ||
182 | table.list td a.ls-dir { | ||
183 | font-weight: bold; | ||
184 | color: #00f; | ||
185 | } | ||
186 | |||
165 | table.list td a:hover { | 187 | table.list td a:hover { |
166 | color: #00f; | 188 | color: #00f; |
167 | } | 189 | } |
@@ -315,6 +337,24 @@ div.commit-msg { | |||
315 | font-family: monospace; | 337 | font-family: monospace; |
316 | } | 338 | } |
317 | 339 | ||
340 | div.notes-header { | ||
341 | font-weight: bold; | ||
342 | padding-top: 1.5em; | ||
343 | } | ||
344 | |||
345 | div.notes { | ||
346 | white-space: pre; | ||
347 | font-family: monospace; | ||
348 | border: solid 1px #ee9; | ||
349 | background-color: #ffd; | ||
350 | padding: 0.3em 2em 0.3em 1em; | ||
351 | float: left; | ||
352 | } | ||
353 | |||
354 | div.notes-footer { | ||
355 | clear: left; | ||
356 | } | ||
357 | |||
318 | div.diffstat-header { | 358 | div.diffstat-header { |
319 | font-weight: bold; | 359 | font-weight: bold; |
320 | padding-top: 1.5em; | 360 | padding-top: 1.5em; |
@@ -520,7 +560,10 @@ a.deco { | |||
520 | border: solid 1px #770000; | 560 | border: solid 1px #770000; |
521 | } | 561 | } |
522 | 562 | ||
523 | div.commit-subject a { | 563 | div.commit-subject a.branch-deco, |
564 | div.commit-subject a.tag-deco, | ||
565 | div.commit-subject a.remote-deco, | ||
566 | div.commit-subject a.deco { | ||
524 | margin-left: 1em; | 567 | margin-left: 1em; |
525 | font-size: 75%; | 568 | font-size: 75%; |
526 | } | 569 | } |
@@ -601,3 +644,102 @@ table.hgraph div.bar { | |||
601 | background-color: #eee; | 644 | background-color: #eee; |
602 | height: 1em; | 645 | height: 1em; |
603 | } | 646 | } |
647 | |||
648 | table.ssdiff { | ||
649 | width: 100%; | ||
650 | } | ||
651 | |||
652 | table.ssdiff td { | ||
653 | font-size: 75%; | ||
654 | font-family: monospace; | ||
655 | white-space: pre; | ||
656 | padding: 1px 4px 1px 4px; | ||
657 | border-left: solid 1px #aaa; | ||
658 | border-right: solid 1px #aaa; | ||
659 | } | ||
660 | |||
661 | table.ssdiff td.add { | ||
662 | color: black; | ||
663 | background: #cfc; | ||
664 | min-width: 50%; | ||
665 | } | ||
666 | |||
667 | table.ssdiff td.add_dark { | ||
668 | color: black; | ||
669 | background: #aca; | ||
670 | min-width: 50%; | ||
671 | } | ||
672 | |||
673 | table.ssdiff span.add { | ||
674 | background: #cfc; | ||
675 | font-weight: bold; | ||
676 | } | ||
677 | |||
678 | table.ssdiff td.del { | ||
679 | color: black; | ||
680 | background: #fcc; | ||
681 | min-width: 50%; | ||
682 | } | ||
683 | |||
684 | table.ssdiff td.del_dark { | ||
685 | color: black; | ||
686 | background: #caa; | ||
687 | min-width: 50%; | ||
688 | } | ||
689 | |||
690 | table.ssdiff span.del { | ||
691 | background: #fcc; | ||
692 | font-weight: bold; | ||
693 | } | ||
694 | |||
695 | table.ssdiff td.changed { | ||
696 | color: black; | ||
697 | background: #ffc; | ||
698 | min-width: 50%; | ||
699 | } | ||
700 | |||
701 | table.ssdiff td.changed_dark { | ||
702 | color: black; | ||
703 | background: #cca; | ||
704 | min-width: 50%; | ||
705 | } | ||
706 | |||
707 | table.ssdiff td.lineno { | ||
708 | color: black; | ||
709 | background: #eee; | ||
710 | text-align: right; | ||
711 | width: 3em; | ||
712 | min-width: 3em; | ||