-rw-r--r-- | cgit.c | 5 | ||||
-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | cgitrc.5.txt | 8 | ||||
-rw-r--r-- | ui-tree.c | 2 |
4 files changed, 9 insertions, 8 deletions
@@ -21,118 +21,118 @@ void add_mimetype(const char *name, const char *value) | |||
21 | { | 21 | { |
22 | struct string_list_item *item; | 22 | struct string_list_item *item; |
23 | 23 | ||
24 | item = string_list_insert(xstrdup(name), &ctx.cfg.mimetypes); | 24 | item = string_list_insert(xstrdup(name), &ctx.cfg.mimetypes); |
25 | item->util = xstrdup(value); | 25 | item->util = xstrdup(value); |
26 | } | 26 | } |
27 | 27 | ||
28 | struct cgit_filter *new_filter(const char *cmd, int extra_args) | 28 | struct cgit_filter *new_filter(const char *cmd, int extra_args) |
29 | { | 29 | { |
30 | struct cgit_filter *f; | 30 | struct cgit_filter *f; |
31 | 31 | ||
32 | if (!cmd || !cmd[0]) | 32 | if (!cmd || !cmd[0]) |
33 | return NULL; | 33 | return NULL; |
34 | 34 | ||
35 | f = xmalloc(sizeof(struct cgit_filter)); | 35 | f = xmalloc(sizeof(struct cgit_filter)); |
36 | f->cmd = xstrdup(cmd); | 36 | f->cmd = xstrdup(cmd); |
37 | f->argv = xmalloc((2 + extra_args) * sizeof(char *)); | 37 | f->argv = xmalloc((2 + extra_args) * sizeof(char *)); |
38 | f->argv[0] = f->cmd; | 38 | f->argv[0] = f->cmd; |
39 | f->argv[1] = NULL; | 39 | f->argv[1] = NULL; |
40 | return f; | 40 | return f; |
41 | } | 41 | } |
42 | 42 | ||
43 | void config_cb(const char *name, const char *value) | 43 | void config_cb(const char *name, const char *value) |
44 | { | 44 | { |
45 | if (!strcmp(name, "root-title")) | 45 | if (!strcmp(name, "root-title")) |
46 | ctx.cfg.root_title = xstrdup(value); | 46 | ctx.cfg.root_title = xstrdup(value); |
47 | else if (!strcmp(name, "root-desc")) | 47 | else if (!strcmp(name, "root-desc")) |
48 | ctx.cfg.root_desc = xstrdup(value); | 48 | ctx.cfg.root_desc = xstrdup(value); |
49 | else if (!strcmp(name, "root-readme")) | 49 | else if (!strcmp(name, "root-readme")) |
50 | ctx.cfg.root_readme = xstrdup(value); | 50 | ctx.cfg.root_readme = xstrdup(value); |
51 | else if (!strcmp(name, "css")) | 51 | else if (!strcmp(name, "css")) |
52 | ctx.cfg.css = xstrdup(value); | 52 | ctx.cfg.css = xstrdup(value); |
53 | else if (!strcmp(name, "favicon")) | 53 | else if (!strcmp(name, "favicon")) |
54 | ctx.cfg.favicon = xstrdup(value); | 54 | ctx.cfg.favicon = xstrdup(value); |
55 | else if (!strcmp(name, "footer")) | 55 | else if (!strcmp(name, "footer")) |
56 | ctx.cfg.footer = xstrdup(value); | 56 | ctx.cfg.footer = xstrdup(value); |
57 | else if (!strcmp(name, "head-include")) | 57 | else if (!strcmp(name, "head-include")) |
58 | ctx.cfg.head_include = xstrdup(value); | 58 | ctx.cfg.head_include = xstrdup(value); |
59 | else if (!strcmp(name, "header")) | 59 | else if (!strcmp(name, "header")) |
60 | ctx.cfg.header = xstrdup(value); | 60 | ctx.cfg.header = xstrdup(value); |
61 | else if (!strcmp(name, "logo")) | 61 | else if (!strcmp(name, "logo")) |
62 | ctx.cfg.logo = xstrdup(value); | 62 | ctx.cfg.logo = xstrdup(value); |
63 | else if (!strcmp(name, "index-header")) | 63 | else if (!strcmp(name, "index-header")) |
64 | ctx.cfg.index_header = xstrdup(value); | 64 | ctx.cfg.index_header = xstrdup(value); |
65 | else if (!strcmp(name, "index-info")) | 65 | else if (!strcmp(name, "index-info")) |
66 | ctx.cfg.index_info = xstrdup(value); | 66 | ctx.cfg.index_info = xstrdup(value); |
67 | else if (!strcmp(name, "logo-link")) | 67 | else if (!strcmp(name, "logo-link")) |
68 | ctx.cfg.logo_link = xstrdup(value); | 68 | ctx.cfg.logo_link = xstrdup(value); |
69 | else if (!strcmp(name, "linenumbers")) | ||
70 | ctx.cfg.linenumbers = atoi(value); | ||
71 | else if (!strcmp(name, "module-link")) | 69 | else if (!strcmp(name, "module-link")) |
72 | ctx.cfg.module_link = xstrdup(value); | 70 | ctx.cfg.module_link = xstrdup(value); |
73 | else if (!strcmp(name, "virtual-root")) { | 71 | else if (!strcmp(name, "virtual-root")) { |
74 | ctx.cfg.virtual_root = trim_end(value, '/'); | 72 | ctx.cfg.virtual_root = trim_end(value, '/'); |
75 | if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) | 73 | if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) |
76 | ctx.cfg.virtual_root = ""; | 74 | ctx.cfg.virtual_root = ""; |
77 | } else if (!strcmp(name, "nocache")) | 75 | } else if (!strcmp(name, "nocache")) |
78 | ctx.cfg.nocache = atoi(value); | 76 | ctx.cfg.nocache = atoi(value); |
79 | else if (!strcmp(name, "noplainemail")) | 77 | else if (!strcmp(name, "noplainemail")) |
80 | ctx.cfg.noplainemail = atoi(value); | 78 | ctx.cfg.noplainemail = atoi(value); |
81 | else if (!strcmp(name, "noheader")) | 79 | else if (!strcmp(name, "noheader")) |
82 | ctx.cfg.noheader = atoi(value); | 80 | ctx.cfg.noheader = atoi(value); |
83 | else if (!strcmp(name, "snapshots")) | 81 | else if (!strcmp(name, "snapshots")) |
84 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); | 82 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); |
85 | else if (!strcmp(name, "enable-index-links")) | 83 | else if (!strcmp(name, "enable-index-links")) |
86 | ctx.cfg.enable_index_links = atoi(value); | 84 | ctx.cfg.enable_index_links = atoi(value); |
87 | else if (!strcmp(name, "enable-log-filecount")) | 85 | else if (!strcmp(name, "enable-log-filecount")) |
88 | ctx.cfg.enable_log_filecount = atoi(value); | 86 | ctx.cfg.enable_log_filecount = atoi(value); |
89 | else if (!strcmp(name, "enable-log-linecount")) | 87 | else if (!strcmp(name, "enable-log-linecount")) |
90 | ctx.cfg.enable_log_linecount = atoi(value); | 88 | ctx.cfg.enable_log_linecount = atoi(value); |
89 | else if (!strcmp(name, "enable-tree-linenumbers")) | ||
90 | ctx.cfg.enable_tree_linenumbers = atoi(value); | ||
91 | else if (!strcmp(name, "max-stats")) | 91 | else if (!strcmp(name, "max-stats")) |
92 | ctx.cfg.max_stats = cgit_find_stats_period(value, NULL); | 92 | ctx.cfg.max_stats = cgit_find_stats_period(value, NULL); |
93 | else if (!strcmp(name, "cache-size")) | 93 | else if (!strcmp(name, "cache-size")) |
94 | ctx.cfg.cache_size = atoi(value); | 94 | ctx.cfg.cache_size = atoi(value); |
95 | else if (!strcmp(name, "cache-root")) | 95 | else if (!strcmp(name, "cache-root")) |
96 | ctx.cfg.cache_root = xstrdup(value); | 96 | ctx.cfg.cache_root = xstrdup(value); |
97 | else if (!strcmp(name, "cache-root-ttl")) | 97 | else if (!strcmp(name, "cache-root-ttl")) |
98 | ctx.cfg.cache_root_ttl = atoi(value); | 98 | ctx.cfg.cache_root_ttl = atoi(value); |
99 | else if (!strcmp(name, "cache-repo-ttl")) | 99 | else if (!strcmp(name, "cache-repo-ttl")) |
100 | ctx.cfg.cache_repo_ttl = atoi(value); | 100 | ctx.cfg.cache_repo_ttl = atoi(value); |
101 | else if (!strcmp(name, "cache-static-ttl")) | 101 | else if (!strcmp(name, "cache-static-ttl")) |
102 | ctx.cfg.cache_static_ttl = atoi(value); | 102 | ctx.cfg.cache_static_ttl = atoi(value); |
103 | else if (!strcmp(name, "cache-dynamic-ttl")) | 103 | else if (!strcmp(name, "cache-dynamic-ttl")) |
104 | ctx.cfg.cache_dynamic_ttl = atoi(value); | 104 | ctx.cfg.cache_dynamic_ttl = atoi(value); |
105 | else if (!strcmp(name, "about-filter")) | 105 | else if (!strcmp(name, "about-filter")) |
106 | ctx.cfg.about_filter = new_filter(value, 0); | 106 | ctx.cfg.about_filter = new_filter(value, 0); |
107 | else if (!strcmp(name, "commit-filter")) | 107 | else if (!strcmp(name, "commit-filter")) |
108 | ctx.cfg.commit_filter = new_filter(value, 0); | 108 | ctx.cfg.commit_filter = new_filter(value, 0); |
109 | else if (!strcmp(name, "embedded")) | 109 | else if (!strcmp(name, "embedded")) |
110 | ctx.cfg.embedded = atoi(value); | 110 | ctx.cfg.embedded = atoi(value); |
111 | else if (!strcmp(name, "max-message-length")) | 111 | else if (!strcmp(name, "max-message-length")) |
112 | ctx.cfg.max_msg_len = atoi(value); | 112 | ctx.cfg.max_msg_len = atoi(value); |
113 | else if (!strcmp(name, "max-repodesc-length")) | 113 | else if (!strcmp(name, "max-repodesc-length")) |
114 | ctx.cfg.max_repodesc_len = atoi(value); | 114 | ctx.cfg.max_repodesc_len = atoi(value); |
115 | else if (!strcmp(name, "max-repo-count")) | 115 | else if (!strcmp(name, "max-repo-count")) |
116 | ctx.cfg.max_repo_count = atoi(value); | 116 | ctx.cfg.max_repo_count = atoi(value); |
117 | else if (!strcmp(name, "max-commit-count")) | 117 | else if (!strcmp(name, "max-commit-count")) |
118 | ctx.cfg.max_commit_count = atoi(value); | 118 | ctx.cfg.max_commit_count = atoi(value); |
119 | else if (!strcmp(name, "source-filter")) | 119 | else if (!strcmp(name, "source-filter")) |
120 | ctx.cfg.source_filter = new_filter(value, 1); | 120 | ctx.cfg.source_filter = new_filter(value, 1); |
121 | else if (!strcmp(name, "summary-log")) | 121 | else if (!strcmp(name, "summary-log")) |
122 | ctx.cfg.summary_log = atoi(value); | 122 | ctx.cfg.summary_log = atoi(value); |
123 | else if (!strcmp(name, "summary-branches")) | 123 | else if (!strcmp(name, "summary-branches")) |
124 | ctx.cfg.summary_branches = atoi(value); | 124 | ctx.cfg.summary_branches = atoi(value); |
125 | else if (!strcmp(name, "summary-tags")) | 125 | else if (!strcmp(name, "summary-tags")) |
126 | ctx.cfg.summary_tags = atoi(value); | 126 | ctx.cfg.summary_tags = atoi(value); |
127 | else if (!strcmp(name, "agefile")) | 127 | else if (!strcmp(name, "agefile")) |
128 | ctx.cfg.agefile = xstrdup(value); | 128 | ctx.cfg.agefile = xstrdup(value); |
129 | else if (!strcmp(name, "renamelimit")) | 129 | else if (!strcmp(name, "renamelimit")) |
130 | ctx.cfg.renamelimit = atoi(value); | 130 | ctx.cfg.renamelimit = atoi(value); |
131 | else if (!strcmp(name, "robots")) | 131 | else if (!strcmp(name, "robots")) |
132 | ctx.cfg.robots = xstrdup(value); | 132 | ctx.cfg.robots = xstrdup(value); |
133 | else if (!strcmp(name, "clone-prefix")) | 133 | else if (!strcmp(name, "clone-prefix")) |
134 | ctx.cfg.clone_prefix = xstrdup(value); | 134 | ctx.cfg.clone_prefix = xstrdup(value); |
135 | else if (!strcmp(name, "local-time")) | 135 | else if (!strcmp(name, "local-time")) |
136 | ctx.cfg.local_time = atoi(value); | 136 | ctx.cfg.local_time = atoi(value); |
137 | else if (!prefixcmp(name, "mimetype.")) | 137 | else if (!prefixcmp(name, "mimetype.")) |
138 | add_mimetype(name + 9, value); | 138 | add_mimetype(name + 9, value); |
@@ -195,96 +195,97 @@ static void querystring_cb(const char *name, const char *value) | |||
195 | } else if (!strcmp(name, "q")) { | 195 | } else if (!strcmp(name, "q")) { |
196 | ctx.qry.search = xstrdup(value); | 196 | ctx.qry.search = xstrdup(value); |
197 | } else if (!strcmp(name, "h")) { | 197 | } else if (!strcmp(name, "h")) { |
198 | ctx.qry.head = xstrdup(value); | 198 | ctx.qry.head = xstrdup(value); |
199 | ctx.qry.has_symref = 1; | 199 | ctx.qry.has_symref = 1; |
200 | } else if (!strcmp(name, "id")) { | 200 | } else if (!strcmp(name, "id")) { |
201 | ctx.qry.sha1 = xstrdup(value); | 201 | ctx.qry.sha1 = xstrdup(value); |
202 | ctx.qry.has_sha1 = 1; | 202 | ctx.qry.has_sha1 = 1; |
203 | } else if (!strcmp(name, "id2")) { | 203 | } else if (!strcmp(name, "id2")) { |
204 | ctx.qry.sha2 = xstrdup(value); | 204 | ctx.qry.sha2 = xstrdup(value); |
205 | ctx.qry.has_sha1 = 1; | 205 | ctx.qry.has_sha1 = 1; |
206 | } else if (!strcmp(name, "ofs")) { | 206 | } else if (!strcmp(name, "ofs")) { |
207 | ctx.qry.ofs = atoi(value); | 207 | ctx.qry.ofs = atoi(value); |
208 | } else if (!strcmp(name, "path")) { | 208 | } else if (!strcmp(name, "path")) { |
209 | ctx.qry.path = trim_end(value, '/'); | 209 | ctx.qry.path = trim_end(value, '/'); |
210 | } else if (!strcmp(name, "name")) { | 210 | } else if (!strcmp(name, "name")) { |
211 | ctx.qry.name = xstrdup(value); | 211 | ctx.qry.name = xstrdup(value); |
212 | } else if (!strcmp(name, "mimetype")) { | 212 | } else if (!strcmp(name, "mimetype")) { |
213 | ctx.qry.mimetype = xstrdup(value); | 213 | ctx.qry.mimetype = xstrdup(value); |
214 | } else if (!strcmp(name, "s")){ | 214 | } else if (!strcmp(name, "s")){ |
215 | ctx.qry.sort = xstrdup(value); | 215 | ctx.qry.sort = xstrdup(value); |
216 | } else if (!strcmp(name, "showmsg")) { | 216 | } else if (!strcmp(name, "showmsg")) { |
217 | ctx.qry.showmsg = atoi(value); | 217 | ctx.qry.showmsg = atoi(value); |
218 | } else if (!strcmp(name, "period")) { | 218 | } else if (!strcmp(name, "period")) { |
219 | ctx.qry.period = xstrdup(value); | 219 | ctx.qry.period = xstrdup(value); |
220 | } | 220 | } |
221 | } | 221 | } |
222 | 222 | ||
223 | char *xstrdupn(const char *str) | 223 | char *xstrdupn(const char *str) |
224 | { | 224 | { |
225 | return (str ? xstrdup(str) : NULL); | 225 | return (str ? xstrdup(str) : NULL); |
226 | } | 226 | } |
227 | 227 | ||
228 | static void prepare_context(struct cgit_context *ctx) | 228 | static void prepare_context(struct cgit_context *ctx) |
229 | { | 229 | { |
230 | memset(ctx, 0, sizeof(ctx)); | 230 | memset(ctx, 0, sizeof(ctx)); |
231 | ctx->cfg.agefile = "info/web/last-modified"; | 231 | ctx->cfg.agefile = "info/web/last-modified"; |
232 | ctx->cfg.nocache = 0; | 232 | ctx->cfg.nocache = 0; |
233 | ctx->cfg.cache_size = 0; | 233 | ctx->cfg.cache_size = 0; |
234 | ctx->cfg.cache_dynamic_ttl = 5; | 234 | ctx->cfg.cache_dynamic_ttl = 5; |
235 | ctx->cfg.cache_max_create_time = 5; | 235 | ctx->cfg.cache_max_create_time = 5; |
236 | ctx->cfg.cache_repo_ttl = 5; | 236 | ctx->cfg.cache_repo_ttl = 5; |
237 | ctx->cfg.cache_root = CGIT_CACHE_ROOT; | 237 | ctx->cfg.cache_root = CGIT_CACHE_ROOT; |
238 | ctx->cfg.cache_root_ttl = 5; | 238 | ctx->cfg.cache_root_ttl = 5; |
239 | ctx->cfg.cache_static_ttl = -1; | 239 | ctx->cfg.cache_static_ttl = -1; |
240 | ctx->cfg.css = "/cgit.css"; | 240 | ctx->cfg.css = "/cgit.css"; |
241 | ctx->cfg.logo = "/cgit.png"; | 241 | ctx->cfg.logo = "/cgit.png"; |
242 | ctx->cfg.local_time = 0; | 242 | ctx->cfg.local_time = 0; |
243 | ctx->cfg.enable_tree_linenumbers = 1; | ||
243 | ctx->cfg.max_repo_count = 50; | 244 | ctx->cfg.max_repo_count = 50; |
244 | ctx->cfg.max_commit_count = 50; | 245 | ctx->cfg.max_commit_count = 50; |
245 | ctx->cfg.max_lock_attempts = 5; | 246 | ctx->cfg.max_lock_attempts = 5; |
246 | ctx->cfg.max_msg_len = 80; | 247 | ctx->cfg.max_msg_len = 80; |
247 | ctx->cfg.max_repodesc_len = 80; | 248 | ctx->cfg.max_repodesc_len = 80; |
248 | ctx->cfg.max_stats = 0; | 249 | ctx->cfg.max_stats = 0; |
249 | ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; | 250 | ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; |
250 | ctx->cfg.renamelimit = -1; | 251 | ctx->cfg.renamelimit = -1; |
251 | ctx->cfg.robots = "index, nofollow"; | 252 | ctx->cfg.robots = "index, nofollow"; |
252 | ctx->cfg.root_title = "Git repository browser"; | 253 | ctx->cfg.root_title = "Git repository browser"; |
253 | ctx->cfg.root_desc = "a fast webinterface for the git dscm"; | 254 | ctx->cfg.root_desc = "a fast webinterface for the git dscm"; |
254 | ctx->cfg.script_name = CGIT_SCRIPT_NAME; | 255 | ctx->cfg.script_name = CGIT_SCRIPT_NAME; |
255 | ctx->cfg.summary_branches = 10; | 256 | ctx->cfg.summary_branches = 10; |
256 | ctx->cfg.summary_log = 10; | 257 | ctx->cfg.summary_log = 10; |
257 | ctx->cfg.summary_tags = 10; | 258 | ctx->cfg.summary_tags = 10; |
258 | ctx->env.cgit_config = xstrdupn(getenv("CGIT_CONFIG")); | 259 | ctx->env.cgit_config = xstrdupn(getenv("CGIT_CONFIG")); |
259 | ctx->env.http_host = xstrdupn(getenv("HTTP_HOST")); | 260 | ctx->env.http_host = xstrdupn(getenv("HTTP_HOST")); |
260 | ctx->env.https = xstrdupn(getenv("HTTPS")); | 261 | ctx->env.https = xstrdupn(getenv("HTTPS")); |
261 | ctx->env.no_http = xstrdupn(getenv("NO_HTTP")); | 262 | ctx->env.no_http = xstrdupn(getenv("NO_HTTP")); |
262 | ctx->env.path_info = xstrdupn(getenv("PATH_INFO")); | 263 | ctx->env.path_info = xstrdupn(getenv("PATH_INFO")); |
263 | ctx->env.query_string = xstrdupn(getenv("QUERY_STRING")); | 264 | ctx->env.query_string = xstrdupn(getenv("QUERY_STRING")); |
264 | ctx->env.request_method = xstrdupn(getenv("REQUEST_METHOD")); | 265 | ctx->env.request_method = xstrdupn(getenv("REQUEST_METHOD")); |
265 | ctx->env.script_name = xstrdupn(getenv("SCRIPT_NAME")); | 266 | ctx->env.script_name = xstrdupn(getenv("SCRIPT_NAME")); |
266 | ctx->env.server_name = xstrdupn(getenv("SERVER_NAME")); | 267 | ctx->env.server_name = xstrdupn(getenv("SERVER_NAME")); |
267 | ctx->env.server_port = xstrdupn(getenv("SERVER_PORT")); | 268 | ctx->env.server_port = xstrdupn(getenv("SERVER_PORT")); |
268 | ctx->page.mimetype = "text/html"; | 269 | ctx->page.mimetype = "text/html"; |
269 | ctx->page.charset = PAGE_ENCODING; | 270 | ctx->page.charset = PAGE_ENCODING; |
270 | ctx->page.filename = NULL; | 271 | ctx->page.filename = NULL; |
271 | ctx->page.size = 0; | 272 | ctx->page.size = 0; |
272 | ctx->page.modified = time(NULL); | 273 | ctx->page.modified = time(NULL); |
273 | ctx->page.expires = ctx->page.modified; | 274 | ctx->page.expires = ctx->page.modified; |
274 | ctx->page.etag = NULL; | 275 | ctx->page.etag = NULL; |
275 | memset(&ctx->cfg.mimetypes, 0, sizeof(struct string_list)); | 276 | memset(&ctx->cfg.mimetypes, 0, sizeof(struct string_list)); |
276 | if (ctx->env.script_name) | 277 | if (ctx->env.script_name) |
277 | ctx->cfg.script_name = ctx->env.script_name; | 278 | ctx->cfg.script_name = ctx->env.script_name; |
278 | if (ctx->env.query_string) | 279 | if (ctx->env.query_string) |
279 | ctx->qry.raw = ctx->env.query_string; | 280 | ctx->qry.raw = ctx->env.query_string; |
280 | if (!ctx->env.cgit_config) | 281 | if (!ctx->env.cgit_config) |
281 | ctx->env.cgit_config = CGIT_CONFIG; | 282 | ctx->env.cgit_config = CGIT_CONFIG; |
282 | } | 283 | } |
283 | 284 | ||
284 | struct refmatch { | 285 | struct refmatch { |
285 | char *req_ref; | 286 | char *req_ref; |
286 | char *first_ref; | 287 | char *first_ref; |
287 | int match; | 288 | int match; |
288 | }; | 289 | }; |
289 | 290 | ||
290 | int find_current_ref(const char *refname, const unsigned char *sha1, | 291 | int find_current_ref(const char *refname, const unsigned char *sha1, |
@@ -128,98 +128,98 @@ struct cgit_query { | |||
128 | char *page; | 128 | char *page; |
129 | char *search; | 129 | char *search; |
130 | char *grep; | 130 | char *grep; |
131 | char *head; | 131 | char *head; |
132 | char *sha1; | 132 | char *sha1; |
133 | char *sha2; | 133 | char *sha2; |
134 | char *path; | 134 | char *path; |
135 | char *name; | 135 | char *name; |
136 | char *mimetype; | 136 | char *mimetype; |
137 | char *url; | 137 | char *url; |
138 | char *period; | 138 | char *period; |
139 | int ofs; | 139 | int ofs; |
140 | int nohead; | 140 | int nohead; |
141 | char *sort; | 141 | char *sort; |
142 | int showmsg; | 142 | int showmsg; |
143 | }; | 143 | }; |
144 | 144 | ||
145 | struct cgit_config { | 145 | struct cgit_config { |
146 | char *agefile; | 146 | char *agefile; |
147 | char *cache_root; | 147 | char *cache_root; |
148 | char *clone_prefix; | 148 | char *clone_prefix; |
149 | char *css; | 149 | char *css; |
150 | char *favicon; | 150 | char *favicon; |
151 | char *footer; | 151 | char *footer; |
152 | char *head_include; | 152 | char *head_include; |
153 | char *header; | 153 | char *header; |
154 | char *index_header; | 154 | char *index_header; |
155 | char *index_info; | 155 | char *index_info; |
156 | char *logo; | 156 | char *logo; |
157 | char *logo_link; | 157 | char *logo_link; |
158 | char *module_link; | 158 | char *module_link; |
159 | char *repo_group; | 159 | char *repo_group; |
160 | char *robots; | 160 | char *robots; |
161 | char *root_title; | 161 | char *root_title; |
162 | char *root_desc; | 162 | char *root_desc; |
163 | char *root_readme; | 163 | char *root_readme; |
164 | char *script_name; | 164 | char *script_name; |
165 | char *virtual_root; | 165 | char *virtual_root; |
166 | int cache_size; | 166 | int cache_size; |
167 | int cache_dynamic_ttl; | 167 | int cache_dynamic_ttl; |
168 | int cache_max_create_time; | 168 | int cache_max_create_time; |
169 | int cache_repo_ttl; | 169 | int cache_repo_ttl; |
170 | int cache_root_ttl; | 170 | int cache_root_ttl; |
171 | int cache_static_ttl; | 171 | int cache_static_ttl; |
172 | int embedded; | 172 | int embedded; |
173 | int enable_index_links; | 173 | int enable_index_links; |
174 | int enable_log_filecount; | 174 | int enable_log_filecount; |
175 | int enable_log_linecount; | 175 | int enable_log_linecount; |
176 | int enable_tree_linenumbers; | ||
176 | int local_time; | 177 | int local_time; |
177 | int linenumbers; | ||
178 | int max_repo_count; | 178 | int max_repo_count; |
179 | int max_commit_count; | 179 | int max_commit_count; |
180 | int max_lock_attempts; | 180 | int max_lock_attempts; |
181 | int max_msg_len; | 181 | int max_msg_len; |
182 | int max_repodesc_len; | 182 | int max_repodesc_len; |
183 | int max_stats; | 183 | int max_stats; |
184 | int nocache; | 184 | int nocache; |
185 | int noplainemail; | 185 | int noplainemail; |
186 | int noheader; | 186 | int noheader; |
187 | int renamelimit; | 187 | int renamelimit; |
188 | int snapshots; | 188 | int snapshots; |
189 | int summary_branches; | 189 | int summary_branches; |
190 | int summary_log; | 190 | int summary_log; |
191 | int summary_tags; | 191 | int summary_tags; |
192 | struct string_list mimetypes; | 192 | struct string_list mimetypes; |
193 | struct cgit_filter *about_filter; | 193 | struct cgit_filter *about_filter; |
194 | struct cgit_filter *commit_filter; | 194 | struct cgit_filter *commit_filter; |
195 | struct cgit_filter *source_filter; | 195 | struct cgit_filter *source_filter; |
196 | }; | 196 | }; |
197 | 197 | ||
198 | struct cgit_page { | 198 | struct cgit_page { |
199 | time_t modified; | 199 | time_t modified; |
200 | time_t expires; | 200 | time_t expires; |
201 | size_t size; | 201 | size_t size; |
202 | char *mimetype; | 202 | char *mimetype; |
203 | char *charset; | 203 | char *charset; |
204 | char *filename; | 204 | char *filename; |
205 | char *etag; | 205 | char *etag; |
206 | char *title; | 206 | char *title; |
207 | int status; | 207 | int status; |
208 | char *statusmsg; | 208 | char *statusmsg; |
209 | }; | 209 | }; |
210 | 210 | ||
211 | struct cgit_environment { | 211 | struct cgit_environment { |
212 | char *cgit_config; | 212 | char *cgit_config; |
213 | char *http_host; | 213 | char *http_host; |
214 | char *https; | 214 | char *https; |
215 | char *no_http; | 215 | char *no_http; |
216 | char *path_info; | 216 | char *path_info; |
217 | char *query_string; | 217 | char *query_string; |
218 | char *request_method; | 218 | char *request_method; |
219 | char *script_name; | 219 | char *script_name; |
220 | char *server_name; | 220 | char *server_name; |
221 | char *server_port; | 221 | char *server_port; |
222 | }; | 222 | }; |
223 | 223 | ||
224 | struct cgit_context { | 224 | struct cgit_context { |
225 | struct cgit_environment env; | 225 | struct cgit_environment env; |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index a762ccc..ac5c58c 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -54,147 +54,147 @@ cache-root-ttl:: | |||
54 | Number which specifies the time-to-live, in minutes, for the cached | 54 | Number which specifies the time-to-live, in minutes, for the cached |
55 | version of the repository index page. Default value: "5". | 55 | version of the repository index page. Default value: "5". |
56 | 56 | ||
57 | cache-size:: | 57 | cache-size:: |
58 | The maximum number of entries in the cgit cache. Default value: "0" | 58 | The maximum number of entries in the cgit cache. Default value: "0" |
59 | (i.e. caching is disabled). | 59 | (i.e. caching is disabled). |
60 | 60 | ||
61 | cache-static-ttl:: | 61 | cache-static-ttl:: |
62 | Number which specifies the time-to-live, in minutes, for the cached | 62 | Number which specifies the time-to-live, in minutes, for the cached |
63 | version of repository pages accessed with a fixed SHA1. Default value: | 63 | version of repository pages accessed with a fixed SHA1. Default value: |
64 | "5". | 64 | "5". |
65 | 65 | ||
66 | clone-prefix:: | 66 | clone-prefix:: |
67 | Space-separated list of common prefixes which, when combined with a | 67 | Space-separated list of common prefixes which, when combined with a |
68 | repository url, generates valid clone urls for the repository. This | 68 | repository url, generates valid clone urls for the repository. This |
69 | setting is only used if `repo.clone-url` is unspecified. Default value: | 69 | setting is only used if `repo.clone-url` is unspecified. Default value: |
70 | none. | 70 | none. |
71 | 71 | ||
72 | commit-filter:: | 72 | commit-filter:: |
73 | Specifies a command which will be invoked to format commit messages. | 73 | Specifies a command which will be invoked to format commit messages. |
74 | The command will get the message on its STDIN, and the STDOUT from the | 74 | The command will get the message on its STDIN, and the STDOUT from the |
75 | command will be included verbatim as the commit message, i.e. this can | 75 | command will be included verbatim as the commit message, i.e. this can |
76 | be used to implement bugtracker integration. Default value: none. | 76 | be used to implement bugtracker integration. Default value: none. |
77 | 77 | ||
78 | css:: | 78 | css:: |
79 | Url which specifies the css document to include in all cgit pages. | 79 | Url which specifies the css document to include in all cgit pages. |
80 | Default value: "/cgit.css". | 80 | Default value: "/cgit.css". |
81 | 81 | ||
82 | embedded:: | 82 | embedded:: |
83 | Flag which, when set to "1", will make cgit generate a html fragment | 83 | Flag which, when set to "1", will make cgit generate a html fragment |
84 | suitable for embedding in other html pages. Default value: none. See | 84 | suitable for embedding in other html pages. Default value: none. See |
85 | also: "noheader". | 85 | also: "noheader". |
86 | 86 | ||
87 | enable-index-links:: | 87 | enable-index-links:: |
88 | Flag which, when set to "1", will make cgit generate extra links for | 88 | Flag which, when set to "1", will make cgit generate extra links for |
89 | each repo in the repository index (specifically, to the "summary", | 89 | each repo in the repository index (specifically, to the "summary", |
90 | "commit" and "tree" pages). Default value: "0". | 90 | "commit" and "tree" pages). Default value: "0". |
91 | 91 | ||
92 | enable-log-filecount:: | 92 | enable-log-filecount:: |
93 | Flag which, when set to "1", will make cgit print the number of | 93 | Flag which, when set to "1", will make cgit print the number of |
94 | modified files for each commit on the repository log page. Default | 94 | modified files for each commit on the repository log page. Default |
95 | value: "0". | 95 | value: "0". |
96 | 96 | ||
97 | enable-log-linecount:: | 97 | enable-log-linecount:: |
98 | Flag which, when set to "1", will make cgit print the number of added | 98 | Flag which, when set to "1", will make cgit print the number of added |
99 | and removed lines for each commit on the repository log page. Default | 99 | and removed lines for each commit on the repository log page. Default |
100 | value: "0". | 100 | value: "0". |
101 | 101 | ||
102 | enable-tree-linenumbers:: | ||
103 | Flag which, when set to "1", will make cgit generate linenumber links | ||
104 | for plaintext blobs printed in the tree view. Default value: "1". | ||
105 | |||
102 | favicon:: | 106 | favicon:: |
103 | Url used as link to a shortcut icon for cgit. If specified, it is | 107 | Url used as link to a shortcut icon for cgit. If specified, it is |
104 | suggested to use the value "/favicon.ico" since certain browsers will | 108 | suggested to use the value "/favicon.ico" since certain browsers will |
105 | ignore other values. Default value: none. | 109 | ignore other values. Default value: none. |
106 | 110 | ||
107 | footer:: | 111 | footer:: |
108 | The content of the file specified with this option will be included | 112 | The content of the file specified with this option will be included |
109 | verbatim at the bottom of all pages (i.e. it replaces the standard | 113 | verbatim at the bottom of all pages (i.e. it replaces the standard |
110 | "generated by..." message. Default value: none. | 114 | "generated by..." message. Default value: none. |
111 | 115 | ||
112 | head-include:: | 116 | head-include:: |
113 | The content of the file specified with this option will be included | 117 | The content of the file specified with this option will be included |
114 | verbatim in the html HEAD section on all pages. Default value: none. | 118 | verbatim in the html HEAD section on all pages. Default value: none. |
115 | 119 | ||
116 | header:: | 120 | header:: |
117 | The content of the file specified with this option will be included | 121 | The content of the file specified with this option will be included |
118 | verbatim at the top of all pages. Default value: none. | 122 | verbatim at the top of all pages. Default value: none. |
119 | 123 | ||
120 | include:: | 124 | include:: |
121 | Name of a configfile to include before the rest of the current config- | 125 | Name of a configfile to include before the rest of the current config- |
122 | file is parsed. Default value: none. | 126 | file is parsed. Default value: none. |
123 | 127 | ||
124 | index-header:: | 128 | index-header:: |
125 | The content of the file specified with this option will be included | 129 | The content of the file specified with this option will be included |
126 | verbatim above the repository index. This setting is deprecated, and | 130 | verbatim above the repository index. This setting is deprecated, and |
127 | will not be supported by cgit-1.0 (use root-readme instead). Default | 131 | will not be supported by cgit-1.0 (use root-readme instead). Default |
128 | value: none. | 132 | value: none. |
129 | 133 | ||
130 | index-info:: | 134 | index-info:: |
131 | The content of the file specified with this option will be included | 135 | The content of the file specified with this option will be included |
132 | verbatim below the heading on the repository index page. This setting | 136 | verbatim below the heading on the repository index page. This setting |
133 | is deprecated, and will not be supported by cgit-1.0 (use root-desc | 137 | is deprecated, and will not be supported by cgit-1.0 (use root-desc |
134 | instead). Default value: none. | 138 | instead). Default value: none. |
135 | 139 | ||
136 | local-time:: | 140 | local-time:: |
137 | Flag which, if set to "1", makes cgit print commit and tag times in the | 141 | Flag which, if set to "1", makes cgit print commit and tag times in the |
138 | servers timezone. Default value: "0". | 142 | servers timezone. Default value: "0". |
139 | 143 | ||
140 | logo:: | 144 | logo:: |
141 | Url which specifies the source of an image which will be used as a logo | 145 | Url which specifies the source of an image which will be used as a logo |
142 | on all cgit pages. Default value: "/cgit.png". | 146 | on all cgit pages. Default value: "/cgit.png". |
143 | 147 | ||
144 | logo-link:: | 148 | logo-link:: |
145 | Url loaded when clicking on the cgit logo image. If unspecified the | 149 | Url loaded when clicking on the cgit logo image. If unspecified the |
146 | calculated url of the repository index page will be used. Default | 150 | calculated url of the repository index page will be used. Default |
147 | value: none. | 151 | value: none. |
148 | 152 | ||
149 | linenumbers:: | ||
150 | If set to "1" lines in tree view will have numbers. | ||
151 | Default value: "0". | ||
152 | |||
153 | max-commit-count:: | 153 | max-commit-count:: |
154 | Specifies the number of entries to list per page in "log" view. Default | 154 | Specifies the number of entries to list per page in "log" view. Default |
155 | value: "50". | 155 | value: "50". |
156 | 156 | ||
157 | max-message-length:: | 157 | max-message-length:: |
158 | Specifies the maximum number of commit message characters to display in | 158 | Specifies the maximum number of commit message characters to display in |
159 | "log" view. Default value: "80". | 159 | "log" view. Default value: "80". |
160 | 160 | ||
161 | max-repo-count:: | 161 | max-repo-count:: |
162 | Specifies the number of entries to list per page on therepository | 162 | Specifies the number of entries to list per page on therepository |
163 | index page. Default value: "50". | 163 | index page. Default value: "50". |
164 | 164 | ||
165 | max-repodesc-length:: | 165 | max-repodesc-length:: |
166 | Specifies the maximum number of repo description characters to display | 166 | Specifies the maximum number of repo description characters to display |
167 | on the repository index page. Default value: "80". | 167 | on the repository index page. Default value: "80". |
168 | 168 | ||
169 | max-stats:: | 169 | max-stats:: |
170 | Set the default maximum statistics period. Valid values are "week", | 170 | Set the default maximum statistics period. Valid values are "week", |
171 | "month", "quarter" and "year". If unspecified, statistics are | 171 | "month", "quarter" and "year". If unspecified, statistics are |
172 | disabled. Default value: none. See also: "repo.max-stats". | 172 | disabled. Default value: none. See also: "repo.max-stats". |
173 | 173 | ||
174 | mimetype.<ext>:: | 174 | mimetype.<ext>:: |
175 | Set the mimetype for the specified filename extension. This is used | 175 | Set the mimetype for the specified filename extension. This is used |
176 | by the `plain` command when returning blob content. | 176 | by the `plain` command when returning blob content. |
177 | 177 | ||
178 | module-link:: | 178 | module-link:: |
179 | Text which will be used as the formatstring for a hyperlink when a | 179 | Text which will be used as the formatstring for a hyperlink when a |
180 | submodule is printed in a directory listing. The arguments for the | 180 | submodule is printed in a directory listing. The arguments for the |
181 | formatstring are the path and SHA1 of the submodule commit. Default | 181 | formatstring are the path and SHA1 of the submodule commit. Default |
182 | value: "./?repo=%s&page=commit&id=%s" | 182 | value: "./?repo=%s&page=commit&id=%s" |
183 | 183 | ||
184 | nocache:: | 184 | nocache:: |
185 | If set to the value "1" caching will be disabled. This settings is | 185 | If set to the value "1" caching will be disabled. This settings is |
186 | deprecated, and will not be honored starting with cgit-1.0. Default | 186 | deprecated, and will not be honored starting with cgit-1.0. Default |
187 | value: "0". | 187 | value: "0". |
188 | 188 | ||
189 | noplainemail:: | 189 | noplainemail:: |
190 | If set to "1" showing full author email adresses will be disabled. | 190 | If set to "1" showing full author email adresses will be disabled. |
191 | Default value: "0". | 191 | Default value: "0". |
192 | 192 | ||
193 | noheader:: | 193 | noheader:: |
194 | Flag which, when set to "1", will make cgit omit the standard header | 194 | Flag which, when set to "1", will make cgit omit the standard header |
195 | on all pages. Default value: none. See also: "embedded". | 195 | on all pages. Default value: none. See also: "embedded". |
196 | 196 | ||
197 | renamelimit:: | 197 | renamelimit:: |
198 | Maximum number of files to consider when detecting renames. The value | 198 | Maximum number of files to consider when detecting renames. The value |
199 | "-1" uses the compiletime value in git (for further info, look at | 199 | "-1" uses the compiletime value in git (for further info, look at |
200 | `man git-diff`). Default value: "-1". | 200 | `man git-diff`). Default value: "-1". |
@@ -1,74 +1,74 @@ | |||
1 | /* ui-tree.c: functions for tree output | 1 | /* ui-tree.c: functions for tree output |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <ctype.h> | 9 | #include <ctype.h> |
10 | #include "cgit.h" | 10 | #include "cgit.h" |
11 | #include "html.h" | 11 | #include "html.h" |
12 | #include "ui-shared.h" | 12 | #include "ui-shared.h" |
13 | 13 | ||
14 | char *curr_rev; | 14 | char *curr_rev; |
15 | char *match_path; | 15 | char *match_path; |
16 | int header = 0; | 16 | int header = 0; |
17 | 17 | ||
18 | static void print_text_buffer(const char *name, char *buf, unsigned long size) | 18 | static void print_text_buffer(const char *name, char *buf, unsigned long size) |
19 | { | 19 | { |
20 | unsigned long lineno, idx; | 20 | unsigned long lineno, idx; |
21 | const char *numberfmt = | 21 | const char *numberfmt = |
22 | "<a class='no' id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a>\n"; | 22 | "<a class='no' id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a>\n"; |
23 | 23 | ||
24 | html("<table summary='blob content' class='blob'>\n"); | 24 | html("<table summary='blob content' class='blob'>\n"); |
25 | 25 | ||
26 | if (ctx.cfg.linenumbers) { | 26 | if (ctx.cfg.enable_tree_linenumbers) { |
27 | html("<tr><td class='linenumbers'><pre>"); | 27 | html("<tr><td class='linenumbers'><pre>"); |
28 | idx = 0; | 28 | idx = 0; |
29 | lineno = 0; | 29 | lineno = 0; |
30 | 30 | ||
31 | if (size) { | 31 | if (size) { |
32 | htmlf(numberfmt, ++lineno); | 32 | htmlf(numberfmt, ++lineno); |
33 | while(idx < size - 1) { // skip absolute last newline | 33 | while(idx < size - 1) { // skip absolute last newline |
34 | if (buf[idx] == '\n') | 34 | if (buf[idx] == '\n') |
35 | htmlf(numberfmt, ++lineno); | 35 | htmlf(numberfmt, ++lineno); |
36 | idx++; | 36 | idx++; |
37 | } | 37 | } |
38 | } | 38 | } |
39 | html("</pre></td>\n"); | 39 | html("</pre></td>\n"); |
40 | } | 40 | } |
41 | else { | 41 | else { |
42 | html("<tr>\n"); | 42 | html("<tr>\n"); |
43 | } | 43 | } |
44 | 44 | ||
45 | if (ctx.repo->source_filter) { | 45 | if (ctx.repo->source_filter) { |
46 | html("<td class='lines'><pre><code>"); | 46 | html("<td class='lines'><pre><code>"); |
47 | ctx.repo->source_filter->argv[1] = xstrdup(name); | 47 | ctx.repo->source_filter->argv[1] = xstrdup(name); |
48 | cgit_open_filter(ctx.repo->source_filter); | 48 | cgit_open_filter(ctx.repo->source_filter); |
49 | write(STDOUT_FILENO, buf, size); | 49 | write(STDOUT_FILENO, buf, size); |
50 | cgit_close_filter(ctx.repo->source_filter); | 50 | cgit_close_filter(ctx.repo->source_filter); |
51 | html("</code></pre></td></tr></table>\n"); | 51 | html("</code></pre></td></tr></table>\n"); |
52 | return; | 52 | return; |
53 | } | 53 | } |
54 | 54 | ||
55 | html("<td class='lines'><pre><code>"); | 55 | html("<td class='lines'><pre><code>"); |
56 | html_txt(buf); | 56 | html_txt(buf); |
57 | html("</code></pre></td></tr></table>\n"); | 57 | html("</code></pre></td></tr></table>\n"); |
58 | } | 58 | } |
59 | 59 | ||
60 | #define ROWLEN 32 | 60 | #define ROWLEN 32 |
61 | 61 | ||
62 | static void print_binary_buffer(char *buf, unsigned long size) | 62 | static void print_binary_buffer(char *buf, unsigned long size) |
63 | { | 63 | { |
64 | unsigned long ofs, idx; | 64 | unsigned long ofs, idx; |
65 | static char ascii[ROWLEN + 1]; | 65 | static char ascii[ROWLEN + 1]; |
66 | 66 | ||
67 | html("<table summary='blob content' class='bin-blob'>\n"); | 67 | html("<table summary='blob content' class='bin-blob'>\n"); |
68 | html("<tr><th>ofs</th><th>hex dump</th><th>ascii</th></tr>"); | 68 | html("<tr><th>ofs</th><th>hex dump</th><th>ascii</th></tr>"); |
69 | for (ofs = 0; ofs < size; ofs += ROWLEN, buf += ROWLEN) { | 69 | for (ofs = 0; ofs < size; ofs += ROWLEN, buf += ROWLEN) { |
70 | htmlf("<tr><td class='right'>%04x</td><td class='hex'>", ofs); | 70 | htmlf("<tr><td class='right'>%04x</td><td class='hex'>", ofs); |
71 | for (idx = 0; idx < ROWLEN && ofs + idx < size; idx++) | 71 | for (idx = 0; idx < ROWLEN && ofs + idx < size; idx++) |
72 | htmlf("%*s%02x", | 72 | htmlf("%*s%02x", |
73 | idx == 16 ? 4 : 1, "", | 73 | idx == 16 ? 4 : 1, "", |
74 | buf[idx] & 0xff); | 74 | buf[idx] & 0xff); |