author | Lars Hjemli <hjemli@gmail.com> | 2011-02-19 13:51:00 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2011-02-19 13:51:00 (UTC) |
commit | 979c460e7f71d153ae79da67b8b21c3412f0fe02 (patch) (unidiff) | |
tree | 6da9ffb66ed0a68205e6644cb7e2b4652d6684be | |
parent | fb9e6d1594a24fe4e551fd57a9c91fd18b14806e (diff) | |
parent | 0141b9f889bbaa1fe474f9a98dd377138ac73054 (diff) | |
download | cgit-979c460e7f71d153ae79da67b8b21c3412f0fe02.zip cgit-979c460e7f71d153ae79da67b8b21c3412f0fe02.tar.gz cgit-979c460e7f71d153ae79da67b8b21c3412f0fe02.tar.bz2 |
Merge branch 'br/misc'
* br/misc:
Use transparent background for the cgit logo
ssdiff: anchors for ssdiff
implement repo.logo and repo.logo-link
-rw-r--r-- | cgit.c | 8 | ||||
-rw-r--r-- | cgit.css | 2 | ||||
-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | cgit.png | bin | 1840 -> 1488 bytes | |||
-rw-r--r-- | cgitrc.5.txt | 9 | ||||
-rw-r--r-- | ui-diff.c | 12 | ||||
-rw-r--r-- | ui-diff.h | 6 | ||||
-rw-r--r-- | ui-shared.c | 18 | ||||
-rw-r--r-- | ui-ssdiff.c | 34 |
9 files changed, 74 insertions, 17 deletions
@@ -1,462 +1,466 @@ | |||
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 | * Copyright (C) 2010 Jason A. Donenfeld <Jason@zx2c4.com> |
5 | * | 5 | * |
6 | * Licensed under GNU General Public License v2 | 6 | * Licensed under GNU General Public License v2 |
7 | * (see COPYING for full license text) | 7 | * (see COPYING for full license text) |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include "cgit.h" | 10 | #include "cgit.h" |
11 | #include "cache.h" | 11 | #include "cache.h" |
12 | #include "cmd.h" | 12 | #include "cmd.h" |
13 | #include "configfile.h" | 13 | #include "configfile.h" |
14 | #include "html.h" | 14 | #include "html.h" |
15 | #include "ui-shared.h" | 15 | #include "ui-shared.h" |
16 | #include "ui-stats.h" | 16 | #include "ui-stats.h" |
17 | #include "scan-tree.h" | 17 | #include "scan-tree.h" |
18 | 18 | ||
19 | const char *cgit_version = CGIT_VERSION; | 19 | const char *cgit_version = CGIT_VERSION; |
20 | 20 | ||
21 | void add_mimetype(const char *name, const char *value) | 21 | void add_mimetype(const char *name, const char *value) |
22 | { | 22 | { |
23 | struct string_list_item *item; | 23 | struct string_list_item *item; |
24 | 24 | ||
25 | item = string_list_insert(&ctx.cfg.mimetypes, xstrdup(name)); | 25 | item = string_list_insert(&ctx.cfg.mimetypes, xstrdup(name)); |
26 | item->util = xstrdup(value); | 26 | item->util = xstrdup(value); |
27 | } | 27 | } |
28 | 28 | ||
29 | struct cgit_filter *new_filter(const char *cmd, int extra_args) | 29 | struct cgit_filter *new_filter(const char *cmd, int extra_args) |
30 | { | 30 | { |
31 | struct cgit_filter *f; | 31 | struct cgit_filter *f; |
32 | 32 | ||
33 | if (!cmd || !cmd[0]) | 33 | if (!cmd || !cmd[0]) |
34 | return NULL; | 34 | return NULL; |
35 | 35 | ||
36 | f = xmalloc(sizeof(struct cgit_filter)); | 36 | f = xmalloc(sizeof(struct cgit_filter)); |
37 | f->cmd = xstrdup(cmd); | 37 | f->cmd = xstrdup(cmd); |
38 | f->argv = xmalloc((2 + extra_args) * sizeof(char *)); | 38 | f->argv = xmalloc((2 + extra_args) * sizeof(char *)); |
39 | f->argv[0] = f->cmd; | 39 | f->argv[0] = f->cmd; |
40 | f->argv[1] = NULL; | 40 | f->argv[1] = NULL; |
41 | return f; | 41 | return f; |
42 | } | 42 | } |
43 | 43 | ||
44 | static void process_cached_repolist(const char *path); | 44 | static void process_cached_repolist(const char *path); |
45 | 45 | ||
46 | void repo_config(struct cgit_repo *repo, const char *name, const char *value) | 46 | void repo_config(struct cgit_repo *repo, const char *name, const char *value) |
47 | { | 47 | { |
48 | if (!strcmp(name, "name")) | 48 | if (!strcmp(name, "name")) |
49 | repo->name = xstrdup(value); | 49 | repo->name = xstrdup(value); |
50 | else if (!strcmp(name, "clone-url")) | 50 | else if (!strcmp(name, "clone-url")) |
51 | repo->clone_url = xstrdup(value); | 51 | repo->clone_url = xstrdup(value); |
52 | else if (!strcmp(name, "desc")) | 52 | else if (!strcmp(name, "desc")) |
53 | repo->desc = xstrdup(value); | 53 | repo->desc = xstrdup(value); |
54 | else if (!strcmp(name, "owner")) | 54 | else if (!strcmp(name, "owner")) |
55 | repo->owner = xstrdup(value); | 55 | repo->owner = xstrdup(value); |
56 | else if (!strcmp(name, "defbranch")) | 56 | else if (!strcmp(name, "defbranch")) |
57 | repo->defbranch = xstrdup(value); | 57 | repo->defbranch = xstrdup(value); |
58 | else if (!strcmp(name, "snapshots")) | 58 | else if (!strcmp(name, "snapshots")) |
59 | repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); | 59 | repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); |
60 | else if (!strcmp(name, "enable-commit-graph")) | 60 | else if (!strcmp(name, "enable-commit-graph")) |
61 | repo->enable_commit_graph = ctx.cfg.enable_commit_graph * atoi(value); | 61 | repo->enable_commit_graph = ctx.cfg.enable_commit_graph * atoi(value); |
62 | else if (!strcmp(name, "enable-log-filecount")) | 62 | else if (!strcmp(name, "enable-log-filecount")) |
63 | repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); | 63 | repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); |
64 | else if (!strcmp(name, "enable-log-linecount")) | 64 | else if (!strcmp(name, "enable-log-linecount")) |
65 | repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); | 65 | repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); |
66 | else if (!strcmp(name, "enable-remote-branches")) | 66 | else if (!strcmp(name, "enable-remote-branches")) |
67 | repo->enable_remote_branches = atoi(value); | 67 | repo->enable_remote_branches = atoi(value); |
68 | else if (!strcmp(name, "enable-subject-links")) | 68 | else if (!strcmp(name, "enable-subject-links")) |
69 | repo->enable_subject_links = atoi(value); | 69 | repo->enable_subject_links = atoi(value); |
70 | else if (!strcmp(name, "max-stats")) | 70 | else if (!strcmp(name, "max-stats")) |
71 | repo->max_stats = cgit_find_stats_period(value, NULL); | 71 | repo->max_stats = cgit_find_stats_period(value, NULL); |
72 | else if (!strcmp(name, "module-link")) | 72 | else if (!strcmp(name, "module-link")) |
73 | repo->module_link= xstrdup(value); | 73 | repo->module_link= xstrdup(value); |
74 | else if (!strcmp(name, "section")) | 74 | else if (!strcmp(name, "section")) |
75 | repo->section = xstrdup(value); | 75 | repo->section = xstrdup(value); |
76 | else if (!strcmp(name, "readme") && value != NULL) { | 76 | else if (!strcmp(name, "readme") && value != NULL) |
77 | repo->readme = xstrdup(value); | 77 | repo->readme = xstrdup(value); |
78 | } else if (ctx.cfg.enable_filter_overrides) { | 78 | else if (!strcmp(name, "logo") && value != NULL) |
79 | repo->logo = xstrdup(value); | ||
80 | else if (!strcmp(name, "logo-link") && value != NULL) | ||
81 | repo->logo_link = xstrdup(value); | ||
82 | else if (ctx.cfg.enable_filter_overrides) { | ||
79 | if (!strcmp(name, "about-filter")) | 83 | if (!strcmp(name, "about-filter")) |
80 | repo->about_filter = new_filter(value, 0); | 84 | repo->about_filter = new_filter(value, 0); |
81 | else if (!strcmp(name, "commit-filter")) | 85 | else if (!strcmp(name, "commit-filter")) |
82 | repo->commit_filter = new_filter(value, 0); | 86 | repo->commit_filter = new_filter(value, 0); |
83 | else if (!strcmp(name, "source-filter")) | 87 | else if (!strcmp(name, "source-filter")) |
84 | repo->source_filter = new_filter(value, 1); | 88 | repo->source_filter = new_filter(value, 1); |
85 | } | 89 | } |
86 | } | 90 | } |
87 | 91 | ||
88 | void config_cb(const char *name, const char *value) | 92 | void config_cb(const char *name, const char *value) |
89 | { | 93 | { |
90 | if (!strcmp(name, "section") || !strcmp(name, "repo.group")) | 94 | if (!strcmp(name, "section") || !strcmp(name, "repo.group")) |
91 | ctx.cfg.section = xstrdup(value); | 95 | ctx.cfg.section = xstrdup(value); |
92 | else if (!strcmp(name, "repo.url")) | 96 | else if (!strcmp(name, "repo.url")) |
93 | ctx.repo = cgit_add_repo(value); | 97 | ctx.repo = cgit_add_repo(value); |
94 | else if (ctx.repo && !strcmp(name, "repo.path")) | 98 | else if (ctx.repo && !strcmp(name, "repo.path")) |
95 | ctx.repo->path = trim_end(value, '/'); | 99 | ctx.repo->path = trim_end(value, '/'); |
96 | else if (ctx.repo && !prefixcmp(name, "repo.")) | 100 | else if (ctx.repo && !prefixcmp(name, "repo.")) |
97 | repo_config(ctx.repo, name + 5, value); | 101 | repo_config(ctx.repo, name + 5, value); |
98 | else if (!strcmp(name, "readme")) | 102 | else if (!strcmp(name, "readme")) |
99 | ctx.cfg.readme = xstrdup(value); | 103 | ctx.cfg.readme = xstrdup(value); |
100 | else if (!strcmp(name, "root-title")) | 104 | else if (!strcmp(name, "root-title")) |
101 | ctx.cfg.root_title = xstrdup(value); | 105 | ctx.cfg.root_title = xstrdup(value); |
102 | else if (!strcmp(name, "root-desc")) | 106 | else if (!strcmp(name, "root-desc")) |
103 | ctx.cfg.root_desc = xstrdup(value); | 107 | ctx.cfg.root_desc = xstrdup(value); |
104 | else if (!strcmp(name, "root-readme")) | 108 | else if (!strcmp(name, "root-readme")) |
105 | ctx.cfg.root_readme = xstrdup(value); | 109 | ctx.cfg.root_readme = xstrdup(value); |
106 | else if (!strcmp(name, "css")) | 110 | else if (!strcmp(name, "css")) |
107 | ctx.cfg.css = xstrdup(value); | 111 | ctx.cfg.css = xstrdup(value); |
108 | else if (!strcmp(name, "favicon")) | 112 | else if (!strcmp(name, "favicon")) |
109 | ctx.cfg.favicon = xstrdup(value); | 113 | ctx.cfg.favicon = xstrdup(value); |
110 | else if (!strcmp(name, "footer")) | 114 | else if (!strcmp(name, "footer")) |
111 | ctx.cfg.footer = xstrdup(value); | 115 | ctx.cfg.footer = xstrdup(value); |
112 | else if (!strcmp(name, "head-include")) | 116 | else if (!strcmp(name, "head-include")) |
113 | ctx.cfg.head_include = xstrdup(value); | 117 | ctx.cfg.head_include = xstrdup(value); |
114 | else if (!strcmp(name, "header")) | 118 | else if (!strcmp(name, "header")) |
115 | ctx.cfg.header = xstrdup(value); | 119 | ctx.cfg.header = xstrdup(value); |
116 | else if (!strcmp(name, "logo")) | 120 | else if (!strcmp(name, "logo")) |
117 | ctx.cfg.logo = xstrdup(value); | 121 | ctx.cfg.logo = xstrdup(value); |
118 | else if (!strcmp(name, "index-header")) | 122 | else if (!strcmp(name, "index-header")) |
119 | ctx.cfg.index_header = xstrdup(value); | 123 | ctx.cfg.index_header = xstrdup(value); |
120 | else if (!strcmp(name, "index-info")) | 124 | else if (!strcmp(name, "index-info")) |
121 | ctx.cfg.index_info = xstrdup(value); | 125 | ctx.cfg.index_info = xstrdup(value); |
122 | else if (!strcmp(name, "logo-link")) | 126 | else if (!strcmp(name, "logo-link")) |
123 | ctx.cfg.logo_link = xstrdup(value); | 127 | ctx.cfg.logo_link = xstrdup(value); |
124 | else if (!strcmp(name, "module-link")) | 128 | else if (!strcmp(name, "module-link")) |
125 | ctx.cfg.module_link = xstrdup(value); | 129 | ctx.cfg.module_link = xstrdup(value); |
126 | else if (!strcmp(name, "strict-export")) | 130 | else if (!strcmp(name, "strict-export")) |
127 | ctx.cfg.strict_export = xstrdup(value); | 131 | ctx.cfg.strict_export = xstrdup(value); |
128 | else if (!strcmp(name, "virtual-root")) { | 132 | else if (!strcmp(name, "virtual-root")) { |
129 | ctx.cfg.virtual_root = trim_end(value, '/'); | 133 | ctx.cfg.virtual_root = trim_end(value, '/'); |
130 | if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) | 134 | if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) |
131 | ctx.cfg.virtual_root = ""; | 135 | ctx.cfg.virtual_root = ""; |
132 | } else if (!strcmp(name, "nocache")) | 136 | } else if (!strcmp(name, "nocache")) |
133 | ctx.cfg.nocache = atoi(value); | 137 | ctx.cfg.nocache = atoi(value); |
134 | else if (!strcmp(name, "noplainemail")) | 138 | else if (!strcmp(name, "noplainemail")) |
135 | ctx.cfg.noplainemail = atoi(value); | 139 | ctx.cfg.noplainemail = atoi(value); |
136 | else if (!strcmp(name, "noheader")) | 140 | else if (!strcmp(name, "noheader")) |
137 | ctx.cfg.noheader = atoi(value); | 141 | ctx.cfg.noheader = atoi(value); |
138 | else if (!strcmp(name, "snapshots")) | 142 | else if (!strcmp(name, "snapshots")) |
139 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); | 143 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); |
140 | else if (!strcmp(name, "enable-filter-overrides")) | 144 | else if (!strcmp(name, "enable-filter-overrides")) |
141 | ctx.cfg.enable_filter_overrides = atoi(value); | 145 | ctx.cfg.enable_filter_overrides = atoi(value); |
142 | else if (!strcmp(name, "enable-gitweb-owner")) | 146 | else if (!strcmp(name, "enable-gitweb-owner")) |
143 | ctx.cfg.enable_gitweb_owner = atoi(value); | 147 | ctx.cfg.enable_gitweb_owner = atoi(value); |
144 | else if (!strcmp(name, "enable-index-links")) | 148 | else if (!strcmp(name, "enable-index-links")) |
145 | ctx.cfg.enable_index_links = atoi(value); | 149 | ctx.cfg.enable_index_links = atoi(value); |
146 | else if (!strcmp(name, "enable-commit-graph")) | 150 | else if (!strcmp(name, "enable-commit-graph")) |
147 | ctx.cfg.enable_commit_graph = atoi(value); | 151 | ctx.cfg.enable_commit_graph = atoi(value); |
148 | else if (!strcmp(name, "enable-log-filecount")) | 152 | else if (!strcmp(name, "enable-log-filecount")) |
149 | ctx.cfg.enable_log_filecount = atoi(value); | 153 | ctx.cfg.enable_log_filecount = atoi(value); |
150 | else if (!strcmp(name, "enable-log-linecount")) | 154 | else if (!strcmp(name, "enable-log-linecount")) |
151 | ctx.cfg.enable_log_linecount = atoi(value); | 155 | ctx.cfg.enable_log_linecount = atoi(value); |
152 | else if (!strcmp(name, "enable-remote-branches")) | 156 | else if (!strcmp(name, "enable-remote-branches")) |
153 | ctx.cfg.enable_remote_branches = atoi(value); | 157 | ctx.cfg.enable_remote_branches = atoi(value); |
154 | else if (!strcmp(name, "enable-subject-links")) | 158 | else if (!strcmp(name, "enable-subject-links")) |
155 | ctx.cfg.enable_subject_links = atoi(value); | 159 | ctx.cfg.enable_subject_links = atoi(value); |
156 | else if (!strcmp(name, "enable-tree-linenumbers")) | 160 | else if (!strcmp(name, "enable-tree-linenumbers")) |
157 | ctx.cfg.enable_tree_linenumbers = atoi(value); | 161 | ctx.cfg.enable_tree_linenumbers = atoi(value); |
158 | else if (!strcmp(name, "max-stats")) | 162 | else if (!strcmp(name, "max-stats")) |
159 | ctx.cfg.max_stats = cgit_find_stats_period(value, NULL); | 163 | ctx.cfg.max_stats = cgit_find_stats_period(value, NULL); |
160 | else if (!strcmp(name, "cache-size")) | 164 | else if (!strcmp(name, "cache-size")) |
161 | ctx.cfg.cache_size = atoi(value); | 165 | ctx.cfg.cache_size = atoi(value); |
162 | else if (!strcmp(name, "cache-root")) | 166 | else if (!strcmp(name, "cache-root")) |
163 | ctx.cfg.cache_root = xstrdup(expand_macros(value)); | 167 | ctx.cfg.cache_root = xstrdup(expand_macros(value)); |
164 | else if (!strcmp(name, "cache-root-ttl")) | 168 | else if (!strcmp(name, "cache-root-ttl")) |
165 | ctx.cfg.cache_root_ttl = atoi(value); | 169 | ctx.cfg.cache_root_ttl = atoi(value); |
166 | else if (!strcmp(name, "cache-repo-ttl")) | 170 | else if (!strcmp(name, "cache-repo-ttl")) |
167 | ctx.cfg.cache_repo_ttl = atoi(value); | 171 | ctx.cfg.cache_repo_ttl = atoi(value); |
168 | else if (!strcmp(name, "cache-scanrc-ttl")) | 172 | else if (!strcmp(name, "cache-scanrc-ttl")) |
169 | ctx.cfg.cache_scanrc_ttl = atoi(value); | 173 | ctx.cfg.cache_scanrc_ttl = atoi(value); |
170 | else if (!strcmp(name, "cache-static-ttl")) | 174 | else if (!strcmp(name, "cache-static-ttl")) |
171 | ctx.cfg.cache_static_ttl = atoi(value); | 175 | ctx.cfg.cache_static_ttl = atoi(value); |
172 | else if (!strcmp(name, "cache-dynamic-ttl")) | 176 | else if (!strcmp(name, "cache-dynamic-ttl")) |
173 | ctx.cfg.cache_dynamic_ttl = atoi(value); | 177 | ctx.cfg.cache_dynamic_ttl = atoi(value); |
174 | else if (!strcmp(name, "about-filter")) | 178 | else if (!strcmp(name, "about-filter")) |
175 | ctx.cfg.about_filter = new_filter(value, 0); | 179 | ctx.cfg.about_filter = new_filter(value, 0); |
176 | else if (!strcmp(name, "commit-filter")) | 180 | else if (!strcmp(name, "commit-filter")) |
177 | ctx.cfg.commit_filter = new_filter(value, 0); | 181 | ctx.cfg.commit_filter = new_filter(value, 0); |
178 | else if (!strcmp(name, "embedded")) | 182 | else if (!strcmp(name, "embedded")) |
179 | ctx.cfg.embedded = atoi(value); | 183 | ctx.cfg.embedded = atoi(value); |
180 | else if (!strcmp(name, "max-atom-items")) | 184 | else if (!strcmp(name, "max-atom-items")) |
181 | ctx.cfg.max_atom_items = atoi(value); | 185 | ctx.cfg.max_atom_items = atoi(value); |
182 | else if (!strcmp(name, "max-message-length")) | 186 | else if (!strcmp(name, "max-message-length")) |
183 | ctx.cfg.max_msg_len = atoi(value); | 187 | ctx.cfg.max_msg_len = atoi(value); |
184 | else if (!strcmp(name, "max-repodesc-length")) | 188 | else if (!strcmp(name, "max-repodesc-length")) |
185 | ctx.cfg.max_repodesc_len = atoi(value); | 189 | ctx.cfg.max_repodesc_len = atoi(value); |
186 | else if (!strcmp(name, "max-blob-size")) | 190 | else if (!strcmp(name, "max-blob-size")) |
187 | ctx.cfg.max_blob_size = atoi(value); | 191 | ctx.cfg.max_blob_size = atoi(value); |
188 | else if (!strcmp(name, "max-repo-count")) | 192 | else if (!strcmp(name, "max-repo-count")) |
189 | ctx.cfg.max_repo_count = atoi(value); | 193 | ctx.cfg.max_repo_count = atoi(value); |
190 | else if (!strcmp(name, "max-commit-count")) | 194 | else if (!strcmp(name, "max-commit-count")) |
191 | ctx.cfg.max_commit_count = atoi(value); | 195 | ctx.cfg.max_commit_count = atoi(value); |
192 | else if (!strcmp(name, "project-list")) | 196 | else if (!strcmp(name, "project-list")) |
193 | ctx.cfg.project_list = xstrdup(expand_macros(value)); | 197 | ctx.cfg.project_list = xstrdup(expand_macros(value)); |
194 | else if (!strcmp(name, "scan-path")) | 198 | else if (!strcmp(name, "scan-path")) |
195 | if (!ctx.cfg.nocache && ctx.cfg.cache_size) | 199 | if (!ctx.cfg.nocache && ctx.cfg.cache_size) |
196 | process_cached_repolist(expand_macros(value)); | 200 | process_cached_repolist(expand_macros(value)); |
197 | else if (ctx.cfg.project_list) | 201 | else if (ctx.cfg.project_list) |
198 | scan_projects(expand_macros(value), | 202 | scan_projects(expand_macros(value), |
199 | ctx.cfg.project_list, repo_config); | 203 | ctx.cfg.project_list, repo_config); |
200 | else | 204 | else |
201 | scan_tree(expand_macros(value), repo_config); | 205 | scan_tree(expand_macros(value), repo_config); |
202 | else if (!strcmp(name, "scan-hidden-path")) | 206 | else if (!strcmp(name, "scan-hidden-path")) |
203 | ctx.cfg.scan_hidden_path = atoi(value); | 207 | ctx.cfg.scan_hidden_path = atoi(value); |
204 | else if (!strcmp(name, "section-from-path")) | 208 | else if (!strcmp(name, "section-from-path")) |
205 | ctx.cfg.section_from_path = atoi(value); | 209 | ctx.cfg.section_from_path = atoi(value); |
206 | else if (!strcmp(name, "source-filter")) | 210 | else if (!strcmp(name, "source-filter")) |
207 | ctx.cfg.source_filter = new_filter(value, 1); | 211 | ctx.cfg.source_filter = new_filter(value, 1); |
208 | else if (!strcmp(name, "summary-log")) | 212 | else if (!strcmp(name, "summary-log")) |
209 | ctx.cfg.summary_log = atoi(value); | 213 | ctx.cfg.summary_log = atoi(value); |
210 | else if (!strcmp(name, "summary-branches")) | 214 | else if (!strcmp(name, "summary-branches")) |
211 | ctx.cfg.summary_branches = atoi(value); | 215 | ctx.cfg.summary_branches = atoi(value); |
212 | else if (!strcmp(name, "summary-tags")) | 216 | else if (!strcmp(name, "summary-tags")) |
213 | ctx.cfg.summary_tags = atoi(value); | 217 | ctx.cfg.summary_tags = atoi(value); |
214 | else if (!strcmp(name, "side-by-side-diffs")) | 218 | else if (!strcmp(name, "side-by-side-diffs")) |
215 | ctx.cfg.ssdiff = atoi(value); | 219 | ctx.cfg.ssdiff = atoi(value); |
216 | else if (!strcmp(name, "agefile")) | 220 | else if (!strcmp(name, "agefile")) |
217 | ctx.cfg.agefile = xstrdup(value); | 221 | ctx.cfg.agefile = xstrdup(value); |
218 | else if (!strcmp(name, "renamelimit")) | 222 | else if (!strcmp(name, "renamelimit")) |
219 | ctx.cfg.renamelimit = atoi(value); | 223 | ctx.cfg.renamelimit = atoi(value); |
220 | else if (!strcmp(name, "remove-suffix")) | 224 | else if (!strcmp(name, "remove-suffix")) |
221 | ctx.cfg.remove_suffix = atoi(value); | 225 | ctx.cfg.remove_suffix = atoi(value); |
222 | else if (!strcmp(name, "robots")) | 226 | else if (!strcmp(name, "robots")) |
223 | ctx.cfg.robots = xstrdup(value); | 227 | ctx.cfg.robots = xstrdup(value); |
224 | else if (!strcmp(name, "clone-prefix")) | 228 | else if (!strcmp(name, "clone-prefix")) |
225 | ctx.cfg.clone_prefix = xstrdup(value); | 229 | ctx.cfg.clone_prefix = xstrdup(value); |
226 | else if (!strcmp(name, "local-time")) | 230 | else if (!strcmp(name, "local-time")) |
227 | ctx.cfg.local_time = atoi(value); | 231 | ctx.cfg.local_time = atoi(value); |
228 | else if (!prefixcmp(name, "mimetype.")) | 232 | else if (!prefixcmp(name, "mimetype.")) |
229 | add_mimetype(name + 9, value); | 233 | add_mimetype(name + 9, value); |
230 | else if (!strcmp(name, "include")) | 234 | else if (!strcmp(name, "include")) |
231 | parse_configfile(expand_macros(value), config_cb); | 235 | parse_configfile(expand_macros(value), config_cb); |
232 | } | 236 | } |
233 | 237 | ||
234 | static void querystring_cb(const char *name, const char *value) | 238 | static void querystring_cb(const char *name, const char *value) |
235 | { | 239 | { |
236 | if (!value) | 240 | if (!value) |
237 | value = ""; | 241 | value = ""; |
238 | 242 | ||
239 | if (!strcmp(name,"r")) { | 243 | if (!strcmp(name,"r")) { |
240 | ctx.qry.repo = xstrdup(value); | 244 | ctx.qry.repo = xstrdup(value); |
241 | ctx.repo = cgit_get_repoinfo(value); | 245 | ctx.repo = cgit_get_repoinfo(value); |
242 | } else if (!strcmp(name, "p")) { | 246 | } else if (!strcmp(name, "p")) { |
243 | ctx.qry.page = xstrdup(value); | 247 | ctx.qry.page = xstrdup(value); |
244 | } else if (!strcmp(name, "url")) { | 248 | } else if (!strcmp(name, "url")) { |
245 | if (*value == '/') | 249 | if (*value == '/') |
246 | value++; | 250 | value++; |
247 | ctx.qry.url = xstrdup(value); | 251 | ctx.qry.url = xstrdup(value); |
248 | cgit_parse_url(value); | 252 | cgit_parse_url(value); |
249 | } else if (!strcmp(name, "qt")) { | 253 | } else if (!strcmp(name, "qt")) { |
250 | ctx.qry.grep = xstrdup(value); | 254 | ctx.qry.grep = xstrdup(value); |
251 | } else if (!strcmp(name, "q")) { | 255 | } else if (!strcmp(name, "q")) { |
252 | ctx.qry.search = xstrdup(value); | 256 | ctx.qry.search = xstrdup(value); |
253 | } else if (!strcmp(name, "h")) { | 257 | } else if (!strcmp(name, "h")) { |
254 | ctx.qry.head = xstrdup(value); | 258 | ctx.qry.head = xstrdup(value); |
255 | ctx.qry.has_symref = 1; | 259 | ctx.qry.has_symref = 1; |
256 | } else if (!strcmp(name, "id")) { | 260 | } else if (!strcmp(name, "id")) { |
257 | ctx.qry.sha1 = xstrdup(value); | 261 | ctx.qry.sha1 = xstrdup(value); |
258 | ctx.qry.has_sha1 = 1; | 262 | ctx.qry.has_sha1 = 1; |
259 | } else if (!strcmp(name, "id2")) { | 263 | } else if (!strcmp(name, "id2")) { |
260 | ctx.qry.sha2 = xstrdup(value); | 264 | ctx.qry.sha2 = xstrdup(value); |
261 | ctx.qry.has_sha1 = 1; | 265 | ctx.qry.has_sha1 = 1; |
262 | } else if (!strcmp(name, "ofs")) { | 266 | } else if (!strcmp(name, "ofs")) { |
263 | ctx.qry.ofs = atoi(value); | 267 | ctx.qry.ofs = atoi(value); |
264 | } else if (!strcmp(name, "path")) { | 268 | } else if (!strcmp(name, "path")) { |
265 | ctx.qry.path = trim_end(value, '/'); | 269 | ctx.qry.path = trim_end(value, '/'); |
266 | } else if (!strcmp(name, "name")) { | 270 | } else if (!strcmp(name, "name")) { |
267 | ctx.qry.name = xstrdup(value); | 271 | ctx.qry.name = xstrdup(value); |
268 | } else if (!strcmp(name, "mimetype")) { | 272 | } else if (!strcmp(name, "mimetype")) { |
269 | ctx.qry.mimetype = xstrdup(value); | 273 | ctx.qry.mimetype = xstrdup(value); |
270 | } else if (!strcmp(name, "s")){ | 274 | } else if (!strcmp(name, "s")){ |
271 | ctx.qry.sort = xstrdup(value); | 275 | ctx.qry.sort = xstrdup(value); |
272 | } else if (!strcmp(name, "showmsg")) { | 276 | } else if (!strcmp(name, "showmsg")) { |
273 | ctx.qry.showmsg = atoi(value); | 277 | ctx.qry.showmsg = atoi(value); |
274 | } else if (!strcmp(name, "period")) { | 278 | } else if (!strcmp(name, "period")) { |
275 | ctx.qry.period = xstrdup(value); | 279 | ctx.qry.period = xstrdup(value); |
276 | } else if (!strcmp(name, "ss")) { | 280 | } else if (!strcmp(name, "ss")) { |
277 | ctx.qry.ssdiff = atoi(value); | 281 | ctx.qry.ssdiff = atoi(value); |
278 | } else if (!strcmp(name, "all")) { | 282 | } else if (!strcmp(name, "all")) { |
279 | ctx.qry.show_all = atoi(value); | 283 | ctx.qry.show_all = atoi(value); |
280 | } else if (!strcmp(name, "context")) { | 284 | } else if (!strcmp(name, "context")) { |
281 | ctx.qry.context = atoi(value); | 285 | ctx.qry.context = atoi(value); |
282 | } else if (!strcmp(name, "ignorews")) { | 286 | } else if (!strcmp(name, "ignorews")) { |
283 | ctx.qry.ignorews = atoi(value); | 287 | ctx.qry.ignorews = atoi(value); |
284 | } | 288 | } |
285 | } | 289 | } |
286 | 290 | ||
287 | char *xstrdupn(const char *str) | 291 | char *xstrdupn(const char *str) |
288 | { | 292 | { |
289 | return (str ? xstrdup(str) : NULL); | 293 | return (str ? xstrdup(str) : NULL); |
290 | } | 294 | } |
291 | 295 | ||
292 | static void prepare_context(struct cgit_context *ctx) | 296 | static void prepare_context(struct cgit_context *ctx) |
293 | { | 297 | { |
294 | memset(ctx, 0, sizeof(*ctx)); | 298 | memset(ctx, 0, sizeof(*ctx)); |
295 | ctx->cfg.agefile = "info/web/last-modified"; | 299 | ctx->cfg.agefile = "info/web/last-modified"; |
296 | ctx->cfg.nocache = 0; | 300 | ctx->cfg.nocache = 0; |
297 | ctx->cfg.cache_size = 0; | 301 | ctx->cfg.cache_size = 0; |
298 | ctx->cfg.cache_dynamic_ttl = 5; | 302 | ctx->cfg.cache_dynamic_ttl = 5; |
299 | ctx->cfg.cache_max_create_time = 5; | 303 | ctx->cfg.cache_max_create_time = 5; |
300 | ctx->cfg.cache_repo_ttl = 5; | 304 | ctx->cfg.cache_repo_ttl = 5; |
301 | ctx->cfg.cache_root = CGIT_CACHE_ROOT; | 305 | ctx->cfg.cache_root = CGIT_CACHE_ROOT; |
302 | ctx->cfg.cache_root_ttl = 5; | 306 | ctx->cfg.cache_root_ttl = 5; |
303 | ctx->cfg.cache_scanrc_ttl = 15; | 307 | ctx->cfg.cache_scanrc_ttl = 15; |
304 | ctx->cfg.cache_static_ttl = -1; | 308 | ctx->cfg.cache_static_ttl = -1; |
305 | ctx->cfg.css = "/cgit.css"; | 309 | ctx->cfg.css = "/cgit.css"; |
306 | ctx->cfg.logo = "/cgit.png"; | 310 | ctx->cfg.logo = "/cgit.png"; |
307 | ctx->cfg.local_time = 0; | 311 | ctx->cfg.local_time = 0; |
308 | ctx->cfg.enable_gitweb_owner = 1; | 312 | ctx->cfg.enable_gitweb_owner = 1; |
309 | ctx->cfg.enable_tree_linenumbers = 1; | 313 | ctx->cfg.enable_tree_linenumbers = 1; |
310 | ctx->cfg.max_repo_count = 50; | 314 | ctx->cfg.max_repo_count = 50; |
311 | ctx->cfg.max_commit_count = 50; | 315 | ctx->cfg.max_commit_count = 50; |
312 | ctx->cfg.max_lock_attempts = 5; | 316 | ctx->cfg.max_lock_attempts = 5; |
313 | ctx->cfg.max_msg_len = 80; | 317 | ctx->cfg.max_msg_len = 80; |
314 | ctx->cfg.max_repodesc_len = 80; | 318 | ctx->cfg.max_repodesc_len = 80; |
315 | ctx->cfg.max_blob_size = 0; | 319 | ctx->cfg.max_blob_size = 0; |
316 | ctx->cfg.max_stats = 0; | 320 | ctx->cfg.max_stats = 0; |
317 | ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; | 321 | ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; |
318 | ctx->cfg.project_list = NULL; | 322 | ctx->cfg.project_list = NULL; |
319 | ctx->cfg.renamelimit = -1; | 323 | ctx->cfg.renamelimit = -1; |
320 | ctx->cfg.remove_suffix = 0; | 324 | ctx->cfg.remove_suffix = 0; |
321 | ctx->cfg.robots = "index, nofollow"; | 325 | ctx->cfg.robots = "index, nofollow"; |
322 | ctx->cfg.root_title = "Git repository browser"; | 326 | ctx->cfg.root_title = "Git repository browser"; |
323 | ctx->cfg.root_desc = "a fast webinterface for the git dscm"; | 327 | ctx->cfg.root_desc = "a fast webinterface for the git dscm"; |
324 | ctx->cfg.scan_hidden_path = 0; | 328 | ctx->cfg.scan_hidden_path = 0; |
325 | ctx->cfg.script_name = CGIT_SCRIPT_NAME; | 329 | ctx->cfg.script_name = CGIT_SCRIPT_NAME; |
326 | ctx->cfg.section = ""; | 330 | ctx->cfg.section = ""; |
327 | ctx->cfg.summary_branches = 10; | 331 | ctx->cfg.summary_branches = 10; |
328 | ctx->cfg.summary_log = 10; | 332 | ctx->cfg.summary_log = 10; |
329 | ctx->cfg.summary_tags = 10; | 333 | ctx->cfg.summary_tags = 10; |
330 | ctx->cfg.max_atom_items = 10; | 334 | ctx->cfg.max_atom_items = 10; |
331 | ctx->cfg.ssdiff = 0; | 335 | ctx->cfg.ssdiff = 0; |
332 | ctx->env.cgit_config = xstrdupn(getenv("CGIT_CONFIG")); | 336 | ctx->env.cgit_config = xstrdupn(getenv("CGIT_CONFIG")); |
333 | ctx->env.http_host = xstrdupn(getenv("HTTP_HOST")); | 337 | ctx->env.http_host = xstrdupn(getenv("HTTP_HOST")); |
334 | ctx->env.https = xstrdupn(getenv("HTTPS")); | 338 | ctx->env.https = xstrdupn(getenv("HTTPS")); |
335 | ctx->env.no_http = xstrdupn(getenv("NO_HTTP")); | 339 | ctx->env.no_http = xstrdupn(getenv("NO_HTTP")); |
336 | ctx->env.path_info = xstrdupn(getenv("PATH_INFO")); | 340 | ctx->env.path_info = xstrdupn(getenv("PATH_INFO")); |
337 | ctx->env.query_string = xstrdupn(getenv("QUERY_STRING")); | 341 | ctx->env.query_string = xstrdupn(getenv("QUERY_STRING")); |
338 | ctx->env.request_method = xstrdupn(getenv("REQUEST_METHOD")); | 342 | ctx->env.request_method = xstrdupn(getenv("REQUEST_METHOD")); |
339 | ctx->env.script_name = xstrdupn(getenv("SCRIPT_NAME")); | 343 | ctx->env.script_name = xstrdupn(getenv("SCRIPT_NAME")); |
340 | ctx->env.server_name = xstrdupn(getenv("SERVER_NAME")); | 344 | ctx->env.server_name = xstrdupn(getenv("SERVER_NAME")); |
341 | ctx->env.server_port = xstrdupn(getenv("SERVER_PORT")); | 345 | ctx->env.server_port = xstrdupn(getenv("SERVER_PORT")); |
342 | ctx->page.mimetype = "text/html"; | 346 | ctx->page.mimetype = "text/html"; |
343 | ctx->page.charset = PAGE_ENCODING; | 347 | ctx->page.charset = PAGE_ENCODING; |
344 | ctx->page.filename = NULL; | 348 | ctx->page.filename = NULL; |
345 | ctx->page.size = 0; | 349 | ctx->page.size = 0; |
346 | ctx->page.modified = time(NULL); | 350 | ctx->page.modified = time(NULL); |
347 | ctx->page.expires = ctx->page.modified; | 351 | ctx->page.expires = ctx->page.modified; |
348 | ctx->page.etag = NULL; | 352 | ctx->page.etag = NULL; |
349 | memset(&ctx->cfg.mimetypes, 0, sizeof(struct string_list)); | 353 | memset(&ctx->cfg.mimetypes, 0, sizeof(struct string_list)); |
350 | if (ctx->env.script_name) | 354 | if (ctx->env.script_name) |
351 | ctx->cfg.script_name = ctx->env.script_name; | 355 | ctx->cfg.script_name = ctx->env.script_name; |
352 | if (ctx->env.query_string) | 356 | if (ctx->env.query_string) |
353 | ctx->qry.raw = ctx->env.query_string; | 357 | ctx->qry.raw = ctx->env.query_string; |
354 | if (!ctx->env.cgit_config) | 358 | if (!ctx->env.cgit_config) |
355 | ctx->env.cgit_config = CGIT_CONFIG; | 359 | ctx->env.cgit_config = CGIT_CONFIG; |
356 | } | 360 | } |
357 | 361 | ||
358 | struct refmatch { | 362 | struct refmatch { |
359 | char *req_ref; | 363 | char *req_ref; |
360 | char *first_ref; | 364 | char *first_ref; |
361 | int match; | 365 | int match; |
362 | }; | 366 | }; |
363 | 367 | ||
364 | int find_current_ref(const char *refname, const unsigned char *sha1, | 368 | int find_current_ref(const char *refname, const unsigned char *sha1, |
365 | int flags, void *cb_data) | 369 | int flags, void *cb_data) |
366 | { | 370 | { |
367 | struct refmatch *info; | 371 | struct refmatch *info; |
368 | 372 | ||
369 | info = (struct refmatch *)cb_data; | 373 | info = (struct refmatch *)cb_data; |
370 | if (!strcmp(refname, info->req_ref)) | 374 | if (!strcmp(refname, info->req_ref)) |
371 | info->match = 1; | 375 | info->match = 1; |
372 | if (!info->first_ref) | 376 | if (!info->first_ref) |
373 | info->first_ref = xstrdup(refname); | 377 | info->first_ref = xstrdup(refname); |
374 | return info->match; | 378 | return info->match; |
375 | } | 379 | } |
376 | 380 | ||
377 | char *find_default_branch(struct cgit_repo *repo) | 381 | char *find_default_branch(struct cgit_repo *repo) |
378 | { | 382 | { |
379 | struct refmatch info; | 383 | struct refmatch info; |
380 | char *ref; | 384 | char *ref; |
381 | 385 | ||
382 | info.req_ref = repo->defbranch; | 386 | info.req_ref = repo->defbranch; |
383 | info.first_ref = NULL; | 387 | info.first_ref = NULL; |
384 | info.match = 0; | 388 | info.match = 0; |
385 | for_each_branch_ref(find_current_ref, &info); | 389 | for_each_branch_ref(find_current_ref, &info); |
386 | if (info.match) | 390 | if (info.match) |
387 | ref = info.req_ref; | 391 | ref = info.req_ref; |
388 | else | 392 | else |
389 | ref = info.first_ref; | 393 | ref = info.first_ref; |
390 | if (ref) | 394 | if (ref) |
391 | ref = xstrdup(ref); | 395 | ref = xstrdup(ref); |
392 | return ref; | 396 | return ref; |
393 | } | 397 | } |
394 | 398 | ||
395 | static int prepare_repo_cmd(struct cgit_context *ctx) | 399 | static int prepare_repo_cmd(struct cgit_context *ctx) |
396 | { | 400 | { |
397 | char *tmp; | 401 | char *tmp; |
398 | unsigned char sha1[20]; | 402 | unsigned char sha1[20]; |
399 | int nongit = 0; | 403 | int nongit = 0; |
400 | 404 | ||
401 | setenv("GIT_DIR", ctx->repo->path, 1); | 405 | setenv("GIT_DIR", ctx->repo->path, 1); |
402 | setup_git_directory_gently(&nongit); | 406 | setup_git_directory_gently(&nongit); |
403 | if (nongit) { | 407 | if (nongit) { |
404 | ctx->page.title = fmt("%s - %s", ctx->cfg.root_title, | 408 | ctx->page.title = fmt("%s - %s", ctx->cfg.root_title, |
405 | "config error"); | 409 | "config error"); |
406 | tmp = fmt("Not a git repository: '%s'", ctx->repo->path); | 410 | tmp = fmt("Not a git repository: '%s'", ctx->repo->path); |
407 | ctx->repo = NULL; | 411 | ctx->repo = NULL; |
408 | cgit_print_http_headers(ctx); | 412 | cgit_print_http_headers(ctx); |
409 | cgit_print_docstart(ctx); | 413 | cgit_print_docstart(ctx); |
410 | cgit_print_pageheader(ctx); | 414 | cgit_print_pageheader(ctx); |
411 | cgit_print_error(tmp); | 415 | cgit_print_error(tmp); |
412 | cgit_print_docend(); | 416 | cgit_print_docend(); |
413 | return 1; | 417 | return 1; |
414 | } | 418 | } |
415 | ctx->page.title = fmt("%s - %s", ctx->repo->name, ctx->repo->desc); | 419 | ctx->page.title = fmt("%s - %s", ctx->repo->name, ctx->repo->desc); |
416 | 420 | ||
417 | if (!ctx->qry.head) { | 421 | if (!ctx->qry.head) { |
418 | ctx->qry.nohead = 1; | 422 | ctx->qry.nohead = 1; |
419 | ctx->qry.head = find_default_branch(ctx->repo); | 423 | ctx->qry.head = find_default_branch(ctx->repo); |
420 | ctx->repo->defbranch = ctx->qry.head; | 424 | ctx->repo->defbranch = ctx->qry.head; |
421 | } | 425 | } |
422 | 426 | ||
423 | if (!ctx->qry.head) { | 427 | if (!ctx->qry.head) { |
424 | cgit_print_http_headers(ctx); | 428 | cgit_print_http_headers(ctx); |
425 | cgit_print_docstart(ctx); | 429 | cgit_print_docstart(ctx); |
426 | cgit_print_pageheader(ctx); | 430 | cgit_print_pageheader(ctx); |
427 | cgit_print_error("Repository seems to be empty"); | 431 | cgit_print_error("Repository seems to be empty"); |
428 | cgit_print_docend(); | 432 | cgit_print_docend(); |
429 | return 1; | 433 | return 1; |
430 | } | 434 | } |
431 | 435 | ||
432 | if (get_sha1(ctx->qry.head, sha1)) { | 436 | if (get_sha1(ctx->qry.head, sha1)) { |
433 | tmp = xstrdup(ctx->qry.head); | 437 | tmp = xstrdup(ctx->qry.head); |
434 | ctx->qry.head = ctx->repo->defbranch; | 438 | ctx->qry.head = ctx->repo->defbranch; |
435 | ctx->page.status = 404; | 439 | ctx->page.status = 404; |
436 | ctx->page.statusmsg = "not found"; | 440 | ctx->page.statusmsg = "not found"; |
437 | cgit_print_http_headers(ctx); | 441 | cgit_print_http_headers(ctx); |
438 | cgit_print_docstart(ctx); | 442 | cgit_print_docstart(ctx); |
439 | cgit_print_pageheader(ctx); | 443 | cgit_print_pageheader(ctx); |
440 | cgit_print_error(fmt("Invalid branch: %s", tmp)); | 444 | cgit_print_error(fmt("Invalid branch: %s", tmp)); |
441 | cgit_print_docend(); | 445 | cgit_print_docend(); |
442 | return 1; | 446 | return 1; |
443 | } | 447 | } |
444 | return 0; | 448 | return 0; |
445 | } | 449 | } |
446 | 450 | ||
447 | static void process_request(void *cbdata) | 451 | static void process_request(void *cbdata) |
448 | { | 452 | { |
449 | struct cgit_context *ctx = cbdata; | 453 | struct cgit_context *ctx = cbdata; |
450 | struct cgit_cmd *cmd; | 454 | struct cgit_cmd *cmd; |
451 | 455 | ||
452 | cmd = cgit_get_cmd(ctx); | 456 | cmd = cgit_get_cmd(ctx); |
453 | if (!cmd) { | 457 | if (!cmd) { |
454 | ctx->page.title = "cgit error"; | 458 | ctx->page.title = "cgit error"; |
455 | cgit_print_http_headers(ctx); | 459 | cgit_print_http_headers(ctx); |
456 | cgit_print_docstart(ctx); | 460 | cgit_print_docstart(ctx); |
457 | cgit_print_pageheader(ctx); | 461 | cgit_print_pageheader(ctx); |
458 | cgit_print_error("Invalid request"); | 462 | cgit_print_error("Invalid request"); |
459 | cgit_print_docend(); | 463 | cgit_print_docend(); |
460 | return; | 464 | return; |
461 | } | 465 | } |
462 | 466 | ||
@@ -1,680 +1,680 @@ | |||
1 | body, table, form { | 1 | body, table, form { |
2 | padding: 0em; | 2 | padding: 0em; |
3 | margin: 0em; | 3 | margin: 0em; |
4 | } | 4 | } |
5 | 5 | ||
6 | body { | 6 | body { |
7 | font-family: sans-serif; | 7 | font-family: sans-serif; |
8 | font-size: 10pt; | 8 | font-size: 10pt; |
9 | color: #333; | 9 | color: #333; |
10 | background: white; | 10 | background: white; |
11 | padding: 4px; | 11 | padding: 4px; |
12 | } | 12 | } |
13 | 13 | ||
14 | a { | 14 | a { |
15 | color: blue; | 15 | color: blue; |
16 | text-decoration: none; | 16 | text-decoration: none; |
17 | } | 17 | } |
18 | 18 | ||
19 | a:hover { | 19 | a:hover { |
20 | text-decoration: underline; | 20 | text-decoration: underline; |
21 | } | 21 | } |
22 | 22 | ||
23 | table { | 23 | table { |
24 | border-collapse: collapse; | 24 | border-collapse: collapse; |
25 | } | 25 | } |
26 | 26 | ||
27 | table#header { | 27 | table#header { |
28 | width: 100%; | 28 | width: 100%; |
29 | margin-bottom: 1em; | 29 | margin-bottom: 1em; |
30 | } | 30 | } |
31 | 31 | ||
32 | table#header td.logo { | 32 | table#header td.logo { |
33 | width: 96px; | 33 | width: 96px; |
34 | } | 34 | } |
35 | 35 | ||
36 | table#header td.main { | 36 | table#header td.main { |
37 | font-size: 250%; | 37 | font-size: 250%; |
38 | padding-left: 10px; | 38 | padding-left: 10px; |
39 | white-space: nowrap; | 39 | white-space: nowrap; |
40 | } | 40 | } |
41 | 41 | ||
42 | table#header td.main a { | 42 | table#header td.main a { |
43 | color: #000; | 43 | color: #000; |
44 | } | 44 | } |
45 | 45 | ||
46 | table#header td.form { | 46 | table#header td.form { |
47 | text-align: right; | 47 | text-align: right; |
48 | vertical-align: bottom; | 48 | vertical-align: bottom; |
49 | padding-right: 1em; | 49 | padding-right: 1em; |
50 | padding-bottom: 2px; | 50 | padding-bottom: 2px; |
51 | white-space: nowrap; | 51 | white-space: nowrap; |
52 | } | 52 | } |
53 | 53 | ||
54 | table#header td.form form, | 54 | table#header td.form form, |
55 | table#header td.form input, | 55 | table#header td.form input, |
56 | table#header td.form select { | 56 | table#header td.form select { |
57 | font-size: 90%; | 57 | font-size: 90%; |
58 | } | 58 | } |
59 | 59 | ||
60 | table#header td.sub { | 60 | table#header td.sub { |
61 | color: #777; | 61 | color: #777; |
62 | border-top: solid 1px #ccc; | 62 | border-top: solid 1px #ccc; |
63 | padding-left: 10px; | 63 | padding-left: 10px; |
64 | } | 64 | } |
65 | 65 | ||
66 | table.tabs { | 66 | table.tabs { |
67 | border-bottom: solid 3px #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; |
71 | width: 100%; | 71 | width: 100%; |
72 | } | 72 | } |
73 | 73 | ||
74 | table.tabs td { | 74 | table.tabs td { |
75 | padding: 0px 1em; | 75 | padding: 0px 1em; |
76 | vertical-align: bottom; | 76 | vertical-align: bottom; |
77 | } | 77 | } |
78 | 78 | ||
79 | table.tabs td a { | 79 | table.tabs td a { |
80 | padding: 2px 0.75em; | 80 | padding: 2px 0.75em; |
81 | color: #777; | 81 | color: #777; |
82 | font-size: 110%; | 82 | font-size: 110%; |
83 | } | 83 | } |
84 | 84 | ||
85 | table.tabs td a.active { | 85 | table.tabs td a.active { |
86 | color: #000; | 86 | color: #000; |
87 | background-color: #ccc; | 87 | background-color: #ccc; |
88 | } | 88 | } |
89 | 89 | ||
90 | table.tabs td.form { | 90 | table.tabs td.form { |
91 | text-align: right; | 91 | text-align: right; |
92 | } | 92 | } |
93 | 93 | ||
94 | table.tabs td.form form { | 94 | table.tabs td.form form { |
95 | padding-bottom: 2px; | 95 | padding-bottom: 2px; |
96 | font-size: 90%; | 96 | font-size: 90%; |
97 | white-space: nowrap; | 97 | white-space: nowrap; |
98 | } | 98 | } |
99 | 99 | ||
100 | table.tabs td.form input, | 100 | table.tabs td.form input, |
101 | table.tabs td.form select { | 101 | table.tabs td.form select { |
102 | font-size: 90%; | 102 | font-size: 90%; |
103 | } | 103 | } |
104 | 104 | ||
105 | div.path { | 105 | div.path { |
106 | margin: 0px; | 106 | margin: 0px; |
107 | padding: 5px 2em 2px 2em; | 107 | padding: 5px 2em 2px 2em; |
108 | color: #000; | 108 | color: #000; |
109 | background-color: #eee; | 109 | background-color: #eee; |
110 | } | 110 | } |
111 | 111 | ||
112 | div.content { | 112 | div.content { |
113 | margin: 0px; | 113 | margin: 0px; |
114 | padding: 2em; | 114 | padding: 2em; |
115 | border-bottom: solid 3px #ccc; | 115 | border-bottom: solid 3px #ccc; |
116 | } | 116 | } |
117 | 117 | ||
118 | 118 | ||
119 | table.list { | 119 | table.list { |
120 | width: 100%; | 120 | width: 100%; |
121 | border: none; | 121 | border: none; |
122 | border-collapse: collapse; | 122 | border-collapse: collapse; |
123 | } | 123 | } |
124 | 124 | ||
125 | table.list tr { | 125 | table.list tr { |
126 | background: white; | 126 | background: white; |
127 | } | 127 | } |
128 | 128 | ||
129 | table.list tr.logheader { | 129 | table.list tr.logheader { |
130 | background: #eee; | 130 | background: #eee; |
131 | } | 131 | } |
132 | 132 | ||
133 | table.list tr:hover { | 133 | table.list tr:hover { |
134 | background: #eee; | 134 | background: #eee; |
135 | } | 135 | } |
136 | 136 | ||
137 | table.list tr.nohover:hover { | 137 | table.list tr.nohover:hover { |
138 | background: white; | 138 | background: white; |
139 | } | 139 | } |
140 | 140 | ||
141 | table.list th { | 141 | table.list th { |
142 | font-weight: bold; | 142 | font-weight: bold; |
143 | /* color: #888; | 143 | /* color: #888; |
144 | border-top: dashed 1px #888; | 144 | border-top: dashed 1px #888; |
145 | border-bottom: dashed 1px #888; | 145 | border-bottom: dashed 1px #888; |
146 | */ | 146 | */ |
147 | padding: 0.1em 0.5em 0.05em 0.5em; | 147 | padding: 0.1em 0.5em 0.05em 0.5em; |
148 | vertical-align: baseline; | 148 | vertical-align: baseline; |
149 | } | 149 | } |
150 | 150 | ||
151 | table.list td { | 151 | table.list td { |
152 | border: none; | 152 | border: none; |
153 | padding: 0.1em 0.5em 0.1em 0.5em; | 153 | padding: 0.1em 0.5em 0.1em 0.5em; |
154 | } | 154 | } |
155 | 155 | ||
156 | table.list td.commitgraph { | 156 | table.list td.commitgraph { |
157 | font-family: monospace; | 157 | font-family: monospace; |
158 | white-space: pre; | 158 | white-space: pre; |
159 | } | 159 | } |
160 | 160 | ||
161 | table.list td.commitgraph .column1 { | 161 | table.list td.commitgraph .column1 { |
162 | color: #a00; | 162 | color: #a00; |
163 | } | 163 | } |
164 | 164 | ||
165 | table.list td.commitgraph .column2 { | 165 | table.list td.commitgraph .column2 { |
166 | color: #0a0; | 166 | color: #0a0; |
167 | } | 167 | } |
168 | 168 | ||
169 | table.list td.commitgraph .column3 { | 169 | table.list td.commitgraph .column3 { |
170 | color: #aa0; | 170 | color: #aa0; |
171 | } | 171 | } |
172 | 172 | ||
173 | table.list td.commitgraph .column4 { | 173 | table.list td.commitgraph .column4 { |
174 | color: #00a; | 174 | color: #00a; |
175 | } | 175 | } |
176 | 176 | ||
177 | table.list td.commitgraph .column5 { | 177 | table.list td.commitgraph .column5 { |
178 | color: #a0a; | 178 | color: #a0a; |
179 | } | 179 | } |
180 | 180 | ||
181 | table.list td.commitgraph .column6 { | 181 | table.list td.commitgraph .column6 { |
182 | color: #0aa; | 182 | color: #0aa; |
183 | } | 183 | } |
184 | 184 | ||
185 | table.list td.logsubject { | 185 | table.list td.logsubject { |
186 | font-family: monospace; | 186 | font-family: monospace; |
187 | font-weight: bold; | 187 | font-weight: bold; |
188 | } | 188 | } |
189 | 189 | ||
190 | table.list td.logmsg { | 190 | table.list td.logmsg { |
191 | font-family: monospace; | 191 | font-family: monospace; |
192 | white-space: pre; | 192 | white-space: pre; |
193 | padding: 0 0.5em; | 193 | padding: 0 0.5em; |
194 | } | 194 | } |
195 | 195 | ||
196 | table.list td a { | 196 | table.list td a { |
197 | color: black; | 197 | color: black; |
198 | } | 198 | } |
199 | 199 | ||
200 | table.list td a.ls-dir { | 200 | table.list td a.ls-dir { |
201 | font-weight: bold; | 201 | font-weight: bold; |
202 | color: #00f; | 202 | color: #00f; |
203 | } | 203 | } |
204 | 204 | ||
205 | table.list td a:hover { | 205 | table.list td a:hover { |
206 | color: #00f; | 206 | color: #00f; |
207 | } | 207 | } |
208 | 208 | ||
209 | img { | 209 | img { |
210 | border: none; | 210 | border: none; |
211 | } | 211 | } |
212 | 212 | ||
213 | input#switch-btn { | 213 | input#switch-btn { |
214 | margin: 2px 0px 0px 0px; | 214 | margin: 2px 0px 0px 0px; |
215 | } | 215 | } |
216 | 216 | ||
217 | td#sidebar input.txt { | 217 | td#sidebar input.txt { |
218 | width: 100%; | 218 | width: 100%; |
219 | margin: 2px 0px 0px 0px; | 219 | margin: 2px 0px 0px 0px; |
220 | } | 220 | } |
221 | 221 | ||
222 | table#grid { | 222 | table#grid { |
223 | margin: 0px; | 223 | margin: 0px; |
224 | } | 224 | } |
225 | 225 | ||
226 | td#content { | 226 | td#content { |
227 | vertical-align: top; | 227 | vertical-align: top; |
228 | padding: 1em 2em 1em 1em; | 228 | padding: 1em 2em 1em 1em; |
229 | border: none; | 229 | border: none; |
230 | } | 230 | } |
231 | 231 | ||
232 | div#summary { | 232 | div#summary { |
233 | vertical-align: top; | 233 | vertical-align: top; |
234 | margin-bottom: 1em; | 234 | margin-bottom: 1em; |
235 | } | 235 | } |
236 | 236 | ||
237 | table#downloads { | 237 | table#downloads { |
238 | float: right; | 238 | float: right; |
239 | border-collapse: collapse; | 239 | border-collapse: collapse; |
240 | border: solid 1px #777; | 240 | border: solid 1px #777; |
241 | margin-left: 0.5em; | 241 | margin-left: 0.5em; |
242 | margin-bottom: 0.5em; | 242 | margin-bottom: 0.5em; |
243 | } | 243 | } |
244 | 244 | ||
245 | table#downloads th { | 245 | table#downloads th { |
246 | background-color: #ccc; | 246 | background-color: #ccc; |
247 | } | 247 | } |
248 | 248 | ||
249 | div#blob { | 249 | div#blob { |
250 | border: solid 1px black; | 250 | border: solid 1px black; |
251 | } | 251 | } |
252 | 252 | ||
253 | div.error { | 253 | div.error { |
254 | color: red; | 254 | color: red; |
255 | font-weight: bold; | 255 | font-weight: bold; |
256 | margin: 1em 2em; | 256 | margin: 1em 2em; |
257 | } | 257 | } |
258 | 258 | ||
259 | a.ls-blob, a.ls-dir, a.ls-mod { | 259 | a.ls-blob, a.ls-dir, a.ls-mod { |
260 | font-family: monospace; | 260 | font-family: monospace; |
261 | } | 261 | } |
262 | 262 | ||
263 | td.ls-size { | 263 | td.ls-size { |
264 | text-align: right; | 264 | text-align: right; |
265 | font-family: monospace; | 265 | font-family: monospace; |
266 | width: 10em; | 266 | width: 10em; |
267 | } | 267 | } |
268 | 268 | ||
269 | td.ls-mode { | 269 | td.ls-mode { |
270 | font-family: monospace; | 270 | font-family: monospace; |
271 | width: 10em; | 271 | width: 10em; |
272 | } | 272 | } |
273 | 273 | ||
274 | table.blob { | 274 | table.blob { |
275 | margin-top: 0.5em; | 275 | margin-top: 0.5em; |
276 | border-top: solid 1px black; | 276 | border-top: solid 1px black; |
277 | } | 277 | } |
278 | 278 | ||
279 | table.blob td.lines { | 279 | table.blob td.lines { |
280 | margin: 0; padding: 0 0 0 0.5em; | 280 | margin: 0; padding: 0 0 0 0.5em; |
281 | vertical-align: top; | 281 | vertical-align: top; |
282 | color: black; | 282 | color: black; |
283 | } | 283 | } |
284 | 284 | ||
285 | table.blob td.linenumbers { | 285 | table.blob td.linenumbers { |
286 | margin: 0; padding: 0 0.5em 0 0.5em; | 286 | margin: 0; padding: 0 0.5em 0 0.5em; |
287 | vertical-align: top; | 287 | vertical-align: top; |
288 | text-align: right; | 288 | text-align: right; |
289 | border-right: 1px solid gray; | 289 | border-right: 1px solid gray; |
290 | } | 290 | } |
291 | 291 | ||
292 | table.blob pre { | 292 | table.blob pre { |
293 | padding: 0; margin: 0; | 293 | padding: 0; margin: 0; |
294 | } | 294 | } |
295 | 295 | ||
296 | table.blob a.no { | 296 | table.blob a.no, table.ssdiff a.no { |
297 | color: gray; | 297 | color: gray; |
298 | text-align: right; | 298 | text-align: right; |
299 | text-decoration: none; | 299 | text-decoration: none; |
300 | } | 300 | } |
301 | 301 | ||
302 | table.blob a.no a:hover { | 302 | table.blob a.no a:hover { |
303 | color: black; | 303 | color: black; |
304 | } | 304 | } |
305 | 305 | ||
306 | table.bin-blob { | 306 | table.bin-blob { |
307 | margin-top: 0.5em; | 307 | margin-top: 0.5em; |
308 | border: solid 1px black; | 308 | border: solid 1px black; |
309 | } | 309 | } |
310 | 310 | ||
311 | table.bin-blob th { | 311 | table.bin-blob th { |
312 | font-family: monospace; | 312 | font-family: monospace; |
313 | white-space: pre; | 313 | white-space: pre; |
314 | border: solid 1px #777; | 314 | border: solid 1px #777; |
315 | padding: 0.5em 1em; | 315 | padding: 0.5em 1em; |
316 | } | 316 | } |
317 | 317 | ||
318 | table.bin-blob td { | 318 | table.bin-blob td { |
319 | font-family: monospace; | 319 | font-family: monospace; |
320 | white-space: pre; | 320 | white-space: pre; |
321 | border-left: solid 1px #777; | 321 | border-left: solid 1px #777; |
322 | padding: 0em 1em; | 322 | padding: 0em 1em; |
323 | } | 323 | } |
324 | 324 | ||
325 | table.nowrap td { | 325 | table.nowrap td { |
326 | white-space: nowrap; | 326 | white-space: nowrap; |
327 | } | 327 | } |
328 | 328 | ||
329 | table.commit-info { | 329 | table.commit-info { |
330 | border-collapse: collapse; | 330 | border-collapse: collapse; |
331 | margin-top: 1.5em; | 331 | margin-top: 1.5em; |
332 | } | 332 | } |
333 | 333 | ||
334 | table.commit-info th { | 334 | table.commit-info th { |
335 | text-align: left; | 335 | text-align: left; |
336 | font-weight: normal; | 336 | font-weight: normal; |
337 | padding: 0.1em 1em 0.1em 0.1em; | 337 | padding: 0.1em 1em 0.1em 0.1em; |
338 | vertical-align: top; | 338 | vertical-align: top; |
339 | } | 339 | } |
340 | 340 | ||
341 | table.commit-info td { | 341 | table.commit-info td { |
342 | font-weight: normal; | 342 | font-weight: normal; |
343 | padding: 0.1em 1em 0.1em 0.1em; | 343 | padding: 0.1em 1em 0.1em 0.1em; |
344 | } | 344 | } |
345 | 345 | ||
346 | div.commit-subject { | 346 | div.commit-subject { |
347 | font-weight: bold; | 347 | font-weight: bold; |
348 | font-size: 125%; | 348 | font-size: 125%; |
349 | margin: 1.5em 0em 0.5em 0em; | 349 | margin: 1.5em 0em 0.5em 0em; |
350 | padding: 0em; | 350 | padding: 0em; |
351 | } | 351 | } |
352 | 352 | ||
353 | div.commit-msg { | 353 | div.commit-msg { |
354 | white-space: pre; | 354 | white-space: pre; |
355 | font-family: monospace; | 355 | font-family: monospace; |
356 | } | 356 | } |
357 | 357 | ||
358 | div.notes-header { | 358 | div.notes-header { |
359 | font-weight: bold; | 359 | font-weight: bold; |
360 | padding-top: 1.5em; | 360 | padding-top: 1.5em; |
361 | } | 361 | } |
362 | 362 | ||
363 | div.notes { | 363 | div.notes { |
364 | white-space: pre; | 364 | white-space: pre; |
365 | font-family: monospace; | 365 | font-family: monospace; |
366 | border: solid 1px #ee9; | 366 | border: solid 1px #ee9; |
367 | background-color: #ffd; | 367 | background-color: #ffd; |
368 | padding: 0.3em 2em 0.3em 1em; | 368 | padding: 0.3em 2em 0.3em 1em; |
369 | float: left; | 369 | float: left; |
370 | } | 370 | } |
371 | 371 | ||
372 | div.notes-footer { | 372 | div.notes-footer { |
373 | clear: left; | 373 | clear: left; |
374 | } | 374 | } |
375 | 375 | ||
376 | div.diffstat-header { | 376 | div.diffstat-header { |
377 | font-weight: bold; | 377 | font-weight: bold; |
378 | padding-top: 1.5em; | 378 | padding-top: 1.5em; |
379 | } | 379 | } |
380 | 380 | ||
381 | table.diffstat { | 381 | table.diffstat { |
382 | border-collapse: collapse; | 382 | border-collapse: collapse; |
383 | border: solid 1px #aaa; | 383 | border: solid 1px #aaa; |
384 | background-color: #eee; | 384 | background-color: #eee; |
385 | } | 385 | } |
386 | 386 | ||
387 | table.diffstat th { | 387 | table.diffstat th { |
388 | font-weight: normal; | 388 | font-weight: normal; |
389 | text-align: left; | 389 | text-align: left; |
390 | text-decoration: underline; | 390 | text-decoration: underline; |
391 | padding: 0.1em 1em 0.1em 0.1em; | 391 | padding: 0.1em 1em 0.1em 0.1em; |
392 | font-size: 100%; | 392 | font-size: 100%; |
393 | } | 393 | } |
394 | 394 | ||
395 | table.diffstat td { | 395 | table.diffstat td { |
396 | padding: 0.2em 0.2em 0.1em 0.1em; | 396 | padding: 0.2em 0.2em 0.1em 0.1em; |
397 | font-size: 100%; | 397 | font-size: 100%; |
398 | border: none; | 398 | border: none; |
399 | } | 399 | } |
400 | 400 | ||
401 | table.diffstat td.mode { | 401 | table.diffstat td.mode { |
402 | white-space: nowrap; | 402 | white-space: nowrap; |
403 | } | 403 | } |
404 | 404 | ||
405 | table.diffstat td span.modechange { | 405 | table.diffstat td span.modechange { |
406 | padding-left: 1em; | 406 | padding-left: 1em; |
407 | color: red; | 407 | color: red; |
408 | } | 408 | } |
409 | 409 | ||
410 | table.diffstat td.add a { | 410 | table.diffstat td.add a { |
411 | color: green; | 411 | color: green; |
412 | } | 412 | } |
413 | 413 | ||
414 | table.diffstat td.del a { | 414 | table.diffstat td.del a { |
415 | color: red; | 415 | color: red; |
416 | } | 416 | } |
417 | 417 | ||
418 | table.diffstat td.upd a { | 418 | table.diffstat td.upd a { |
419 | color: blue; | 419 | color: blue; |
420 | } | 420 | } |
421 | 421 | ||
422 | table.diffstat td.graph { | 422 | table.diffstat td.graph { |
423 | width: 500px; | 423 | width: 500px; |
424 | vertical-align: middle; | 424 | vertical-align: middle; |
425 | } | 425 | } |
426 | 426 | ||
427 | table.diffstat td.graph table { | 427 | table.diffstat td.graph table { |
428 | border: none; | 428 | border: none; |
429 | } | 429 | } |
430 | 430 | ||
431 | table.diffstat td.graph td { | 431 | table.diffstat td.graph td { |
432 | padding: 0px; | 432 | padding: 0px; |
433 | border: 0px; | 433 | border: 0px; |
434 | height: 7pt; | 434 | height: 7pt; |
435 | } | 435 | } |
436 | 436 | ||
437 | table.diffstat td.graph td.add { | 437 | table.diffstat td.graph td.add { |
438 | background-color: #5c5; | 438 | background-color: #5c5; |
439 | } | 439 | } |
440 | 440 | ||
441 | table.diffstat td.graph td.rem { | 441 | table.diffstat td.graph td.rem { |
442 | background-color: #c55; | 442 | background-color: #c55; |
443 | } | 443 | } |
444 | 444 | ||
445 | div.diffstat-summary { | 445 | div.diffstat-summary { |
446 | color: #888; | 446 | color: #888; |
447 | padding-top: 0.5em; | 447 | padding-top: 0.5em; |
448 | } | 448 | } |
449 | 449 | ||
450 | table.diff { | 450 | table.diff { |
451 | width: 100%; | 451 | width: 100%; |
452 | } | 452 | } |
453 | 453 | ||
454 | table.diff td { | 454 | table.diff td { |
455 | font-family: monospace; | 455 | font-family: monospace; |
456 | white-space: pre; | 456 | white-space: pre; |
457 | } | 457 | } |
458 | 458 | ||
459 | table.diff td div.head { | 459 | table.diff td div.head { |
460 | font-weight: bold; | 460 | font-weight: bold; |
461 | margin-top: 1em; | 461 | margin-top: 1em; |
462 | color: black; | 462 | color: black; |
463 | } | 463 | } |
464 | 464 | ||
465 | table.diff td div.hunk { | 465 | table.diff td div.hunk { |
466 | color: #009; | 466 | color: #009; |
467 | } | 467 | } |
468 | 468 | ||
469 | table.diff td div.add { | 469 | table.diff td div.add { |
470 | color: green; | 470 | color: green; |
471 | } | 471 | } |
472 | 472 | ||
473 | table.diff td div.del { | 473 | table.diff td div.del { |
474 | color: red; | 474 | color: red; |
475 | } | 475 | } |
476 | 476 | ||
477 | .sha1 { | 477 | .sha1 { |
478 | font-family: monospace; | 478 | font-family: monospace; |
479 | font-size: 90%; | 479 | font-size: 90%; |
480 | } | 480 | } |
481 | 481 | ||
482 | .left { | 482 | .left { |
483 | text-align: left; | 483 | text-align: left; |
484 | } | 484 | } |
485 | 485 | ||
486 | .right { | 486 | .right { |
487 | text-align: right; | 487 | text-align: right; |
488 | } | 488 | } |
489 | 489 | ||
490 | table.list td.reposection { | 490 | table.list td.reposection { |
491 | font-style: italic; | 491 | font-style: italic; |
492 | color: #888; | 492 | color: #888; |
493 | } | 493 | } |
494 | 494 | ||
495 | a.button { | 495 | a.button { |
496 | font-size: 80%; | 496 | font-size: 80%; |
497 | padding: 0em 0.5em; | 497 | padding: 0em 0.5em; |
498 | } | 498 | } |
499 | 499 | ||
500 | a.primary { | 500 | a.primary { |
501 | font-size: 100%; | 501 | font-size: 100%; |
502 | } | 502 | } |
503 | 503 | ||
504 | a.secondary { | 504 | a.secondary { |
505 | font-size: 90%; | 505 | font-size: 90%; |
506 | } | 506 | } |
507 | 507 | ||
508 | td.toplevel-repo { | 508 | td.toplevel-repo { |
509 | 509 | ||
510 | } | 510 | } |
511 | 511 | ||
512 | table.list td.sublevel-repo { | 512 | table.list td.sublevel-repo { |
513 | padding-left: 1.5em; | 513 | padding-left: 1.5em; |
514 | } | 514 | } |
515 | 515 | ||
516 | div.pager { | 516 | div.pager { |
517 | text-align: center; | 517 | text-align: center; |
518 | margin: 1em 0em 0em 0em; | 518 | margin: 1em 0em 0em 0em; |
519 | } | 519 | } |
520 | 520 | ||
521 | div.pager a { | 521 | div.pager a { |
522 | color: #777; | 522 | color: #777; |
523 | margin: 0em 0.5em; | 523 | margin: 0em 0.5em; |
524 | } | 524 | } |
525 | 525 | ||
526 | span.age-mins { | 526 | span.age-mins { |
527 | font-weight: bold; | 527 | font-weight: bold; |
528 | color: #080; | 528 | color: #080; |
529 | } | 529 | } |
530 | 530 | ||
531 | span.age-hours { | 531 | span.age-hours { |
532 | color: #080; | 532 | color: #080; |
533 | } | 533 | } |
534 | 534 | ||
535 | span.age-days { | 535 | span.age-days { |
536 | color: #040; | 536 | color: #040; |
537 | } | 537 | } |
538 | 538 | ||
539 | span.age-weeks { | 539 | span.age-weeks { |
540 | color: #444; | 540 | color: #444; |
541 | } | 541 | } |
542 | 542 | ||
543 | span.age-months { | 543 | span.age-months { |
544 | color: #888; | 544 | color: #888; |
545 | } | 545 | } |
546 | 546 | ||
547 | span.age-years { | 547 | span.age-years { |
548 | color: #bbb; | 548 | color: #bbb; |
549 | } | 549 | } |
550 | div.footer { | 550 | div.footer { |
551 | margin-top: 0.5em; | 551 | margin-top: 0.5em; |
552 | text-align: center; | 552 | text-align: center; |
553 | font-size: 80%; | 553 | font-size: 80%; |
554 | color: #ccc; | 554 | color: #ccc; |
555 | } | 555 | } |
556 | a.branch-deco { | 556 | a.branch-deco { |
557 | margin: 0px 0.5em; | 557 | margin: 0px 0.5em; |
558 | padding: 0px 0.25em; | 558 | padding: 0px 0.25em; |
559 | background-color: #88ff88; | 559 | background-color: #88ff88; |
560 | border: solid 1px #007700; | 560 | border: solid 1px #007700; |
561 | } | 561 | } |
562 | a.tag-deco { | 562 | a.tag-deco { |
563 | margin: 0px 0.5em; | 563 | margin: 0px 0.5em; |
564 | padding: 0px 0.25em; | 564 | padding: 0px 0.25em; |
565 | background-color: #ffff88; | 565 | background-color: #ffff88; |
566 | border: solid 1px #777700; | 566 | border: solid 1px #777700; |
567 | } | 567 | } |
568 | a.remote-deco { | 568 | a.remote-deco { |
569 | margin: 0px 0.5em; | 569 | margin: 0px 0.5em; |
570 | padding: 0px 0.25em; | 570 | padding: 0px 0.25em; |
571 | background-color: #ccccff; | 571 | background-color: #ccccff; |
572 | border: solid 1px #000077; | 572 | border: solid 1px #000077; |
573 | } | 573 | } |
574 | a.deco { | 574 | a.deco { |
575 | margin: 0px 0.5em; | 575 | margin: 0px 0.5em; |
576 | padding: 0px 0.25em; | 576 | padding: 0px 0.25em; |
577 | background-color: #ff8888; | 577 | background-color: #ff8888; |
578 | border: solid 1px #770000; | 578 | border: solid 1px #770000; |
579 | } | 579 | } |
580 | 580 | ||
581 | div.commit-subject a.branch-deco, | 581 | div.commit-subject a.branch-deco, |
582 | div.commit-subject a.tag-deco, | 582 | div.commit-subject a.tag-deco, |
583 | div.commit-subject a.remote-deco, | 583 | div.commit-subject a.remote-deco, |
584 | div.commit-subject a.deco { | 584 | div.commit-subject a.deco { |
585 | margin-left: 1em; | 585 | margin-left: 1em; |
586 | font-size: 75%; | 586 | font-size: 75%; |
587 | } | 587 | } |
588 | 588 | ||
589 | table.stats { | 589 | table.stats { |
590 | border: solid 1px black; | 590 | border: solid 1px black; |
591 | border-collapse: collapse; | 591 | border-collapse: collapse; |
592 | } | 592 | } |
593 | 593 | ||
594 | table.stats th { | 594 | table.stats th { |
595 | text-align: left; | 595 | text-align: left; |
596 | padding: 1px 0.5em; | 596 | padding: 1px 0.5em; |
597 | background-color: #eee; | 597 | background-color: #eee; |
598 | border: solid 1px black; | 598 | border: solid 1px black; |
599 | } | 599 | } |
600 | 600 | ||
601 | table.stats td { | 601 | table.stats td { |
602 | text-align: right; | 602 | text-align: right; |
603 | padding: 1px 0.5em; | 603 | padding: 1px 0.5em; |
604 | border: solid 1px black; | 604 | border: solid 1px black; |
605 | } | 605 | } |
606 | 606 | ||
607 | table.stats td.total { | 607 | table.stats td.total { |
608 | font-weight: bold; | 608 | font-weight: bold; |
609 | text-align: left; | 609 | text-align: left; |
610 | } | 610 | } |
611 | 611 | ||
612 | table.stats td.sum { | 612 | table.stats td.sum { |
613 | color: #c00; | 613 | color: #c00; |
614 | font-weight: bold; | 614 | font-weight: bold; |
615 | /*background-color: #eee; */ | 615 | /*background-color: #eee; */ |
616 | } | 616 | } |
617 | 617 | ||
618 | table.stats td.left { | 618 | table.stats td.left { |
619 | text-align: left; | 619 | text-align: left; |
620 | } | 620 | } |
621 | 621 | ||
622 | table.vgraph { | 622 | table.vgraph { |
623 | border-collapse: separate; | 623 | border-collapse: separate; |
624 | border: solid 1px black; | 624 | border: solid 1px black; |
625 | height: 200px; | 625 | height: 200px; |
626 | } | 626 | } |
627 | 627 | ||
628 | table.vgraph th { | 628 | table.vgraph th { |
629 | background-color: #eee; | 629 | background-color: #eee; |
630 | font-weight: bold; | 630 | font-weight: bold; |
631 | border: solid 1px white; | 631 | border: solid 1px white; |
632 | padding: 1px 0.5em; | 632 | padding: 1px 0.5em; |
633 | } | 633 | } |
634 | 634 | ||
635 | table.vgraph td { | 635 | table.vgraph td { |
636 | vertical-align: bottom; | 636 | vertical-align: bottom; |
637 | padding: 0px 10px; | 637 | padding: 0px 10px; |
638 | } | 638 | } |
639 | 639 | ||
640 | table.vgraph div.bar { | 640 | table.vgraph div.bar { |
641 | background-color: #eee; | 641 | background-color: #eee; |
642 | } | 642 | } |
643 | 643 | ||
644 | table.hgraph { | 644 | table.hgraph { |
645 | border: solid 1px black; | 645 | border: solid 1px black; |
646 | width: 800px; | 646 | width: 800px; |
647 | } | 647 | } |
648 | 648 | ||
649 | table.hgraph th { | 649 | table.hgraph th { |
650 | background-color: #eee; | 650 | background-color: #eee; |
651 | font-weight: bold; | 651 | font-weight: bold; |
652 | border: solid 1px black; | 652 | border: solid 1px black; |
653 | padding: 1px 0.5em; | 653 | padding: 1px 0.5em; |
654 | } | 654 | } |
655 | 655 | ||
656 | table.hgraph td { | 656 | table.hgraph td { |
657 | vertical-align: center; | 657 | vertical-align: center; |
658 | padding: 2px 2px; | 658 | padding: 2px 2px; |
659 | } | 659 | } |
660 | 660 | ||
661 | table.hgraph div.bar { | 661 | table.hgraph div.bar { |
662 | background-color: #eee; | 662 | background-color: #eee; |
663 | height: 1em; | 663 | height: 1em; |
664 | } | 664 | } |
665 | 665 | ||
666 | table.ssdiff { | 666 | table.ssdiff { |
667 | width: 100%; | 667 | width: 100%; |
668 | } | 668 | } |
669 | 669 | ||
670 | table.ssdiff td { | 670 | table.ssdiff td { |
671 | font-size: 75%; | 671 | font-size: 75%; |
672 | font-family: monospace; | 672 | font-family: monospace; |
673 | white-space: pre; | 673 | white-space: pre; |
674 | padding: 1px 4px 1px 4px; | 674 | padding: 1px 4px 1px 4px; |
675 | border-left: solid 1px #aaa; | 675 | border-left: solid 1px #aaa; |
676 | border-right: solid 1px #aaa; | 676 | border-right: solid 1px #aaa; |
677 | } | 677 | } |
678 | 678 | ||
679 | table.ssdiff td.add { | 679 | table.ssdiff td.add { |
680 | color: black; | 680 | color: black; |
@@ -1,322 +1,324 @@ | |||
1 | #ifndef CGIT_H | 1 | #ifndef CGIT_H |
2 | #define CGIT_H | 2 | #define CGIT_H |
3 | 3 | ||
4 | 4 | ||
5 | #include <git-compat-util.h> | 5 | #include <git-compat-util.h> |
6 | #include <cache.h> | 6 | #include <cache.h> |
7 | #include <grep.h> | 7 | #include <grep.h> |
8 | #include <object.h> | 8 | #include <object.h> |
9 | #include <tree.h> | 9 | #include <tree.h> |
10 | #include <commit.h> | 10 | #include <commit.h> |
11 | #include <tag.h> | 11 | #include <tag.h> |
12 | #include <diff.h> | 12 | #include <diff.h> |
13 | #include <diffcore.h> | 13 | #include <diffcore.h> |
14 | #include <refs.h> | 14 | #include <refs.h> |
15 | #include <revision.h> | 15 | #include <revision.h> |
16 | #include <log-tree.h> | 16 | #include <log-tree.h> |
17 | #include <archive.h> | 17 | #include <archive.h> |
18 | #include <string-list.h> | 18 | #include <string-list.h> |
19 | #include <xdiff-interface.h> | 19 | #include <xdiff-interface.h> |
20 | #include <xdiff/xdiff.h> | 20 | #include <xdiff/xdiff.h> |
21 | #include <utf8.h> | 21 | #include <utf8.h> |
22 | #include <notes.h> | 22 | #include <notes.h> |
23 | #include <graph.h> | 23 | #include <graph.h> |
24 | 24 | ||
25 | 25 | ||
26 | /* | 26 | /* |
27 | * Dateformats used on misc. pages | 27 | * Dateformats used on misc. pages |
28 | */ | 28 | */ |
29 | #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S (%Z)" | 29 | #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S (%Z)" |
30 | #define FMT_SHORTDATE "%Y-%m-%d" | 30 | #define FMT_SHORTDATE "%Y-%m-%d" |
31 | #define FMT_ATOMDATE "%Y-%m-%dT%H:%M:%SZ" | 31 | #define FMT_ATOMDATE "%Y-%m-%dT%H:%M:%SZ" |
32 | 32 | ||
33 | 33 | ||
34 | /* | 34 | /* |
35 | * Limits used for relative dates | 35 | * Limits used for relative dates |
36 | */ | 36 | */ |
37 | #define TM_MIN 60 | 37 | #define TM_MIN 60 |
38 | #define TM_HOUR (TM_MIN * 60) | 38 | #define TM_HOUR (TM_MIN * 60) |
39 | #define TM_DAY (TM_HOUR * 24) | 39 | #define TM_DAY (TM_HOUR * 24) |
40 | #define TM_WEEK (TM_DAY * 7) | 40 | #define TM_WEEK (TM_DAY * 7) |
41 | #define TM_YEAR (TM_DAY * 365) | 41 | #define TM_YEAR (TM_DAY * 365) |
42 | #define TM_MONTH (TM_YEAR / 12.0) | 42 | #define TM_MONTH (TM_YEAR / 12.0) |
43 | 43 | ||
44 | 44 | ||
45 | /* | 45 | /* |
46 | * Default encoding | 46 | * Default encoding |
47 | */ | 47 | */ |
48 | #define PAGE_ENCODING "UTF-8" | 48 | #define PAGE_ENCODING "UTF-8" |
49 | 49 | ||
50 | typedef void (*configfn)(const char *name, const char *value); | 50 | typedef void (*configfn)(const char *name, const char *value); |
51 | typedef void (*filepair_fn)(struct diff_filepair *pair); | 51 | typedef void (*filepair_fn)(struct diff_filepair *pair); |
52 | typedef void (*linediff_fn)(char *line, int len); | 52 | typedef void (*linediff_fn)(char *line, int len); |
53 | 53 | ||
54 | struct cgit_filter { | 54 | struct cgit_filter { |
55 | char *cmd; | 55 | char *cmd; |
56 | char **argv; | 56 | char **argv; |
57 | int old_stdout; | 57 | int old_stdout; |
58 | int pipe_fh[2]; | 58 | int pipe_fh[2]; |
59 | int pid; | 59 | int pid; |
60 | int exitstatus; | 60 | int exitstatus; |
61 | }; | 61 | }; |
62 | 62 | ||
63 | struct cgit_repo { | 63 | struct cgit_repo { |
64 | char *url; | 64 | char *url; |
65 | char *name; | 65 | char *name; |
66 | char *path; | 66 | char *path; |
67 | char *desc; | 67 | char *desc; |
68 | char *owner; | 68 | char *owner; |
69 | char *defbranch; | 69 | char *defbranch; |
70 | char *module_link; | 70 | char *module_link; |
71 | char *readme; | 71 | char *readme; |
72 | char *section; | 72 | char *section; |
73 | char *clone_url; | 73 | char *clone_url; |
74 | char *logo; | ||
75 | char *logo_link; | ||
74 | int snapshots; | 76 | int snapshots; |
75 | int enable_commit_graph; | 77 | int enable_commit_graph; |
76 | int enable_log_filecount; | 78 | int enable_log_filecount; |
77 | int enable_log_linecount; | 79 | int enable_log_linecount; |
78 | int enable_remote_branches; | 80 | int enable_remote_branches; |
79 | int enable_subject_links; | 81 | int enable_subject_links; |
80 | int max_stats; | 82 | int max_stats; |
81 | time_t mtime; | 83 | time_t mtime; |
82 | struct cgit_filter *about_filter; | 84 | struct cgit_filter *about_filter; |
83 | struct cgit_filter *commit_filter; | 85 | struct cgit_filter *commit_filter; |
84 | struct cgit_filter *source_filter; | 86 | struct cgit_filter *source_filter; |
85 | }; | 87 | }; |
86 | 88 | ||
87 | typedef void (*repo_config_fn)(struct cgit_repo *repo, const char *name, | 89 | typedef void (*repo_config_fn)(struct cgit_repo *repo, const char *name, |
88 | const char *value); | 90 | const char *value); |
89 | 91 | ||
90 | struct cgit_repolist { | 92 | struct cgit_repolist { |
91 | int length; | 93 | int length; |
92 | int count; | 94 | int count; |
93 | struct cgit_repo *repos; | 95 | struct cgit_repo *repos; |
94 | }; | 96 | }; |
95 | 97 | ||
96 | struct commitinfo { | 98 | struct commitinfo { |
97 | struct commit *commit; | 99 | struct commit *commit; |
98 | char *author; | 100 | char *author; |
99 | char *author_email; | 101 | char *author_email; |
100 | unsigned long author_date; | 102 | unsigned long author_date; |
101 | char *committer; | 103 | char *committer; |
102 | char *committer_email; | 104 | char *committer_email; |
103 | unsigned long committer_date; | 105 | unsigned long committer_date; |
104 | char *subject; | 106 | char *subject; |
105 | char *msg; | 107 | char *msg; |
106 | char *msg_encoding; | 108 | char *msg_encoding; |
107 | }; | 109 | }; |
108 | 110 | ||
109 | struct taginfo { | 111 | struct taginfo { |
110 | char *tagger; | 112 | char *tagger; |
111 | char *tagger_email; | 113 | char *tagger_email; |
112 | unsigned long tagger_date; | 114 | unsigned long tagger_date; |
113 | char *msg; | 115 | char *msg; |
114 | }; | 116 | }; |
115 | 117 | ||
116 | struct refinfo { | 118 | struct refinfo { |
117 | const char *refname; | 119 | const char *refname; |
118 | struct object *object; | 120 | struct object *object; |
119 | union { | 121 | union { |
120 | struct taginfo *tag; | 122 | struct taginfo *tag; |
121 | struct commitinfo *commit; | 123 | struct commitinfo *commit; |
122 | }; | 124 | }; |
123 | }; | 125 | }; |
124 | 126 | ||
125 | struct reflist { | 127 | struct reflist { |
126 | struct refinfo **refs; | 128 | struct refinfo **refs; |
127 | int alloc; | 129 | int alloc; |
128 | int count; | 130 | int count; |
129 | }; | 131 | }; |
130 | 132 | ||
131 | struct cgit_query { | 133 | struct cgit_query { |
132 | int has_symref; | 134 | int has_symref; |
133 | int has_sha1; | 135 | int has_sha1; |
134 | char *raw; | 136 | char *raw; |
135 | char *repo; | 137 | char *repo; |
136 | char *page; | 138 | char *page; |
137 | char *search; | 139 | char *search; |
138 | char *grep; | 140 | char *grep; |
139 | char *head; | 141 | char *head; |
140 | char *sha1; | 142 | char *sha1; |
141 | char *sha2; | 143 | char *sha2; |
142 | char *path; | 144 | char *path; |
143 | char *name; | 145 | char *name; |
144 | char *mimetype; | 146 | char *mimetype; |
145 | char *url; | 147 | char *url; |
146 | char *period; | 148 | char *period; |
147 | int ofs; | 149 | int ofs; |
148 | int nohead; | 150 | int nohead; |
149 | char *sort; | 151 | char *sort; |
150 | int showmsg; | 152 | int showmsg; |
151 | int ssdiff; | 153 | int ssdiff; |
152 | int show_all; | 154 | int show_all; |
153 | int context; | 155 | int context; |
154 | int ignorews; | 156 | int ignorews; |
155 | char *vpath; | 157 | char *vpath; |
156 | }; | 158 | }; |
157 | 159 | ||
158 | struct cgit_config { | 160 | struct cgit_config { |
159 | char *agefile; | 161 | char *agefile; |
160 | char *cache_root; | 162 | char *cache_root; |
161 | char *clone_prefix; | 163 | char *clone_prefix; |
162 | char *css; | 164 | char *css; |
163 | char *favicon; | 165 | char *favicon; |
164 | char *footer; | 166 | char *footer; |
165 | char *head_include; | 167 | char *head_include; |
166 | char *header; | 168 | char *header; |
167 | char *index_header; | 169 | char *index_header; |
168 | char *index_info; | 170 | char *index_info; |
169 | char *logo; | 171 | char *logo; |
170 | char *logo_link; | 172 | char *logo_link; |
171 | char *module_link; | 173 | char *module_link; |
172 | char *project_list; | 174 | char *project_list; |
173 | char *readme; | 175 | char *readme; |
174 | char *robots; | 176 | char *robots; |
175 | char *root_title; | 177 | char *root_title; |
176 | char *root_desc; | 178 | char *root_desc; |
177 | char *root_readme; | 179 | char *root_readme; |
178 | char *script_name; | 180 | char *script_name; |
179 | char *section; | 181 | char *section; |
180 | char *virtual_root; | 182 | char *virtual_root; |
181 | char *strict_export; | 183 | char *strict_export; |
182 | int cache_size; | 184 | int cache_size; |
183 | int cache_dynamic_ttl; | 185 | int cache_dynamic_ttl; |
184 | int cache_max_create_time; | 186 | int cache_max_create_time; |
185 | int cache_repo_ttl; | 187 | int cache_repo_ttl; |
186 | int cache_root_ttl; | 188 | int cache_root_ttl; |
187 | int cache_scanrc_ttl; | 189 | int cache_scanrc_ttl; |
188 | int cache_static_ttl; | 190 | int cache_static_ttl; |
189 | int embedded; | 191 | int embedded; |
190 | int enable_filter_overrides; | 192 | int enable_filter_overrides; |
191 | int enable_gitweb_owner; | 193 | int enable_gitweb_owner; |
192 | int enable_index_links; | 194 | int enable_index_links; |
193 | int enable_commit_graph; | 195 | int enable_commit_graph; |
194 | int enable_log_filecount; | 196 | int enable_log_filecount; |
195 | int enable_log_linecount; | 197 | int enable_log_linecount; |
196 | int enable_remote_branches; | 198 | int enable_remote_branches; |
197 | int enable_subject_links; | 199 | int enable_subject_links; |
198 | int enable_tree_linenumbers; | 200 | int enable_tree_linenumbers; |
199 | int local_time; | 201 | int local_time; |
200 | int max_atom_items; | 202 | int max_atom_items; |
201 | int max_repo_count; | 203 | int max_repo_count; |
202 | int max_commit_count; | 204 | int max_commit_count; |
203 | int max_lock_attempts; | 205 | int max_lock_attempts; |
204 | int max_msg_len; | 206 | int max_msg_len; |
205 | int max_repodesc_len; | 207 | int max_repodesc_len; |
206 | int max_blob_size; | 208 | int max_blob_size; |
207 | int max_stats; | 209 | int max_stats; |
208 | int nocache; | 210 | int nocache; |
209 | int noplainemail; | 211 | int noplainemail; |
210 | int noheader; | 212 | int noheader; |
211 | int renamelimit; | 213 | int renamelimit; |
212 | int remove_suffix; | 214 | int remove_suffix; |
213 | int scan_hidden_path; | 215 | int scan_hidden_path; |
214 | int section_from_path; | 216 | int section_from_path; |
215 | int snapshots; | 217 | int snapshots; |
216 | int summary_branches; | 218 | int summary_branches; |
217 | int summary_log; | 219 | int summary_log; |
218 | int summary_tags; | 220 | int summary_tags; |
219 | int ssdiff; | 221 | int ssdiff; |
220 | struct string_list mimetypes; | 222 | struct string_list mimetypes; |
221 | struct cgit_filter *about_filter; | 223 | struct cgit_filter *about_filter; |
222 | struct cgit_filter *commit_filter; | 224 | struct cgit_filter *commit_filter; |
223 | struct cgit_filter *source_filter; | 225 | struct cgit_filter *source_filter; |
224 | }; | 226 | }; |
225 | 227 | ||
226 | struct cgit_page { | 228 | struct cgit_page { |
227 | time_t modified; | 229 | time_t modified; |
228 | time_t expires; | 230 | time_t expires; |
229 | size_t size; | 231 | size_t size; |
230 | char *mimetype; | 232 | char *mimetype; |
231 | char *charset; | 233 | char *charset; |
232 | char *filename; | 234 | char *filename; |
233 | char *etag; | 235 | char *etag; |
234 | char *title; | 236 | char *title; |
235 | int status; | 237 | int status; |
236 | char *statusmsg; | 238 | char *statusmsg; |
237 | }; | 239 | }; |
238 | 240 | ||
239 | struct cgit_environment { | 241 | struct cgit_environment { |
240 | char *cgit_config; | 242 | char *cgit_config; |
241 | char *http_host; | 243 | char *http_host; |
242 | char *https; | 244 | char *https; |
243 | char *no_http; | 245 | char *no_http; |
244 | char *path_info; | 246 | char *path_info; |
245 | char *query_string; | 247 | char *query_string; |
246 | char *request_method; | 248 | char *request_method; |
247 | char *script_name; | 249 | char *script_name; |
248 | char *server_name; | 250 | char *server_name; |
249 | char *server_port; | 251 | char *server_port; |
250 | }; | 252 | }; |
251 | 253 | ||
252 | struct cgit_context { | 254 | struct cgit_context { |
253 | struct cgit_environment env; | 255 | struct cgit_environment env; |
254 | struct cgit_query qry; | 256 | struct cgit_query qry; |
255 | struct cgit_config cfg; | 257 | struct cgit_config cfg; |
256 | struct cgit_repo *repo; | 258 | struct cgit_repo *repo; |
257 | struct cgit_page page; | 259 | struct cgit_page page; |
258 | }; | 260 | }; |
259 | 261 | ||
260 | struct cgit_snapshot_format { | 262 | struct cgit_snapshot_format { |
261 | const char *suffix; | 263 | const char *suffix; |
262 | const char *mimetype; | 264 | const char *mimetype; |
263 | write_archive_fn_t write_func; | 265 | write_archive_fn_t write_func; |
264 | int bit; | 266 | int bit; |
265 | }; | 267 | }; |
266 | 268 | ||
267 | extern const char *cgit_version; | 269 | extern const char *cgit_version; |
268 | 270 | ||
269 | extern struct cgit_repolist cgit_repolist; | 271 | extern struct cgit_repolist cgit_repolist; |
270 | extern struct cgit_context ctx; | 272 | extern struct cgit_context ctx; |
271 | extern const struct cgit_snapshot_format cgit_snapshot_formats[]; | 273 | extern const struct cgit_snapshot_format cgit_snapshot_formats[]; |
272 | 274 | ||
273 | extern struct cgit_repo *cgit_add_repo(const char *url); | 275 | extern struct cgit_repo *cgit_add_repo(const char *url); |
274 | extern struct cgit_repo *cgit_get_repoinfo(const char *url); | 276 | extern struct cgit_repo *cgit_get_repoinfo(const char *url); |
275 | extern void cgit_repo_config_cb(const char *name, const char *value); | 277 | extern void cgit_repo_config_cb(const char *name, const char *value); |
276 | 278 | ||
277 | extern int chk_zero(int result, char *msg); | 279 | extern int chk_zero(int result, char *msg); |
278 | extern int chk_positive(int result, char *msg); | 280 | extern int chk_positive(int result, char *msg); |
279 | extern int chk_non_negative(int result, char *msg); | 281 | extern int chk_non_negative(int result, char *msg); |
280 | 282 | ||
281 | extern char *trim_end(const char *str, char c); | 283 | extern char *trim_end(const char *str, char c); |
282 | extern char *strlpart(char *txt, int maxlen); | 284 | extern char *strlpart(char *txt, int maxlen); |
283 | extern char *strrpart(char *txt, int maxlen); | 285 | extern char *strrpart(char *txt, int maxlen); |
284 | 286 | ||
285 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); | 287 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); |
286 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, | 288 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, |
287 | int flags, void *cb_data); | 289 | int flags, void *cb_data); |
288 | 290 | ||
289 | extern void *cgit_free_commitinfo(struct commitinfo *info); | 291 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
290 | 292 | ||
291 | extern int cgit_diff_files(const unsigned char *old_sha1, | 293 | extern int cgit_diff_files(const unsigned char *old_sha1, |
292 | const unsigned char *new_sha1, | 294 | const unsigned char *new_sha1, |
293 | unsigned long *old_size, unsigned long *new_size, | 295 | unsigned long *old_size, unsigned long *new_size, |
294 | int *binary, int context, int ignorews, | 296 | int *binary, int context, int ignorews, |
295 | linediff_fn fn); | 297 | linediff_fn fn); |
296 | 298 | ||
297 | extern void cgit_diff_tree(const unsigned char *old_sha1, | 299 | extern void cgit_diff_tree(const unsigned char *old_sha1, |
298 | const unsigned char *new_sha1, | 300 | const unsigned char *new_sha1, |
299 | filepair_fn fn, const char *prefix, int ignorews); | 301 | filepair_fn fn, const char *prefix, int ignorews); |
300 | 302 | ||
301 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn, | 303 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn, |
302 | const char *prefix); | 304 | const char *prefix); |
303 | 305 | ||
304 | __attribute__((format (printf,1,2))) | 306 | __attribute__((format (printf,1,2))) |
305 | extern char *fmt(const char *format,...); | 307 | extern char *fmt(const char *format,...); |
306 | 308 | ||
307 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); | 309 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
308 | extern struct taginfo *cgit_parse_tag(struct tag *tag); | 310 | extern struct taginfo *cgit_parse_tag(struct tag *tag); |
309 | extern void cgit_parse_url(const char *url); | 311 | extern void cgit_parse_url(const char *url); |
310 | 312 | ||
311 | extern const char *cgit_repobasename(const char *reponame); | 313 | extern const char *cgit_repobasename(const char *reponame); |
312 | 314 | ||
313 | extern int cgit_parse_snapshots_mask(const char *str); | 315 | extern int cgit_parse_snapshots_mask(const char *str); |
314 | 316 | ||
315 | extern int cgit_open_filter(struct cgit_filter *filter); | 317 | extern int cgit_open_filter(struct cgit_filter *filter); |
316 | extern int cgit_close_filter(struct cgit_filter *filter); | 318 | extern int cgit_close_filter(struct cgit_filter *filter); |
317 | 319 | ||
318 | extern int readfile(const char *path, char **buf, size_t *size); | 320 | extern int readfile(const char *path, char **buf, size_t *size); |
319 | 321 | ||
320 | extern char *expand_macros(const char *txt); | 322 | extern char *expand_macros(const char *txt); |
321 | 323 | ||
322 | #endif /* CGIT_H */ | 324 | #endif /* CGIT_H */ |
Binary files differ | |||
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index a832830..c3698a6 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -6,586 +6,595 @@ CGITRC(5) | |||
6 | 6 | ||
7 | 7 | ||
8 | NAME | 8 | NAME |
9 | ---- | 9 | ---- |
10 | cgitrc - runtime configuration for cgit | 10 | cgitrc - runtime configuration for cgit |
11 | 11 | ||
12 | 12 | ||
13 | SYNOPSIS | 13 | SYNOPSIS |
14 | -------- | 14 | -------- |
15 | Cgitrc contains all runtime settings for cgit, including the list of git | 15 | Cgitrc contains all runtime settings for cgit, including the list of git |
16 | repositories, formatted as a line-separated list of NAME=VALUE pairs. Blank | 16 | repositories, formatted as a line-separated list of NAME=VALUE pairs. Blank |
17 | lines, and lines starting with '#', are ignored. | 17 | lines, and lines starting with '#', are ignored. |
18 | 18 | ||
19 | 19 | ||
20 | LOCATION | 20 | LOCATION |
21 | -------- | 21 | -------- |
22 | The default location of cgitrc, defined at compile time, is /etc/cgitrc. At | 22 | The default location of cgitrc, defined at compile time, is /etc/cgitrc. At |
23 | runtime, cgit will consult the environment variable CGIT_CONFIG and, if | 23 | runtime, cgit will consult the environment variable CGIT_CONFIG and, if |
24 | defined, use its value instead. | 24 | defined, use its value instead. |
25 | 25 | ||
26 | 26 | ||
27 | GLOBAL SETTINGS | 27 | GLOBAL SETTINGS |
28 | --------------- | 28 | --------------- |
29 | about-filter:: | 29 | about-filter:: |
30 | Specifies a command which will be invoked to format the content of | 30 | Specifies a command which will be invoked to format the content of |
31 | about pages (both top-level and for each repository). The command will | 31 | about pages (both top-level and for each repository). The command will |
32 | get the content of the about-file on its STDIN, and the STDOUT from the | 32 | get the content of the about-file on its STDIN, and the STDOUT from the |
33 | command will be included verbatim on the about page. Default value: | 33 | command will be included verbatim on the about page. Default value: |
34 | none. | 34 | none. |
35 | 35 | ||
36 | agefile:: | 36 | agefile:: |
37 | Specifies a path, relative to each repository path, which can be used | 37 | Specifies a path, relative to each repository path, which can be used |
38 | to specify the date and time of the youngest commit in the repository. | 38 | to specify the date and time of the youngest commit in the repository. |
39 | The first line in the file is used as input to the "parse_date" | 39 | The first line in the file is used as input to the "parse_date" |
40 | function in libgit. Recommended timestamp-format is "yyyy-mm-dd | 40 | function in libgit. Recommended timestamp-format is "yyyy-mm-dd |
41 | hh:mm:ss". Default value: "info/web/last-modified". | 41 | hh:mm:ss". Default value: "info/web/last-modified". |
42 | 42 | ||
43 | cache-root:: | 43 | cache-root:: |
44 | Path used to store the cgit cache entries. Default value: | 44 | Path used to store the cgit cache entries. Default value: |
45 | "/var/cache/cgit". | 45 | "/var/cache/cgit". |
46 | 46 | ||
47 | cache-dynamic-ttl:: | 47 | cache-dynamic-ttl:: |
48 | Number which specifies the time-to-live, in minutes, for the cached | 48 | Number which specifies the time-to-live, in minutes, for the cached |
49 | version of repository pages accessed without a fixed SHA1. Default | 49 | version of repository pages accessed without a fixed SHA1. Default |
50 | value: "5". | 50 | value: "5". |
51 | 51 | ||
52 | cache-repo-ttl:: | 52 | cache-repo-ttl:: |
53 | Number which specifies the time-to-live, in minutes, for the cached | 53 | Number which specifies the time-to-live, in minutes, for the cached |
54 | version of the repository summary page. Default value: "5". | 54 | version of the repository summary page. Default value: "5". |
55 | 55 | ||
56 | cache-root-ttl:: | 56 | cache-root-ttl:: |
57 | Number which specifies the time-to-live, in minutes, for the cached | 57 | Number which specifies the time-to-live, in minutes, for the cached |
58 | version of the repository index page. Default value: "5". | 58 | version of the repository index page. Default value: "5". |
59 | 59 | ||
60 | cache-scanrc-ttl:: | 60 | cache-scanrc-ttl:: |
61 | Number which specifies the time-to-live, in minutes, for the result | 61 | Number which specifies the time-to-live, in minutes, for the result |
62 | of scanning a path for git repositories. Default value: "15". | 62 | of scanning a path for git repositories. Default value: "15". |
63 | 63 | ||
64 | cache-size:: | 64 | cache-size:: |
65 | The maximum number of entries in the cgit cache. Default value: "0" | 65 | The maximum number of entries in the cgit cache. Default value: "0" |
66 | (i.e. caching is disabled). | 66 | (i.e. caching is disabled). |
67 | 67 | ||
68 | cache-static-ttl:: | 68 | cache-static-ttl:: |
69 | Number which specifies the time-to-live, in minutes, for the cached | 69 | Number which specifies the time-to-live, in minutes, for the cached |
70 | version of repository pages accessed with a fixed SHA1. Default value: | 70 | version of repository pages accessed with a fixed SHA1. Default value: |
71 | "5". | 71 | "5". |
72 | 72 | ||
73 | clone-prefix:: | 73 | clone-prefix:: |
74 | Space-separated list of common prefixes which, when combined with a | 74 | Space-separated list of common prefixes which, when combined with a |
75 | repository url, generates valid clone urls for the repository. This | 75 | repository url, generates valid clone urls for the repository. This |
76 | setting is only used if `repo.clone-url` is unspecified. Default value: | 76 | setting is only used if `repo.clone-url` is unspecified. Default value: |
77 | none. | 77 | none. |
78 | 78 | ||
79 | commit-filter:: | 79 | commit-filter:: |
80 | Specifies a command which will be invoked to format commit messages. | 80 | Specifies a command which will be invoked to format commit messages. |
81 | The command will get the message on its STDIN, and the STDOUT from the | 81 | The command will get the message on its STDIN, and the STDOUT from the |
82 | command will be included verbatim as the commit message, i.e. this can | 82 | command will be included verbatim as the commit message, i.e. this can |
83 | be used to implement bugtracker integration. Default value: none. | 83 | be used to implement bugtracker integration. Default value: none. |
84 | 84 | ||
85 | css:: | 85 | css:: |
86 | Url which specifies the css document to include in all cgit pages. | 86 | Url which specifies the css document to include in all cgit pages. |
87 | Default value: "/cgit.css". | 87 | Default value: "/cgit.css". |
88 | 88 | ||
89 | embedded:: | 89 | embedded:: |
90 | Flag which, when set to "1", will make cgit generate a html fragment | 90 | Flag which, when set to "1", will make cgit generate a html fragment |
91 | suitable for embedding in other html pages. Default value: none. See | 91 | suitable for embedding in other html pages. Default value: none. See |
92 | also: "noheader". | 92 | also: "noheader". |
93 | 93 | ||
94 | enable-commit-graph:: | 94 | enable-commit-graph:: |
95 | Flag which, when set to "1", will make cgit print an ASCII-art commit | 95 | Flag which, when set to "1", will make cgit print an ASCII-art commit |
96 | history graph to the left of the commit messages in the repository | 96 | history graph to the left of the commit messages in the repository |
97 | log page. Default value: "0". | 97 | log page. Default value: "0". |
98 | 98 | ||
99 | enable-filter-overrides:: | 99 | enable-filter-overrides:: |
100 | Flag which, when set to "1", allows all filter settings to be | 100 | Flag which, when set to "1", allows all filter settings to be |
101 | overridden in repository-specific cgitrc files. Default value: none. | 101 | overridden in repository-specific cgitrc files. Default value: none. |
102 | 102 | ||
103 | enable-gitweb-owner:: | 103 | enable-gitweb-owner:: |
104 | If set to "1" and scan-path is enabled, we first check each repository | 104 | If set to "1" and scan-path is enabled, we first check each repository |
105 | for the git config value "gitweb.owner" to determine the owner. | 105 | for the git config value "gitweb.owner" to determine the owner. |
106 | Default value: "1". See also: scan-path. | 106 | Default value: "1". See also: scan-path. |
107 | 107 | ||
108 | enable-index-links:: | 108 | enable-index-links:: |
109 | Flag which, when set to "1", will make cgit generate extra links for | 109 | Flag which, when set to "1", will make cgit generate extra links for |
110 | each repo in the repository index (specifically, to the "summary", | 110 | each repo in the repository index (specifically, to the "summary", |
111 | "commit" and "tree" pages). Default value: "0". | 111 | "commit" and "tree" pages). Default value: "0". |
112 | 112 | ||
113 | enable-log-filecount:: | 113 | enable-log-filecount:: |
114 | Flag which, when set to "1", will make cgit print the number of | 114 | Flag which, when set to "1", will make cgit print the number of |
115 | modified files for each commit on the repository log page. Default | 115 | modified files for each commit on the repository log page. Default |
116 | value: "0". | 116 | value: "0". |
117 | 117 | ||
118 | enable-log-linecount:: | 118 | enable-log-linecount:: |
119 | Flag which, when set to "1", will make cgit print the number of added | 119 | Flag which, when set to "1", will make cgit print the number of added |
120 | and removed lines for each commit on the repository log page. Default | 120 | and removed lines for each commit on the repository log page. Default |
121 | value: "0". | 121 | value: "0". |
122 | 122 | ||
123 | enable-remote-branches:: | 123 | enable-remote-branches:: |
124 | Flag which, when set to "1", will make cgit display remote branches | 124 | Flag which, when set to "1", will make cgit display remote branches |
125 | in the summary and refs views. Default value: "0". See also: | 125 | in the summary and refs views. Default value: "0". See also: |
126 | "repo.enable-remote-branches". | 126 | "repo.enable-remote-branches". |
127 | 127 | ||
128 | enable-subject-links:: | 128 | enable-subject-links:: |
129 | Flag which, when set to "1", will make cgit use the subject of the | 129 | Flag which, when set to "1", will make cgit use the subject of the |
130 | parent commit as link text when generating links to parent commits | 130 | parent commit as link text when generating links to parent commits |
131 | in commit view. Default value: "0". See also: | 131 | in commit view. Default value: "0". See also: |
132 | "repo.enable-subject-links". | 132 | "repo.enable-subject-links". |
133 | 133 | ||
134 | enable-tree-linenumbers:: | 134 | enable-tree-linenumbers:: |
135 | Flag which, when set to "1", will make cgit generate linenumber links | 135 | Flag which, when set to "1", will make cgit generate linenumber links |
136 | for plaintext blobs printed in the tree view. Default value: "1". | 136 | for plaintext blobs printed in the tree view. Default value: "1". |
137 | 137 | ||
138 | favicon:: | 138 | favicon:: |
139 | Url used as link to a shortcut icon for cgit. If specified, it is | 139 | Url used as link to a shortcut icon for cgit. If specified, it is |
140 | suggested to use the value "/favicon.ico" since certain browsers will | 140 | suggested to use the value "/favicon.ico" since certain browsers will |
141 | ignore other values. Default value: none. | 141 | ignore other values. Default value: none. |
142 | 142 | ||
143 | footer:: | 143 | footer:: |
144 | The content of the file specified with this option will be included | 144 | The content of the file specified with this option will be included |
145 | verbatim at the bottom of all pages (i.e. it replaces the standard | 145 | verbatim at the bottom of all pages (i.e. it replaces the standard |
146 | "generated by..." message. Default value: none. | 146 | "generated by..." message. Default value: none. |
147 | 147 | ||
148 | head-include:: | 148 | head-include:: |
149 | The content of the file specified with this option will be included | 149 | The content of the file specified with this option will be included |
150 | verbatim in the html HEAD section on all pages. Default value: none. | 150 | verbatim in the html HEAD section on all pages. Default value: none. |
151 | 151 | ||
152 | header:: | 152 | header:: |
153 | The content of the file specified with this option will be included | 153 | The content of the file specified with this option will be included |
154 | verbatim at the top of all pages. Default value: none. | 154 | verbatim at the top of all pages. Default value: none. |
155 | 155 | ||
156 | include:: | 156 | include:: |
157 | Name of a configfile to include before the rest of the current config- | 157 | Name of a configfile to include before the rest of the current config- |
158 | file is parsed. Default value: none. | 158 | file is parsed. Default value: none. |
159 | 159 | ||
160 | index-header:: | 160 | index-header:: |
161 | The content of the file specified with this option will be included | 161 | The content of the file specified with this option will be included |
162 | verbatim above the repository index. This setting is deprecated, and | 162 | verbatim above the repository index. This setting is deprecated, and |
163 | will not be supported by cgit-1.0 (use root-readme instead). Default | 163 | will not be supported by cgit-1.0 (use root-readme instead). Default |
164 | value: none. | 164 | value: none. |
165 | 165 | ||
166 | index-info:: | 166 | index-info:: |
167 | The content of the file specified with this option will be included | 167 | The content of the file specified with this option will be included |
168 | verbatim below the heading on the repository index page. This setting | 168 | verbatim below the heading on the repository index page. This setting |
169 | is deprecated, and will not be supported by cgit-1.0 (use root-desc | 169 | is deprecated, and will not be supported by cgit-1.0 (use root-desc |
170 | instead). Default value: none. | 170 | instead). Default value: none. |
171 | 171 | ||
172 | local-time:: | 172 | local-time:: |
173 | Flag which, if set to "1", makes cgit print commit and tag times in the | 173 | Flag which, if set to "1", makes cgit print commit and tag times in the |
174 | servers timezone. Default value: "0". | 174 | servers timezone. Default value: "0". |
175 | 175 | ||
176 | logo:: | 176 | logo:: |
177 | Url which specifies the source of an image which will be used as a logo | 177 | Url which specifies the source of an image which will be used as a logo |
178 | on all cgit pages. Default value: "/cgit.png". | 178 | on all cgit pages. Default value: "/cgit.png". |
179 | 179 | ||
180 | logo-link:: | 180 | logo-link:: |
181 | Url loaded when clicking on the cgit logo image. If unspecified the | 181 | Url loaded when clicking on the cgit logo image. If unspecified the |
182 | calculated url of the repository index page will be used. Default | 182 | calculated url of the repository index page will be used. Default |
183 | value: none. | 183 | value: none. |
184 | 184 | ||
185 | max-atom-items:: | 185 | max-atom-items:: |
186 | Specifies the number of items to display in atom feeds view. Default | 186 | Specifies the number of items to display in atom feeds view. Default |
187 | value: "10". | 187 | value: "10". |
188 | 188 | ||
189 | max-commit-count:: | 189 | max-commit-count:: |
190 | Specifies the number of entries to list per page in "log" view. Default | 190 | Specifies the number of entries to list per page in "log" view. Default |
191 | value: "50". | 191 | value: "50". |
192 | 192 | ||
193 | max-message-length:: | 193 | max-message-length:: |
194 | Specifies the maximum number of commit message characters to display in | 194 | Specifies the maximum number of commit message characters to display in |
195 | "log" view. Default value: "80". | 195 | "log" view. Default value: "80". |
196 | 196 | ||
197 | max-repo-count:: | 197 | max-repo-count:: |
198 | Specifies the number of entries to list per page on therepository | 198 | Specifies the number of entries to list per page on therepository |
199 | index page. Default value: "50". | 199 | index page. Default value: "50". |
200 | 200 | ||
201 | max-repodesc-length:: | 201 | max-repodesc-length:: |
202 | Specifies the maximum number of repo description characters to display | 202 | Specifies the maximum number of repo description characters to display |
203 | on the repository index page. Default value: "80". | 203 | on the repository index page. Default value: "80". |
204 | 204 | ||
205 | max-blob-size:: | 205 | max-blob-size:: |
206 | Specifies the maximum size of a blob to display HTML for in KBytes. | 206 | Specifies the maximum size of a blob to display HTML for in KBytes. |
207 | Default value: "0" (limit disabled). | 207 | Default value: "0" (limit disabled). |
208 | 208 | ||
209 | max-stats:: | 209 | max-stats:: |
210 | Set the default maximum statistics period. Valid values are "week", | 210 | Set the default maximum statistics period. Valid values are "week", |
211 | "month", "quarter" and "year". If unspecified, statistics are | 211 | "month", "quarter" and "year". If unspecified, statistics are |
212 | disabled. Default value: none. See also: "repo.max-stats". | 212 | disabled. Default value: none. See also: "repo.max-stats". |
213 | 213 | ||
214 | mimetype.<ext>:: | 214 | mimetype.<ext>:: |
215 | Set the mimetype for the specified filename extension. This is used | 215 | Set the mimetype for the specified filename extension. This is used |
216 | by the `plain` command when returning blob content. | 216 | by the `plain` command when returning blob content. |
217 | 217 | ||
218 | module-link:: | 218 | module-link:: |
219 | Text which will be used as the formatstring for a hyperlink when a | 219 | Text which will be used as the formatstring for a hyperlink when a |
220 | submodule is printed in a directory listing. The arguments for the | 220 | submodule is printed in a directory listing. The arguments for the |
221 | formatstring are the path and SHA1 of the submodule commit. Default | 221 | formatstring are the path and SHA1 of the submodule commit. Default |
222 | value: "./?repo=%s&page=commit&id=%s" | 222 | value: "./?repo=%s&page=commit&id=%s" |
223 | 223 | ||
224 | nocache:: | 224 | nocache:: |
225 | If set to the value "1" caching will be disabled. This settings is | 225 | If set to the value "1" caching will be disabled. This settings is |
226 | deprecated, and will not be honored starting with cgit-1.0. Default | 226 | deprecated, and will not be honored starting with cgit-1.0. Default |
227 | value: "0". | 227 | value: "0". |
228 | 228 | ||
229 | noplainemail:: | 229 | noplainemail:: |
230 | If set to "1" showing full author email adresses will be disabled. | 230 | If set to "1" showing full author email adresses will be disabled. |
231 | Default value: "0". | 231 | Default value: "0". |
232 | 232 | ||
233 | noheader:: | 233 | noheader:: |
234 | Flag which, when set to "1", will make cgit omit the standard header | 234 | Flag which, when set to "1", will make cgit omit the standard header |
235 | on all pages. Default value: none. See also: "embedded". | 235 | on all pages. Default value: none. See also: "embedded". |
236 | 236 | ||
237 | project-list:: | 237 | project-list:: |
238 | A list of subdirectories inside of scan-path, relative to it, that | 238 | A list of subdirectories inside of scan-path, relative to it, that |
239 | should loaded as git repositories. This must be defined prior to | 239 | should loaded as git repositories. This must be defined prior to |
240 | scan-path. Default value: none. See also: scan-path. | 240 | scan-path. Default value: none. See also: scan-path. |
241 | 241 | ||
242 | readme:: | 242 | readme:: |
243 | Text which will be used as default value for "repo.readme". Default | 243 | Text which will be used as default value for "repo.readme". Default |
244 | value: none. | 244 | value: none. |
245 | 245 | ||
246 | remove-suffix:: | 246 | remove-suffix:: |
247 | If set to "1" and scan-path is enabled, if any repositories are found | 247 | If set to "1" and scan-path is enabled, if any repositories are found |
248 | with a suffix of ".git", this suffix will be removed for the url and | 248 | with a suffix of ".git", this suffix will be removed for the url and |
249 | name. Default value: "0". See also: scan-path. | 249 | name. Default value: "0". See also: scan-path. |
250 | 250 | ||
251 | renamelimit:: | 251 | renamelimit:: |
252 | Maximum number of files to consider when detecting renames. The value | 252 | Maximum number of files to consider when detecting renames. The value |
253 | "-1" uses the compiletime value in git (for further info, look at | 253 | "-1" uses the compiletime value in git (for further info, look at |
254 | `man git-diff`). Default value: "-1". | 254 | `man git-diff`). Default value: "-1". |
255 | 255 | ||
256 | repo.group:: | 256 | repo.group:: |
257 | Legacy alias for "section". This option is deprecated and will not be | 257 | Legacy alias for "section". This option is deprecated and will not be |
258 | supported in cgit-1.0. | 258 | supported in cgit-1.0. |
259 | 259 | ||
260 | robots:: | 260 | robots:: |
261 | Text used as content for the "robots" meta-tag. Default value: | 261 | Text used as content for the "robots" meta-tag. Default value: |
262 | "index, nofollow". | 262 | "index, nofollow". |
263 | 263 | ||
264 | root-desc:: | 264 | root-desc:: |
265 | Text printed below the heading on the repository index page. Default | 265 | Text printed below the heading on the repository index page. Default |
266 | value: "a fast webinterface for the git dscm". | 266 | value: "a fast webinterface for the git dscm". |
267 | 267 | ||
268 | root-readme:: | 268 | root-readme:: |
269 | The content of the file specified with this option will be included | 269 | The content of the file specified with this option will be included |
270 | verbatim below the "about" link on the repository index page. Default | 270 | verbatim below the "about" link on the repository index page. Default |
271 | value: none. | 271 | value: none. |
272 | 272 | ||
273 | root-title:: | 273 | root-title:: |
274 | Text printed as heading on the repository index page. Default value: | 274 | Text printed as heading on the repository index page. Default value: |
275 | "Git Repository Browser". | 275 | "Git Repository Browser". |
276 | 276 | ||
277 | scan-hidden-path:: | 277 | scan-hidden-path:: |
278 | If set to "1" and scan-path is enabled, scan-path will recurse into | 278 | If set to "1" and scan-path is enabled, scan-path will recurse into |
279 | directories whose name starts with a period ('.'). Otherwise, | 279 | directories whose name starts with a period ('.'). Otherwise, |
280 | scan-path will stay away from such directories (considered as | 280 | scan-path will stay away from such directories (considered as |
281 | "hidden"). Note that this does not apply to the ".git" directory in | 281 | "hidden"). Note that this does not apply to the ".git" directory in |
282 | non-bare repos. This must be defined prior to scan-path. | 282 | non-bare repos. This must be defined prior to scan-path. |
283 | Default value: 0. See also: scan-path. | 283 | Default value: 0. See also: scan-path. |
284 | 284 | ||
285 | scan-path:: | 285 | scan-path:: |
286 | A path which will be scanned for repositories. If caching is enabled, | 286 | A path which will be scanned for repositories. If caching is enabled, |
287 | the result will be cached as a cgitrc include-file in the cache | 287 | the result will be cached as a cgitrc include-file in the cache |
288 | directory. If project-list has been defined prior to scan-path, | 288 | directory. If project-list has been defined prior to scan-path, |
289 | scan-path loads only the directories listed in the file pointed to by | 289 | scan-path loads only the directories listed in the file pointed to by |
290 | project-list. Default value: none. See also: cache-scanrc-ttl, | 290 | project-list. Default value: none. See also: cache-scanrc-ttl, |
291 | project-list. | 291 | project-list. |
292 | 292 | ||
293 | section:: | 293 | section:: |
294 | The name of the current repository section - all repositories defined | 294 | The name of the current repository section - all repositories defined |
295 | after this option will inherit the current section name. Default value: | 295 | after this option will inherit the current section name. Default value: |
296 | none. | 296 | none. |
297 | 297 | ||
298 | section-from-path:: | 298 | section-from-path:: |
299 | A number which, if specified before scan-path, specifies how many | 299 | A number which, if specified before scan-path, specifies how many |
300 | path elements from each repo path to use as a default section name. | 300 | path elements from each repo path to use as a default section name. |
301 | If negative, cgit will discard the specified number of path elements | 301 | If negative, cgit will discard the specified number of path elements |
302 | above the repo directory. Default value: 0. | 302 | above the repo directory. Default value: 0. |
303 | 303 | ||
304 | side-by-side-diffs:: | 304 | side-by-side-diffs:: |
305 | If set to "1" shows side-by-side diffs instead of unidiffs per | 305 | If set to "1" shows side-by-side diffs instead of unidiffs per |
306 | default. Default value: "0". | 306 | default. Default value: "0". |
307 | 307 | ||
308 | snapshots:: | 308 | snapshots:: |
309 | Text which specifies the default set of snapshot formats generated by | 309 | Text which specifies the default set of snapshot formats generated by |
310 | cgit. The value is a space-separated list of zero or more of the | 310 | cgit. The value is a space-separated list of zero or more of the |
311 | values "tar", "tar.gz", "tar.bz2" and "zip". Default value: none. | 311 | values "tar", "tar.gz", "tar.bz2" and "zip". Default value: none. |
312 | 312 | ||
313 | source-filter:: | 313 | source-filter:: |
314 | Specifies a command which will be invoked to format plaintext blobs | 314 | Specifies a command which will be invoked to format plaintext blobs |
315 | in the tree view. The command will get the blob content on its STDIN | 315 | in the tree view. The command will get the blob content on its STDIN |
316 | and the name of the blob as its only command line argument. The STDOUT | 316 | and the name of the blob as its only command line argument. The STDOUT |
317 | from the command will be included verbatim as the blob contents, i.e. | 317 | from the command will be included verbatim as the blob contents, i.e. |
318 | this can be used to implement e.g. syntax highlighting. Default value: | 318 | this can be used to implement e.g. syntax highlighting. Default value: |
319 | none. | 319 | none. |
320 | 320 | ||
321 | summary-branches:: | 321 | summary-branches:: |
322 | Specifies the number of branches to display in the repository "summary" | 322 | Specifies the number of branches to display in the repository "summary" |
323 | view. Default value: "10". | 323 | view. Default value: "10". |
324 | 324 | ||
325 | summary-log:: | 325 | summary-log:: |
326 | Specifies the number of log entries to display in the repository | 326 | Specifies the number of log entries to display in the repository |
327 | "summary" view. Default value: "10". | 327 | "summary" view. Default value: "10". |
328 | 328 | ||
329 | summary-tags:: | 329 | summary-tags:: |
330 | Specifies the number of tags to display in the repository "summary" | 330 | Specifies the number of tags to display in the repository "summary" |
331 | view. Default value: "10". | 331 | view. Default value: "10". |
332 | 332 | ||
333 | strict-export:: | 333 | strict-export:: |
334 | Filename which, if specified, needs to be present within the repository | 334 | Filename which, if specified, needs to be present within the repository |
335 | for cgit to allow access to that repository. This can be used to emulate | 335 | for cgit to allow access to that repository. This can be used to emulate |
336 | gitweb's EXPORT_OK and STRICT_EXPORT functionality and limit cgit's | 336 | gitweb's EXPORT_OK and STRICT_EXPORT functionality and limit cgit's |
337 | repositories to match those exported by git-daemon. This option MUST come | 337 | repositories to match those exported by git-daemon. This option MUST come |
338 | before 'scan-path'. | 338 | before 'scan-path'. |
339 | 339 | ||
340 | virtual-root:: | 340 | virtual-root:: |
341 | Url which, if specified, will be used as root for all cgit links. It | 341 | Url which, if specified, will be used as root for all cgit links. It |
342 | will also cause cgit to generate 'virtual urls', i.e. urls like | 342 | will also cause cgit to generate 'virtual urls', i.e. urls like |
343 | '/cgit/tree/README' as opposed to '?r=cgit&p=tree&path=README'. Default | 343 | '/cgit/tree/README' as opposed to '?r=cgit&p=tree&path=README'. Default |
344 | value: none. | 344 | value: none. |
345 | NOTE: cgit has recently learned how to use PATH_INFO to achieve the | 345 | NOTE: cgit has recently learned how to use PATH_INFO to achieve the |
346 | same kind of virtual urls, so this option will probably be deprecated. | 346 | same kind of virtual urls, so this option will probably be deprecated. |
347 | 347 | ||
348 | REPOSITORY SETTINGS | 348 | REPOSITORY SETTINGS |
349 | ------------------- | 349 | ------------------- |
350 | repo.about-filter:: | 350 | repo.about-filter:: |
351 | Override the default about-filter. Default value: none. See also: | 351 | Override the default about-filter. Default value: none. See also: |
352 | "enable-filter-overrides". | 352 | "enable-filter-overrides". |
353 | 353 | ||
354 | repo.clone-url:: | 354 | repo.clone-url:: |
355 | A list of space-separated urls which can be used to clone this repo. | 355 | A list of space-separated urls which can be used to clone this repo. |
356 | Default value: none. | 356 | Default value: none. |
357 | 357 | ||
358 | repo.commit-filter:: | 358 | repo.commit-filter:: |
359 | Override the default commit-filter. Default value: none. See also: | 359 | Override the default commit-filter. Default value: none. See also: |
360 | "enable-filter-overrides". | 360 | "enable-filter-overrides". |
361 | 361 | ||
362 | repo.defbranch:: | 362 | repo.defbranch:: |
363 | The name of the default branch for this repository. If no such branch | 363 | The name of the default branch for this repository. If no such branch |
364 | exists in the repository, the first branch name (when sorted) is used | 364 | exists in the repository, the first branch name (when sorted) is used |
365 | as default instead. Default value: "master". | 365 | as default instead. Default value: "master". |
366 | 366 | ||
367 | repo.desc:: | 367 | repo.desc:: |
368 | The value to show as repository description. Default value: none. | 368 | The value to show as repository description. Default value: none. |
369 | 369 | ||
370 | repo.enable-commit-graph:: | 370 | repo.enable-commit-graph:: |
371 | A flag which can be used to disable the global setting | 371 | A flag which can be used to disable the global setting |
372 | `enable-commit-graph'. Default value: none. | 372 | `enable-commit-graph'. Default value: none. |
373 | 373 | ||
374 | repo.enable-log-filecount:: | 374 | repo.enable-log-filecount:: |
375 | A flag which can be used to disable the global setting | 375 | A flag which can be used to disable the global setting |
376 | `enable-log-filecount'. Default value: none. | 376 | `enable-log-filecount'. Default value: none. |
377 | 377 | ||
378 | repo.enable-log-linecount:: | 378 | repo.enable-log-linecount:: |
379 | A flag which can be used to disable the global setting | 379 | A flag which can be used to disable the global setting |
380 | `enable-log-linecount'. Default value: none. | 380 | `enable-log-linecount'. Default value: none. |
381 | 381 | ||
382 | repo.enable-remote-branches:: | 382 | repo.enable-remote-branches:: |
383 | Flag which, when set to "1", will make cgit display remote branches | 383 | Flag which, when set to "1", will make cgit display remote branches |
384 | in the summary and refs views. Default value: <enable-remote-branches>. | 384 | in the summary and refs views. Default value: <enable-remote-branches>. |
385 | 385 | ||
386 | repo.enable-subject-links:: | 386 | repo.enable-subject-links:: |
387 | A flag which can be used to override the global setting | 387 | A flag which can be used to override the global setting |
388 | `enable-subject-links'. Default value: none. | 388 | `enable-subject-links'. Default value: none. |
389 | 389 | ||
390 | repo.logo:: | ||
391 | Url which specifies the source of an image which will be used as a logo | ||
392 | on this repo's pages. Default value: global logo. | ||
393 | |||
394 | repo.logo-link:: | ||
395 | Url loaded when clicking on the cgit logo image. If unspecified the | ||
396 | calculated url of the repository index page will be used. Default | ||
397 | value: global logo-link. | ||
398 | |||
390 | repo.max-stats:: | 399 | repo.max-stats:: |
391 | Override the default maximum statistics period. Valid values are equal | 400 | Override the default maximum statistics period. Valid values are equal |
392 | to the values specified for the global "max-stats" setting. Default | 401 | to the values specified for the global "max-stats" setting. Default |
393 | value: none. | 402 | value: none. |
394 | 403 | ||
395 | repo.name:: | 404 | repo.name:: |
396 | The value to show as repository name. Default value: <repo.url>. | 405 | The value to show as repository name. Default value: <repo.url>. |
397 | 406 | ||
398 | repo.owner:: | 407 | repo.owner:: |
399 | A value used to identify the owner of the repository. Default value: | 408 | A value used to identify the owner of the repository. Default value: |
400 | none. | 409 | none. |
401 | 410 | ||
402 | repo.path:: | 411 | repo.path:: |
403 | An absolute path to the repository directory. For non-bare repositories | 412 | An absolute path to the repository directory. For non-bare repositories |
404 | this is the .git-directory. Default value: none. | 413 | this is the .git-directory. Default value: none. |
405 | 414 | ||
406 | repo.readme:: | 415 | repo.readme:: |
407 | A path (relative to <repo.path>) which specifies a file to include | 416 | A path (relative to <repo.path>) which specifies a file to include |
408 | verbatim as the "About" page for this repo. You may also specify a | 417 | verbatim as the "About" page for this repo. You may also specify a |
409 | git refspec by head or by hash by prepending the refspec followed by | 418 | git refspec by head or by hash by prepending the refspec followed by |
410 | a colon. For example, "master:docs/readme.mkd" Default value: <readme>. | 419 | a colon. For example, "master:docs/readme.mkd" Default value: <readme>. |
411 | 420 | ||
412 | repo.snapshots:: | 421 | repo.snapshots:: |
413 | A mask of allowed snapshot-formats for this repo, restricted by the | 422 | A mask of allowed snapshot-formats for this repo, restricted by the |
414 | "snapshots" global setting. Default value: <snapshots>. | 423 | "snapshots" global setting. Default value: <snapshots>. |
415 | 424 | ||
416 | repo.section:: | 425 | repo.section:: |
417 | Override the current section name for this repository. Default value: | 426 | Override the current section name for this repository. Default value: |
418 | none. | 427 | none. |
419 | 428 | ||
420 | repo.source-filter:: | 429 | repo.source-filter:: |
421 | Override the default source-filter. Default value: none. See also: | 430 | Override the default source-filter. Default value: none. See also: |
422 | "enable-filter-overrides". | 431 | "enable-filter-overrides". |
423 | 432 | ||
424 | repo.url:: | 433 | repo.url:: |
425 | The relative url used to access the repository. This must be the first | 434 | The relative url used to access the repository. This must be the first |
426 | setting specified for each repo. Default value: none. | 435 | setting specified for each repo. Default value: none. |
427 | 436 | ||
428 | 437 | ||
429 | REPOSITORY-SPECIFIC CGITRC FILE | 438 | REPOSITORY-SPECIFIC CGITRC FILE |
430 | ------------------------------- | 439 | ------------------------------- |
431 | When the option "scan-path" is used to auto-discover git repositories, cgit | 440 | When the option "scan-path" is used to auto-discover git repositories, cgit |
432 | will try to parse the file "cgitrc" within any found repository. Such a | 441 | will try to parse the file "cgitrc" within any found repository. Such a |
433 | repo-specific config file may contain any of the repo-specific options | 442 | repo-specific config file may contain any of the repo-specific options |
434 | described above, except "repo.url" and "repo.path". Additionally, the "filter" | 443 | described above, except "repo.url" and "repo.path". Additionally, the "filter" |
435 | options are only acknowledged in repo-specific config files when | 444 | options are only acknowledged in repo-specific config files when |
436 | "enable-filter-overrides" is set to "1". | 445 | "enable-filter-overrides" is set to "1". |
437 | 446 | ||
438 | Note: the "repo." prefix is dropped from the option names in repo-specific | 447 | Note: the "repo." prefix is dropped from the option names in repo-specific |
439 | config files, e.g. "repo.desc" becomes "desc". | 448 | config files, e.g. "repo.desc" becomes "desc". |
440 | 449 | ||
441 | 450 | ||
442 | EXAMPLE CGITRC FILE | 451 | EXAMPLE CGITRC FILE |
443 | ------------------- | 452 | ------------------- |
444 | 453 | ||
445 | .... | 454 | .... |
446 | # Enable caching of up to 1000 output entriess | 455 | # Enable caching of up to 1000 output entriess |
447 | cache-size=1000 | 456 | cache-size=1000 |
448 | 457 | ||
449 | 458 | ||
450 | # Specify some default clone prefixes | 459 | # Specify some default clone prefixes |
451 | clone-prefix=git://example.com ssh://example.com/pub/git http://example.com/git | 460 | clone-prefix=git://example.com ssh://example.com/pub/git http://example.com/git |
452 | 461 | ||
453 | # Specify the css url | 462 | # Specify the css url |
454 | css=/css/cgit.css | 463 | css=/css/cgit.css |
455 | 464 | ||
456 | 465 | ||
457 | # Show extra links for each repository on the index page | 466 | # Show extra links for each repository on the index page |
458 | enable-index-links=1 | 467 | enable-index-links=1 |
459 | 468 | ||
460 | 469 | ||
461 | # Enable ASCII art commit history graph on the log pages | 470 | # Enable ASCII art commit history graph on the log pages |
462 | enable-commit-graph=1 | 471 | enable-commit-graph=1 |
463 | 472 | ||
464 | 473 | ||
465 | # Show number of affected files per commit on the log pages | 474 | # Show number of affected files per commit on the log pages |
466 | enable-log-filecount=1 | 475 | enable-log-filecount=1 |
467 | 476 | ||
468 | 477 | ||
469 | # Show number of added/removed lines per commit on the log pages | 478 | # Show number of added/removed lines per commit on the log pages |
470 | enable-log-linecount=1 | 479 | enable-log-linecount=1 |
471 | 480 | ||
472 | 481 | ||
473 | # Add a cgit favicon | 482 | # Add a cgit favicon |
474 | favicon=/favicon.ico | 483 | favicon=/favicon.ico |
475 | 484 | ||
476 | 485 | ||
477 | # Use a custom logo | 486 | # Use a custom logo |
478 | logo=/img/mylogo.png | 487 | logo=/img/mylogo.png |
479 | 488 | ||
480 | 489 | ||
481 | # Enable statistics per week, month and quarter | 490 | # Enable statistics per week, month and quarter |
482 | max-stats=quarter | 491 | max-stats=quarter |
483 | 492 | ||
484 | 493 | ||
485 | # Set the title and heading of the repository index page | 494 | # Set the title and heading of the repository index page |
486 | root-title=example.com git repositories | 495 | root-title=example.com git repositories |
487 | 496 | ||
488 | 497 | ||
489 | # Set a subheading for the repository index page | 498 | # Set a subheading for the repository index page |
490 | root-desc=tracking the foobar development | 499 | root-desc=tracking the foobar development |
491 | 500 | ||
492 | 501 | ||
493 | # Include some more info about example.com on the index page | 502 | # Include some more info about example.com on the index page |
494 | root-readme=/var/www/htdocs/about.html | 503 | root-readme=/var/www/htdocs/about.html |
495 | 504 | ||
496 | 505 | ||
497 | # Allow download of tar.gz, tar.bz2 and zip-files | 506 | # Allow download of tar.gz, tar.bz2 and zip-files |
498 | snapshots=tar.gz tar.bz2 zip | 507 | snapshots=tar.gz tar.bz2 zip |
499 | 508 | ||
500 | 509 | ||
501 | ## | 510 | ## |
502 | ## List of common mimetypes | 511 | ## List of common mimetypes |
503 | ## | 512 | ## |
504 | 513 | ||
505 | mimetype.gif=image/gif | 514 | mimetype.gif=image/gif |
506 | mimetype.html=text/html | 515 | mimetype.html=text/html |
507 | mimetype.jpg=image/jpeg | 516 | mimetype.jpg=image/jpeg |
508 | mimetype.jpeg=image/jpeg | 517 | mimetype.jpeg=image/jpeg |
509 | mimetype.pdf=application/pdf | 518 | mimetype.pdf=application/pdf |
510 | mimetype.png=image/png | 519 | mimetype.png=image/png |
511 | mimetype.svg=image/svg+xml | 520 | mimetype.svg=image/svg+xml |
512 | 521 | ||
513 | 522 | ||
514 | ## | 523 | ## |
515 | ## List of repositories. | 524 | ## List of repositories. |
516 | ## PS: Any repositories listed when section is unset will not be | 525 | ## PS: Any repositories listed when section is unset will not be |
517 | ## displayed under a section heading | 526 | ## displayed under a section heading |
518 | ## PPS: This list could be kept in a different file (e.g. '/etc/cgitrepos') | 527 | ## PPS: This list could be kept in a different file (e.g. '/etc/cgitrepos') |
519 | ## and included like this: | 528 | ## and included like this: |
520 | ## include=/etc/cgitrepos | 529 | ## include=/etc/cgitrepos |
521 | ## | 530 | ## |
522 | 531 | ||
523 | 532 | ||
524 | repo.url=foo | 533 | repo.url=foo |
525 | repo.path=/pub/git/foo.git | 534 | repo.path=/pub/git/foo.git |
526 | repo.desc=the master foo repository | 535 | repo.desc=the master foo repository |
527 | repo.owner=fooman@example.com | 536 | repo.owner=fooman@example.com |
528 | repo.readme=info/web/about.html | 537 | repo.readme=info/web/about.html |
529 | 538 | ||
530 | 539 | ||
531 | repo.url=bar | 540 | repo.url=bar |
532 | repo.path=/pub/git/bar.git | 541 | repo.path=/pub/git/bar.git |
533 | repo.desc=the bars for your foo | 542 | repo.desc=the bars for your foo |
534 | repo.owner=barman@example.com | 543 | repo.owner=barman@example.com |
535 | repo.readme=info/web/about.html | 544 | repo.readme=info/web/about.html |
536 | 545 | ||
537 | 546 | ||
538 | # The next repositories will be displayed under the 'extras' heading | 547 | # The next repositories will be displayed under the 'extras' heading |
539 | section=extras | 548 | section=extras |
540 | 549 | ||
541 | 550 | ||
542 | repo.url=baz | 551 | repo.url=baz |
543 | repo.path=/pub/git/baz.git | 552 | repo.path=/pub/git/baz.git |
544 | repo.desc=a set of extensions for bar users | 553 | repo.desc=a set of extensions for bar users |
545 | 554 | ||
546 | repo.url=wiz | 555 | repo.url=wiz |
547 | repo.path=/pub/git/wiz.git | 556 | repo.path=/pub/git/wiz.git |
548 | repo.desc=the wizard of foo | 557 | repo.desc=the wizard of foo |
549 | 558 | ||
550 | 559 | ||
551 | # Add some mirrored repositories | 560 | # Add some mirrored repositories |
552 | section=mirrors | 561 | section=mirrors |
553 | 562 | ||
554 | 563 | ||
555 | repo.url=git | 564 | repo.url=git |
556 | repo.path=/pub/git/git.git | 565 | repo.path=/pub/git/git.git |
557 | repo.desc=the dscm | 566 | repo.desc=the dscm |
558 | 567 | ||
559 | 568 | ||
560 | repo.url=linux | 569 | repo.url=linux |
561 | repo.path=/pub/git/linux.git | 570 | repo.path=/pub/git/linux.git |
562 | repo.desc=the kernel | 571 | repo.desc=the kernel |
563 | 572 | ||
564 | # Disable adhoc downloads of this repo | 573 | # Disable adhoc downloads of this repo |
565 | repo.snapshots=0 | 574 | repo.snapshots=0 |
566 | 575 | ||
567 | # Disable line-counts for this repo | 576 | # Disable line-counts for this repo |
568 | repo.enable-log-linecount=0 | 577 | repo.enable-log-linecount=0 |
569 | 578 | ||
570 | # Restrict the max statistics period for this repo | 579 | # Restrict the max statistics period for this repo |
571 | repo.max-stats=month | 580 | repo.max-stats=month |
572 | .... | 581 | .... |
573 | 582 | ||
574 | 583 | ||
575 | BUGS | 584 | BUGS |
576 | ---- | 585 | ---- |
577 | Comments currently cannot appear on the same line as a setting; the comment | 586 | Comments currently cannot appear on the same line as a setting; the comment |
578 | will be included as part of the value. E.g. this line: | 587 | will be included as part of the value. E.g. this line: |
579 | 588 | ||
580 | robots=index # allow indexing | 589 | robots=index # allow indexing |
581 | 590 | ||
582 | will generate the following html element: | 591 | will generate the following html element: |
583 | 592 | ||
584 | <meta name='robots' content='index # allow indexing'/> | 593 | <meta name='robots' content='index # allow indexing'/> |
585 | 594 | ||
586 | 595 | ||
587 | 596 | ||
588 | AUTHOR | 597 | AUTHOR |
589 | ------ | 598 | ------ |
590 | Lars Hjemli <hjemli@gmail.com> | 599 | Lars Hjemli <hjemli@gmail.com> |
591 | Jason A. Donenfeld <Jason@zx2c4.com> | 600 | Jason A. Donenfeld <Jason@zx2c4.com> |
@@ -1,371 +1,383 @@ | |||
1 | /* ui-diff.c: show diff between two blobs | 1 | /* ui-diff.c: show diff between two blobs |
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 "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 | #include "ui-ssdiff.h" |
13 | 13 | ||
14 | unsigned char old_rev_sha1[20]; | 14 | unsigned char old_rev_sha1[20]; |
15 | unsigned char new_rev_sha1[20]; | 15 | unsigned char new_rev_sha1[20]; |
16 | 16 | ||
17 | static int files, slots; | 17 | static int files, slots; |
18 | static int total_adds, total_rems, max_changes; | 18 | static int total_adds, total_rems, max_changes; |
19 | static int lines_added, lines_removed; | 19 | static int lines_added, lines_removed; |
20 | 20 | ||
21 | static struct fileinfo { | 21 | static struct fileinfo { |
22 | char status; | 22 | char status; |
23 | unsigned char old_sha1[20]; | 23 | unsigned char old_sha1[20]; |
24 | unsigned char new_sha1[20]; | 24 | unsigned char new_sha1[20]; |
25 | unsigned short old_mode; | 25 | unsigned short old_mode; |
26 | unsigned short new_mode; | 26 | unsigned short new_mode; |
27 | char *old_path; | 27 | char *old_path; |
28 | char *new_path; | 28 | char *new_path; |
29 | unsigned int added; | 29 | unsigned int added; |
30 | unsigned int removed; | 30 | unsigned int removed; |
31 | unsigned long old_size; | 31 | unsigned long old_size; |
32 | unsigned long new_size; | 32 | unsigned long new_size; |
33 | int binary:1; | 33 | int binary:1; |
34 | } *items; | 34 | } *items; |
35 | 35 | ||
36 | static int use_ssdiff = 0; | 36 | static int use_ssdiff = 0; |
37 | static struct diff_filepair *current_filepair; | ||
38 | |||
39 | struct diff_filespec *cgit_get_current_old_file(void) | ||
40 | { | ||
41 | return current_filepair->one; | ||
42 | } | ||
43 | |||
44 | struct diff_filespec *cgit_get_current_new_file(void) | ||
45 | { | ||
46 | return current_filepair->two; | ||
47 | } | ||
37 | 48 | ||
38 | static void print_fileinfo(struct fileinfo *info) | 49 | static void print_fileinfo(struct fileinfo *info) |
39 | { | 50 | { |
40 | char *class; | 51 | char *class; |
41 | 52 | ||
42 | switch (info->status) { | 53 | switch (info->status) { |
43 | case DIFF_STATUS_ADDED: | 54 | case DIFF_STATUS_ADDED: |
44 | class = "add"; | 55 | class = "add"; |
45 | break; | 56 | break; |
46 | case DIFF_STATUS_COPIED: | 57 | case DIFF_STATUS_COPIED: |
47 | class = "cpy"; | 58 | class = "cpy"; |
48 | break; | 59 | break; |
49 | case DIFF_STATUS_DELETED: | 60 | case DIFF_STATUS_DELETED: |
50 | class = "del"; | 61 | class = "del"; |
51 | break; | 62 | break; |
52 | case DIFF_STATUS_MODIFIED: | 63 | case DIFF_STATUS_MODIFIED: |
53 | class = "upd"; | 64 | class = "upd"; |
54 | break; | 65 | break; |
55 | case DIFF_STATUS_RENAMED: | 66 | case DIFF_STATUS_RENAMED: |
56 | class = "mov"; | 67 | class = "mov"; |
57 | break; | 68 | break; |
58 | case DIFF_STATUS_TYPE_CHANGED: | 69 | case DIFF_STATUS_TYPE_CHANGED: |
59 | class = "typ"; | 70 | class = "typ"; |
60 | break; | 71 | break; |
61 | case DIFF_STATUS_UNKNOWN: | 72 | case DIFF_STATUS_UNKNOWN: |
62 | class = "unk"; | 73 | class = "unk"; |
63 | break; | 74 | break; |
64 | case DIFF_STATUS_UNMERGED: | 75 | case DIFF_STATUS_UNMERGED: |
65 | class = "stg"; | 76 | class = "stg"; |
66 | break; | 77 | break; |
67 | default: | 78 | default: |
68 | die("bug: unhandled diff status %c", info->status); | 79 | die("bug: unhandled diff status %c", info->status); |
69 | } | 80 | } |
70 | 81 | ||
71 | html("<tr>"); | 82 | html("<tr>"); |
72 | htmlf("<td class='mode'>"); | 83 | htmlf("<td class='mode'>"); |
73 | if (is_null_sha1(info->new_sha1)) { | 84 | if (is_null_sha1(info->new_sha1)) { |
74 | cgit_print_filemode(info->old_mode); | 85 | cgit_print_filemode(info->old_mode); |
75 | } else { | 86 | } else { |
76 | cgit_print_filemode(info->new_mode); | 87 | cgit_print_filemode(info->new_mode); |
77 | } | 88 | } |
78 | 89 | ||
79 | if (info->old_mode != info->new_mode && | 90 | if (info->old_mode != info->new_mode && |
80 | !is_null_sha1(info->old_sha1) && | 91 | !is_null_sha1(info->old_sha1) && |
81 | !is_null_sha1(info->new_sha1)) { | 92 | !is_null_sha1(info->new_sha1)) { |
82 | html("<span class='modechange'>["); | 93 | html("<span class='modechange'>["); |
83 | cgit_print_filemode(info->old_mode); | 94 | cgit_print_filemode(info->old_mode); |
84 | html("]</span>"); | 95 | html("]</span>"); |
85 | } | 96 | } |
86 | htmlf("</td><td class='%s'>", class); | 97 | htmlf("</td><td class='%s'>", class); |
87 | cgit_diff_link(info->new_path, NULL, NULL, ctx.qry.head, ctx.qry.sha1, | 98 | cgit_diff_link(info->new_path, NULL, NULL, ctx.qry.head, ctx.qry.sha1, |
88 | ctx.qry.sha2, info->new_path, 0); | 99 | ctx.qry.sha2, info->new_path, 0); |
89 | if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED) | 100 | if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED) |
90 | htmlf(" (%s from %s)", | 101 | htmlf(" (%s from %s)", |
91 | info->status == DIFF_STATUS_COPIED ? "copied" : "renamed", | 102 | info->status == DIFF_STATUS_COPIED ? "copied" : "renamed", |
92 | info->old_path); | 103 | info->old_path); |
93 | html("</td><td class='right'>"); | 104 | html("</td><td class='right'>"); |
94 | if (info->binary) { | 105 | if (info->binary) { |
95 | htmlf("bin</td><td class='graph'>%ld -> %ld bytes", | 106 | htmlf("bin</td><td class='graph'>%ld -> %ld bytes", |
96 | info->old_size, info->new_size); | 107 | info->old_size, info->new_size); |
97 | return; | 108 | return; |
98 | } | 109 | } |
99 | htmlf("%d", info->added + info->removed); | 110 | htmlf("%d", info->added + info->removed); |
100 | html("</td><td class='graph'>"); | 111 | html("</td><td class='graph'>"); |
101 | htmlf("<table summary='file diffstat' width='%d%%'><tr>", (max_changes > 100 ? 100 : max_changes)); | 112 | htmlf("<table summary='file diffstat' width='%d%%'><tr>", (max_changes > 100 ? 100 : max_changes)); |
102 | htmlf("<td class='add' style='width: %.1f%%;'/>", | 113 | htmlf("<td class='add' style='width: %.1f%%;'/>", |
103 | info->added * 100.0 / max_changes); | 114 | info->added * 100.0 / max_changes); |
104 | htmlf("<td class='rem' style='width: %.1f%%;'/>", | 115 | htmlf("<td class='rem' style='width: %.1f%%;'/>", |
105 | info->removed * 100.0 / max_changes); | 116 | info->removed * 100.0 / max_changes); |
106 | htmlf("<td class='none' style='width: %.1f%%;'/>", | 117 | htmlf("<td class='none' style='width: %.1f%%;'/>", |
107 | (max_changes - info->removed - info->added) * 100.0 / max_changes); | 118 | (max_changes - info->removed - info->added) * 100.0 / max_changes); |
108 | html("</tr></table></td></tr>\n"); | 119 | html("</tr></table></td></tr>\n"); |
109 | } | 120 | } |
110 | 121 | ||
111 | static void count_diff_lines(char *line, int len) | 122 | static void count_diff_lines(char *line, int len) |
112 | { | 123 | { |
113 | if (line && (len > 0)) { | 124 | if (line && (len > 0)) { |
114 | if (line[0] == '+') | 125 | if (line[0] == '+') |
115 | lines_added++; | 126 | lines_added++; |
116 | else if (line[0] == '-') | 127 | else if (line[0] == '-') |
117 | lines_removed++; | 128 | lines_removed++; |
118 | } | 129 | } |
119 | } | 130 | } |
120 | 131 | ||
121 | static void inspect_filepair(struct diff_filepair *pair) | 132 | static void inspect_filepair(struct diff_filepair *pair) |
122 | { | 133 | { |
123 | int binary = 0; | 134 | int binary = 0; |
124 | unsigned long old_size = 0; | 135 | unsigned long old_size = 0; |
125 | unsigned long new_size = 0; | 136 | unsigned long new_size = 0; |
126 | files++; | 137 | files++; |
127 | lines_added = 0; | 138 | lines_added = 0; |
128 | lines_removed = 0; | 139 | lines_removed = 0; |
129 | cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, &new_size, | 140 | cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, &new_size, |
130 | &binary, 0, ctx.qry.ignorews, count_diff_lines); | 141 | &binary, 0, ctx.qry.ignorews, count_diff_lines); |
131 | if (files >= slots) { | 142 | if (files >= slots) { |
132 | if (slots == 0) | 143 | if (slots == 0) |
133 | slots = 4; | 144 | slots = 4; |
134 | else | 145 | else |
135 | slots = slots * 2; | 146 | slots = slots * 2; |
136 | items = xrealloc(items, slots * sizeof(struct fileinfo)); | 147 | items = xrealloc(items, slots * sizeof(struct fileinfo)); |
137 | } | 148 | } |
138 | items[files-1].status = pair->status; | 149 | items[files-1].status = pair->status; |
139 | hashcpy(items[files-1].old_sha1, pair->one->sha1); | 150 | hashcpy(items[files-1].old_sha1, pair->one->sha1); |
140 | hashcpy(items[files-1].new_sha1, pair->two->sha1); | 151 | hashcpy(items[files-1].new_sha1, pair->two->sha1); |
141 | items[files-1].old_mode = pair->one->mode; | 152 | items[files-1].old_mode = pair->one->mode; |
142 | items[files-1].new_mode = pair->two->mode; | 153 | items[files-1].new_mode = pair->two->mode; |
143 | items[files-1].old_path = xstrdup(pair->one->path); | 154 | items[files-1].old_path = xstrdup(pair->one->path); |
144 | items[files-1].new_path = xstrdup(pair->two->path); | 155 | items[files-1].new_path = xstrdup(pair->two->path); |
145 | items[files-1].added = lines_added; | 156 | items[files-1].added = lines_added; |
146 | items[files-1].removed = lines_removed; | 157 | items[files-1].removed = lines_removed; |
147 | items[files-1].old_size = old_size; | 158 | items[files-1].old_size = old_size; |
148 | items[files-1].new_size = new_size; | 159 | items[files-1].new_size = new_size; |
149 | items[files-1].binary = binary; | 160 | items[files-1].binary = binary; |
150 | if (lines_added + lines_removed > max_changes) | 161 | if (lines_added + lines_removed > max_changes) |
151 | max_changes = lines_added + lines_removed; | 162 | max_changes = lines_added + lines_removed; |
152 | total_adds += lines_added; | 163 | total_adds += lines_added; |
153 | total_rems += lines_removed; | 164 | total_rems += lines_removed; |
154 | } | 165 | } |
155 | 166 | ||
156 | void cgit_print_diffstat(const unsigned char *old_sha1, | 167 | void cgit_print_diffstat(const unsigned char *old_sha1, |
157 | const unsigned char *new_sha1, const char *prefix) | 168 | const unsigned char *new_sha1, const char *prefix) |
158 | { | 169 | { |
159 | int i, save_context = ctx.qry.context; | 170 | int i, save_context = ctx.qry.context; |
160 | 171 | ||
161 | html("<div class='diffstat-header'>"); | 172 | html("<div class='diffstat-header'>"); |
162 | cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1, | 173 | cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1, |
163 | ctx.qry.sha2, NULL, 0); | 174 | ctx.qry.sha2, NULL, 0); |
164 | if (prefix) | 175 | if (prefix) |
165 | htmlf(" (limited to '%s')", prefix); | 176 | htmlf(" (limited to '%s')", prefix); |
166 | html(" ("); | 177 | html(" ("); |
167 | ctx.qry.context = (save_context > 0 ? save_context : 3) << 1; | 178 | ctx.qry.context = (save_context > 0 ? save_context : 3) << 1; |
168 | cgit_self_link("more", NULL, NULL, &ctx); | 179 | cgit_self_link("more", NULL, NULL, &ctx); |
169 | html("/"); | 180 | html("/"); |
170 | ctx.qry.context = (save_context > 3 ? save_context : 3) >> 1; | 181 | ctx.qry.context = (save_context > 3 ? save_context : 3) >> 1; |
171 | cgit_self_link("less", NULL, NULL, &ctx); | 182 | cgit_self_link("less", NULL, NULL, &ctx); |
172 | ctx.qry.context = save_context; | 183 | ctx.qry.context = save_context; |
173 | html(" context)"); | 184 | html(" context)"); |
174 | html(" ("); | 185 | html(" ("); |
175 | ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2; | 186 | ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2; |
176 | cgit_self_link(ctx.qry.ignorews ? "ignore" : "show", NULL, NULL, &ctx); | 187 | cgit_self_link(ctx.qry.ignorews ? "ignore" : "show", NULL, NULL, &ctx); |
177 | ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2; | 188 | ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2; |
178 | html(" whitespace changes)"); | 189 | html(" whitespace changes)"); |
179 | html("</div>"); | 190 | html("</div>"); |
180 | html("<table summary='diffstat' class='diffstat'>"); | 191 | html("<table summary='diffstat' class='diffstat'>"); |
181 | max_changes = 0; | 192 | max_changes = 0; |
182 | cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, prefix, | 193 | cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, prefix, |
183 | ctx.qry.ignorews); | 194 | ctx.qry.ignorews); |
184 | for(i = 0; i<files; i++) | 195 | for(i = 0; i<files; i++) |
185 | print_fileinfo(&items[i]); | 196 | print_fileinfo(&items[i]); |
186 | html("</table>"); | 197 | html("</table>"); |
187 | html("<div class='diffstat-summary'>"); | 198 | html("<div class='diffstat-summary'>"); |
188 | htmlf("%d files changed, %d insertions, %d deletions", | 199 | htmlf("%d files changed, %d insertions, %d deletions", |
189 | files, total_adds, total_rems); | 200 | files, total_adds, total_rems); |
190 | html("</div>"); | 201 | html("</div>"); |
191 | } | 202 | } |
192 | 203 | ||
193 | 204 | ||
194 | /* | 205 | /* |
195 | * print a single line returned from xdiff | 206 | * print a single line returned from xdiff |
196 | */ | 207 | */ |
197 | static void print_line(char *line, int len) | 208 | static void print_line(char *line, int len) |
198 | { | 209 | { |
199 | char *class = "ctx"; | 210 | char *class = "ctx"; |
200 | char c = line[len-1]; | 211 | char c = line[len-1]; |
201 | 212 | ||
202 | if (line[0] == '+') | 213 | if (line[0] == '+') |
203 | class = "add"; | 214 | class = "add"; |
204 | else if (line[0] == '-') | 215 | else if (line[0] == '-') |
205 | class = "del"; | 216 | class = "del"; |
206 | else if (line[0] == '@') | 217 | else if (line[0] == '@') |
207 | class = "hunk"; | 218 | class = "hunk"; |
208 | 219 | ||
209 | htmlf("<div class='%s'>", class); | 220 | htmlf("<div class='%s'>", class); |
210 | line[len-1] = '\0'; | 221 | line[len-1] = '\0'; |
211 | html_txt(line); | 222 | html_txt(line); |
212 | html("</div>"); | 223 | html("</div>"); |
213 | line[len-1] = c; | 224 | line[len-1] = c; |
214 | } | 225 | } |
215 | 226 | ||
216 | static void header(unsigned char *sha1, char *path1, int mode1, | 227 | static void header(unsigned char *sha1, char *path1, int mode1, |
217 | unsigned char *sha2, char *path2, int mode2) | 228 | unsigned char *sha2, char *path2, int mode2) |
218 | { | 229 | { |
219 | char *abbrev1, *abbrev2; | 230 | char *abbrev1, *abbrev2; |
220 | int subproject; | 231 | int subproject; |
221 | 232 | ||
222 | subproject = (S_ISGITLINK(mode1) || S_ISGITLINK(mode2)); | 233 | subproject = (S_ISGITLINK(mode1) || S_ISGITLINK(mode2)); |
223 | html("<div class='head'>"); | 234 | html("<div class='head'>"); |
224 | html("diff --git a/"); | 235 | html("diff --git a/"); |
225 | html_txt(path1); | 236 | html_txt(path1); |
226 | html(" b/"); | 237 | html(" b/"); |
227 | html_txt(path2); | 238 | html_txt(path2); |
228 | 239 | ||
229 | if (is_null_sha1(sha1)) | 240 | if (is_null_sha1(sha1)) |
230 | path1 = "dev/null"; | 241 | path1 = "dev/null"; |
231 | if (is_null_sha1(sha2)) | 242 | if (is_null_sha1(sha2)) |
232 | path2 = "dev/null"; | 243 | path2 = "dev/null"; |
233 | 244 | ||
234 | if (mode1 == 0) | 245 | if (mode1 == 0) |
235 | htmlf("<br/>new file mode %.6o", mode2); | 246 | htmlf("<br/>new file mode %.6o", mode2); |
236 | 247 | ||
237 | if (mode2 == 0) | 248 | if (mode2 == 0) |
238 | htmlf("<br/>deleted file mode %.6o", mode1); | 249 | htmlf("<br/>deleted file mode %.6o", mode1); |
239 | 250 | ||
240 | if (!subproject) { | 251 | if (!subproject) { |
241 | abbrev1 = xstrdup(find_unique_abbrev(sha1, DEFAULT_ABBREV)); | 252 | abbrev1 = xstrdup(find_unique_abbrev(sha1, DEFAULT_ABBREV)); |
242 | abbrev2 = xstrdup(find_unique_abbrev(sha2, DEFAULT_ABBREV)); | 253 | abbrev2 = xstrdup(find_unique_abbrev(sha2, DEFAULT_ABBREV)); |
243 | htmlf("<br/>index %s..%s", abbrev1, abbrev2); | 254 | htmlf("<br/>index %s..%s", abbrev1, abbrev2); |
244 | free(abbrev1); | 255 | free(abbrev1); |
245 | free(abbrev2); | 256 | free(abbrev2); |
246 | if (mode1 != 0 && mode2 != 0) { | 257 | if (mode1 != 0 && mode2 != 0) { |
247 | htmlf(" %.6o", mode1); | 258 | htmlf(" %.6o", mode1); |
248 | if (mode2 != mode1) | 259 | if (mode2 != mode1) |
249 | htmlf("..%.6o", mode2); | 260 | htmlf("..%.6o", mode2); |
250 | } | 261 | } |
251 | html("<br/>--- a/"); | 262 | html("<br/>--- a/"); |
252 | if (mode1 != 0) | 263 | if (mode1 != 0) |
253 | cgit_tree_link(path1, NULL, NULL, ctx.qry.head, | 264 | cgit_tree_link(path1, NULL, NULL, ctx.qry.head, |
254 | sha1_to_hex(old_rev_sha1), path1); | 265 | sha1_to_hex(old_rev_sha1), path1); |
255 | else | 266 | else |
256 | html_txt(path1); | 267 | html_txt(path1); |
257 | html("<br/>+++ b/"); | 268 | html("<br/>+++ b/"); |
258 | if (mode2 != 0) | 269 | if (mode2 != 0) |
259 | cgit_tree_link(path2, NULL, NULL, ctx.qry.head, | 270 | cgit_tree_link(path2, NULL, NULL, ctx.qry.head, |
260 | sha1_to_hex(new_rev_sha1), path2); | 271 | sha1_to_hex(new_rev_sha1), path2); |
261 | else | 272 | else |
262 | html_txt(path2); | 273 | html_txt(path2); |
263 | } | 274 | } |
264 | html("</div>"); | 275 | html("</div>"); |
265 | } | 276 | } |
266 | 277 | ||
267 | static void print_ssdiff_link() | 278 | static void print_ssdiff_link() |
268 | { | 279 | { |
269 | if (!strcmp(ctx.qry.page, "diff")) { | 280 | if (!strcmp(ctx.qry.page, "diff")) { |
270 | if (use_ssdiff) | 281 | if (use_ssdiff) |
271 | cgit_diff_link("Unidiff", NULL, NULL, ctx.qry.head, | 282 | cgit_diff_link("Unidiff", NULL, NULL, ctx.qry.head, |
272 | ctx.qry.sha1, ctx.qry.sha2, ctx.qry.path, 1); | 283 | ctx.qry.sha1, ctx.qry.sha2, ctx.qry.path, 1); |
273 | else | 284 | else |
274 | cgit_diff_link("Side-by-side diff", NULL, NULL, | 285 | cgit_diff_link("Side-by-side diff", NULL, NULL, |
275 | ctx.qry.head, ctx.qry.sha1, | 286 | ctx.qry.head, ctx.qry.sha1, |
276 | ctx.qry.sha2, ctx.qry.path, 1); | 287 | ctx.qry.sha2, ctx.qry.path, 1); |
277 | } | 288 | } |
278 | } | 289 | } |
279 | 290 | ||
280 | static void filepair_cb(struct diff_filepair *pair) | 291 | static void filepair_cb(struct diff_filepair *pair) |
281 | { | 292 | { |
282 | unsigned long old_size = 0; | 293 | unsigned long old_size = 0; |
283 | unsigned long new_size = 0; | 294 | unsigned long new_size = 0; |
284 | int binary = 0; | 295 | int binary = 0; |
285 | linediff_fn print_line_fn = print_line; | 296 | linediff_fn print_line_fn = print_line; |
286 | 297 | ||
298 | current_filepair = pair; | ||
287 | if (use_ssdiff) { | 299 | if (use_ssdiff) { |
288 | cgit_ssdiff_header_begin(); | 300 | cgit_ssdiff_header_begin(); |
289 | print_line_fn = cgit_ssdiff_line_cb; | 301 | print_line_fn = cgit_ssdiff_line_cb; |
290 | } | 302 | } |
291 | header(pair->one->sha1, pair->one->path, pair->one->mode, | 303 | header(pair->one->sha1, pair->one->path, pair->one->mode, |
292 | pair->two->sha1, pair->two->path, pair->two->mode); | 304 | pair->two->sha1, pair->two->path, pair->two->mode); |
293 | if (use_ssdiff) | 305 | if (use_ssdiff) |
294 | cgit_ssdiff_header_end(); | 306 | cgit_ssdiff_header_end(); |
295 | if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) { | 307 | if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) { |
296 | if (S_ISGITLINK(pair->one->mode)) | 308 | if (S_ISGITLINK(pair->one->mode)) |
297 | print_line_fn(fmt("-Subproject %s", sha1_to_hex(pair->one->sha1)), 52); | 309 | print_line_fn(fmt("-Subproject %s", sha1_to_hex(pair->one->sha1)), 52); |
298 | if (S_ISGITLINK(pair->two->mode)) | 310 | if (S_ISGITLINK(pair->two->mode)) |
299 | print_line_fn(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52); | 311 | print_line_fn(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52); |
300 | if (use_ssdiff) | 312 | if (use_ssdiff) |
301 | cgit_ssdiff_footer(); | 313 | cgit_ssdiff_footer(); |
302 | return; | 314 | return; |
303 | } | 315 | } |
304 | if (cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, | 316 | if (cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, |
305 | &new_size, &binary, ctx.qry.context, | 317 | &new_size, &binary, ctx.qry.context, |
306 | ctx.qry.ignorews, print_line_fn)) | 318 | ctx.qry.ignorews, print_line_fn)) |
307 | cgit_print_error("Error running diff"); | 319 | cgit_print_error("Error running diff"); |
308 | if (binary) { | 320 | if (binary) { |
309 | if (use_ssdiff) | 321 | if (use_ssdiff) |
310 | html("<tr><td colspan='4'>Binary files differ</td></tr>"); | 322 | html("<tr><td colspan='4'>Binary files differ</td></tr>"); |
311 | else | 323 | else |
312 | html("Binary files differ"); | 324 | html("Binary files differ"); |
313 | } | 325 | } |
314 | if (use_ssdiff) | 326 | if (use_ssdiff) |
315 | cgit_ssdiff_footer(); | 327 | cgit_ssdiff_footer(); |
316 | } | 328 | } |
317 | 329 | ||
318 | void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefix) | 330 | void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefix) |
319 | { | 331 | { |
320 | enum object_type type; | 332 | enum object_type type; |
321 | unsigned long size; | 333 | unsigned long size; |
322 | struct commit *commit, *commit2; | 334 | struct commit *commit, *commit2; |
323 | 335 | ||
324 | if (!new_rev) | 336 | if (!new_rev) |
325 | new_rev = ctx.qry.head; | 337 | new_rev = ctx.qry.head; |
326 | get_sha1(new_rev, new_rev_sha1); | 338 | get_sha1(new_rev, new_rev_sha1); |
327 | type = sha1_object_info(new_rev_sha1, &size); | 339 | type = sha1_object_info(new_rev_sha1, &size); |
328 | if (type == OBJ_BAD) { | 340 | if (type == OBJ_BAD) { |
329 | cgit_print_error(fmt("Bad object name: %s", new_rev)); | 341 | cgit_print_error(fmt("Bad object name: %s", new_rev)); |
330 | return; | 342 | return; |
331 | } | 343 | } |
332 | commit = lookup_commit_reference(new_rev_sha1); | 344 | commit = lookup_commit_reference(new_rev_sha1); |
333 | if (!commit || parse_commit(commit)) | 345 | if (!commit || parse_commit(commit)) |
334 | cgit_print_error(fmt("Bad commit: %s", sha1_to_hex(new_rev_sha1))); | 346 | cgit_print_error(fmt("Bad commit: %s", sha1_to_hex(new_rev_sha1))); |
335 | 347 | ||
336 | if (old_rev) | 348 | if (old_rev) |
337 | get_sha1(old_rev, old_rev_sha1); | 349 | get_sha1(old_rev, old_rev_sha1); |
338 | else if (commit->parents && commit->parents->item) | 350 | else if (commit->parents && commit->parents->item) |
339 | hashcpy(old_rev_sha1, commit->parents->item->object.sha1); | 351 | hashcpy(old_rev_sha1, commit->parents->item->object.sha1); |
340 | else | 352 | else |
341 | hashclr(old_rev_sha1); | 353 | hashclr(old_rev_sha1); |
342 | 354 | ||
343 | if (!is_null_sha1(old_rev_sha1)) { | 355 | if (!is_null_sha1(old_rev_sha1)) { |
344 | type = sha1_object_info(old_rev_sha1, &size); | 356 | type = sha1_object_info(old_rev_sha1, &size); |
345 | if (type == OBJ_BAD) { | 357 | if (type == OBJ_BAD) { |
346 | cgit_print_error(fmt("Bad object name: %s", sha1_to_hex(old_rev_sha1))); | 358 | cgit_print_error(fmt("Bad object name: %s", sha1_to_hex(old_rev_sha1))); |
347 | return; | 359 | return; |
348 | } | 360 | } |
349 | commit2 = lookup_commit_reference(old_rev_sha1); | 361 | commit2 = lookup_commit_reference(old_rev_sha1); |
350 | if (!commit2 || parse_commit(commit2)) | 362 | if (!commit2 || parse_commit(commit2)) |
351 | cgit_print_error(fmt("Bad commit: %s", sha1_to_hex(old_rev_sha1))); | 363 | cgit_print_error(fmt("Bad commit: %s", sha1_to_hex(old_rev_sha1))); |
352 | } | 364 | } |
353 | 365 | ||
354 | if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff)) | 366 | if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff)) |
355 | use_ssdiff = 1; | 367 | use_ssdiff = 1; |
356 | 368 | ||
357 | print_ssdiff_link(); | 369 | print_ssdiff_link(); |
358 | cgit_print_diffstat(old_rev_sha1, new_rev_sha1, prefix); | 370 | cgit_print_diffstat(old_rev_sha1, new_rev_sha1, prefix); |
359 | 371 | ||
360 | if (use_ssdiff) { | 372 | if (use_ssdiff) { |
361 | html("<table summary='ssdiff' class='ssdiff'>"); | 373 | html("<table summary='ssdiff' class='ssdiff'>"); |
362 | } else { | 374 | } else { |
363 | html("<table summary='diff' class='diff'>"); | 375 | html("<table summary='diff' class='diff'>"); |
364 | html("<tr><td>"); | 376 | html("<tr><td>"); |
365 | } | 377 | } |
366 | cgit_diff_tree(old_rev_sha1, new_rev_sha1, filepair_cb, prefix, | 378 | cgit_diff_tree(old_rev_sha1, new_rev_sha1, filepair_cb, prefix, |
367 | ctx.qry.ignorews); | 379 | ctx.qry.ignorews); |
368 | if (!use_ssdiff) | 380 | if (!use_ssdiff) |
369 | html("</td></tr>"); | 381 | html("</td></tr>"); |
370 | html("</table>"); | 382 | html("</table>"); |
371 | } | 383 | } |
@@ -1,10 +1,16 @@ | |||
1 | #ifndef UI_DIFF_H | 1 | #ifndef UI_DIFF_H |
2 | #define UI_DIFF_H | 2 | #define UI_DIFF_H |
3 | 3 | ||
4 | extern void cgit_print_diffstat(const unsigned char *old_sha1, | 4 | extern void cgit_print_diffstat(const unsigned char *old_sha1, |
5 | const unsigned char *new_sha1); | 5 | const unsigned char *new_sha1); |
6 | 6 | ||
7 | extern void cgit_print_diff(const char *new_hex, const char *old_hex, | 7 | extern void cgit_print_diff(const char *new_hex, const char *old_hex, |
8 | const char *prefix); | 8 | const char *prefix); |
9 | 9 | ||
10 | extern struct diff_filespec *cgit_get_current_old_file(void); | ||
11 | extern struct diff_filespec *cgit_get_current_new_file(void); | ||
12 | |||
13 | extern unsigned char old_rev_sha1[20]; | ||
14 | extern unsigned char new_rev_sha1[20]; | ||
15 | |||
10 | #endif /* UI_DIFF_H */ | 16 | #endif /* UI_DIFF_H */ |
diff --git a/ui-shared.c b/ui-shared.c index ae29615..7efae7a 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -375,535 +375,545 @@ void cgit_snapshot_link(const char *name, const char *title, const char *class, | |||
375 | void cgit_diff_link(const char *name, const char *title, const char *class, | 375 | void cgit_diff_link(const char *name, const char *title, const char *class, |
376 | const char *head, const char *new_rev, const char *old_rev, | 376 | const char *head, const char *new_rev, const char *old_rev, |
377 | const char *path, int toggle_ssdiff) | 377 | const char *path, int toggle_ssdiff) |
378 | { | 378 | { |
379 | char *delim; | 379 | char *delim; |
380 | 380 | ||
381 | delim = repolink(title, class, "diff", head, path); | 381 | delim = repolink(title, class, "diff", head, path); |
382 | if (new_rev && ctx.qry.head != NULL && strcmp(new_rev, ctx.qry.head)) { | 382 | if (new_rev && ctx.qry.head != NULL && strcmp(new_rev, ctx.qry.head)) { |
383 | html(delim); | 383 | html(delim); |
384 | html("id="); | 384 | html("id="); |
385 | html_url_arg(new_rev); | 385 | html_url_arg(new_rev); |
386 | delim = "&"; | 386 | delim = "&"; |
387 | } | 387 | } |
388 | if (old_rev) { | 388 | if (old_rev) { |
389 | html(delim); | 389 | html(delim); |
390 | html("id2="); | 390 | html("id2="); |
391 | html_url_arg(old_rev); | 391 | html_url_arg(old_rev); |
392 | delim = "&"; | 392 | delim = "&"; |
393 | } | 393 | } |
394 | if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) { | 394 | if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) { |
395 | html(delim); | 395 | html(delim); |
396 | html("ss=1"); | 396 | html("ss=1"); |
397 | delim = "&"; | 397 | delim = "&"; |
398 | } | 398 | } |
399 | if (ctx.qry.context > 0 && ctx.qry.context != 3) { | 399 | if (ctx.qry.context > 0 && ctx.qry.context != 3) { |
400 | html(delim); | 400 | html(delim); |
401 | html("context="); | 401 | html("context="); |
402 | htmlf("%d", ctx.qry.context); | 402 | htmlf("%d", ctx.qry.context); |
403 | delim = "&"; | 403 | delim = "&"; |
404 | } | 404 | } |
405 | if (ctx.qry.ignorews) { | 405 | if (ctx.qry.ignorews) { |
406 | html(delim); | 406 | html(delim); |
407 | html("ignorews=1"); | 407 | html("ignorews=1"); |
408 | delim = "&"; | 408 | delim = "&"; |
409 | } | 409 | } |
410 | html("'>"); | 410 | html("'>"); |
411 | html_txt(name); | 411 | html_txt(name); |
412 | html("</a>"); | 412 | html("</a>"); |
413 | } | 413 | } |
414 | 414 | ||
415 | void cgit_patch_link(const char *name, const char *title, const char *class, | 415 | void cgit_patch_link(const char *name, const char *title, const char *class, |
416 | const char *head, const char *rev, const char *path) | 416 | const char *head, const char *rev, const char *path) |
417 | { | 417 | { |
418 | reporevlink("patch", name, title, class, head, rev, path); | 418 | reporevlink("patch", name, title, class, head, rev, path); |
419 | } | 419 | } |
420 | 420 | ||
421 | void cgit_stats_link(const char *name, const char *title, const char *class, | 421 | void cgit_stats_link(const char *name, const char *title, const char *class, |
422 | const char *head, const char *path) | 422 | const char *head, const char *path) |
423 | { | 423 | { |
424 | reporevlink("stats", name, title, class, head, NULL, path); | 424 | reporevlink("stats", name, title, class, head, NULL, path); |
425 | } | 425 | } |
426 | 426 | ||
427 | void cgit_self_link(char *name, const char *title, const char *class, | 427 | void cgit_self_link(char *name, const char *title, const char *class, |
428 | struct cgit_context *ctx) | 428 | struct cgit_context *ctx) |
429 | { | 429 | { |
430 | if (!strcmp(ctx->qry.page, "repolist")) | 430 | if (!strcmp(ctx->qry.page, "repolist")) |
431 | return cgit_index_link(name, title, class, ctx->qry.search, | 431 | return cgit_index_link(name, title, class, ctx->qry.search, |
432 | ctx->qry.ofs); | 432 | ctx->qry.ofs); |
433 | else if (!strcmp(ctx->qry.page, "summary")) | 433 | else if (!strcmp(ctx->qry.page, "summary")) |
434 | return cgit_summary_link(name, title, class, ctx->qry.head); | 434 | return cgit_summary_link(name, title, class, ctx->qry.head); |
435 | else if (!strcmp(ctx->qry.page, "tag")) | 435 | else if (!strcmp(ctx->qry.page, "tag")) |
436 | return cgit_tag_link(name, title, class, ctx->qry.head, | 436 | return cgit_tag_link(name, title, class, ctx->qry.head, |
437 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL); | 437 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL); |
438 | else if (!strcmp(ctx->qry.page, "tree")) | 438 | else if (!strcmp(ctx->qry.page, "tree")) |
439 | return cgit_tree_link(name, title, class, ctx->qry.head, | 439 | return cgit_tree_link(name, title, class, ctx->qry.head, |
440 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, | 440 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, |
441 | ctx->qry.path); | 441 | ctx->qry.path); |
442 | else if (!strcmp(ctx->qry.page, "plain")) | 442 | else if (!strcmp(ctx->qry.page, "plain")) |
443 | return cgit_plain_link(name, title, class, ctx->qry.head, | 443 | return cgit_plain_link(name, title, class, ctx->qry.head, |
444 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, | 444 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, |
445 | ctx->qry.path); | 445 | ctx->qry.path); |
446 | else if (!strcmp(ctx->qry.page, "log")) | 446 | else if (!strcmp(ctx->qry.page, "log")) |
447 | return cgit_log_link(name, title, class, ctx->qry.head, | 447 | return cgit_log_link(name, title, class, ctx->qry.head, |
448 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, | 448 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, |
449 | ctx->qry.path, ctx->qry.ofs, | 449 | ctx->qry.path, ctx->qry.ofs, |
450 | ctx->qry.grep, ctx->qry.search, | 450 | ctx->qry.grep, ctx->qry.search, |
451 | ctx->qry.showmsg); | 451 | ctx->qry.showmsg); |
452 | else if (!strcmp(ctx->qry.page, "commit")) | 452 | else if (!strcmp(ctx->qry.page, "commit")) |
453 | return cgit_commit_link(name, title, class, ctx->qry.head, | 453 | return cgit_commit_link(name, title, class, ctx->qry.head, |
454 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, | 454 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, |
455 | ctx->qry.path, 0); | 455 | ctx->qry.path, 0); |
456 | else if (!strcmp(ctx->qry.page, "patch")) | 456 | else if (!strcmp(ctx->qry.page, "patch")) |
457 | return cgit_patch_link(name, title, class, ctx->qry.head, | 457 | return cgit_patch_link(name, title, class, ctx->qry.head, |
458 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, | 458 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, |
459 | ctx->qry.path); | 459 | ctx->qry.path); |
460 | else if (!strcmp(ctx->qry.page, "refs")) | 460 | else if (!strcmp(ctx->qry.page, "refs")) |
461 | return cgit_refs_link(name, title, class, ctx->qry.head, | 461 | return cgit_refs_link(name, title, class, ctx->qry.head, |
462 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, | 462 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, |
463 | ctx->qry.path); | 463 | ctx->qry.path); |
464 | else if (!strcmp(ctx->qry.page, "snapshot")) | 464 | else if (!strcmp(ctx->qry.page, "snapshot")) |
465 | return cgit_snapshot_link(name, title, class, ctx->qry.head, | 465 | return cgit_snapshot_link(name, title, class, ctx->qry.head, |
466 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, | 466 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, |
467 | ctx->qry.path); | 467 | ctx->qry.path); |
468 | else if (!strcmp(ctx->qry.page, "diff")) | 468 | else if (!strcmp(ctx->qry.page, "diff")) |
469 | return cgit_diff_link(name, title, class, ctx->qry.head, | 469 | return cgit_diff_link(name, title, class, ctx->qry.head, |
470 | ctx->qry.sha1, ctx->qry.sha2, | 470 | ctx->qry.sha1, ctx->qry.sha2, |
471 | ctx->qry.path, 0); | 471 | ctx->qry.path, 0); |
472 | else if (!strcmp(ctx->qry.page, "stats")) | 472 | else if (!strcmp(ctx->qry.page, "stats")) |
473 | return cgit_stats_link(name, title, class, ctx->qry.head, | 473 | return cgit_stats_link(name, title, class, ctx->qry.head, |
474 | ctx->qry.path); | 474 | ctx->qry.path); |
475 | 475 | ||
476 | /* Don't known how to make link for this page */ | 476 | /* Don't known how to make link for this page */ |
477 | repolink(title, class, ctx->qry.page, ctx->qry.head, ctx->qry.path); | 477 | repolink(title, class, ctx->qry.page, ctx->qry.head, ctx->qry.path); |
478 | html("><!-- cgit_self_link() doesn't know how to make link for page '"); | 478 | html("><!-- cgit_self_link() doesn't know how to make link for page '"); |
479 | html_txt(ctx->qry.page); | 479 | html_txt(ctx->qry.page); |
480 | html("' -->"); | 480 | html("' -->"); |
481 | html_txt(name); | 481 | html_txt(name); |
482 | html("</a>"); | 482 | html("</a>"); |
483 | } | 483 | } |
484 | 484 | ||
485 | void cgit_object_link(struct object *obj) | 485 | void cgit_object_link(struct object *obj) |
486 | { | 486 | { |
487 | char *page, *shortrev, *fullrev, *name; | 487 | char *page, *shortrev, *fullrev, *name; |
488 | 488 | ||
489 | fullrev = sha1_to_hex(obj->sha1); | 489 | fullrev = sha1_to_hex(obj->sha1); |
490 | shortrev = xstrdup(fullrev); | 490 | shortrev = xstrdup(fullrev); |
491 | shortrev[10] = '\0'; | 491 | shortrev[10] = '\0'; |
492 | if (obj->type == OBJ_COMMIT) { | 492 | if (obj->type == OBJ_COMMIT) { |
493 | cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL, | 493 | cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL, |
494 | ctx.qry.head, fullrev, NULL, 0); | 494 | ctx.qry.head, fullrev, NULL, 0); |
495 | return; | 495 | return; |
496 | } else if (obj->type == OBJ_TREE) | 496 | } else if (obj->type == OBJ_TREE) |
497 | page = "tree"; | 497 | page = "tree"; |
498 | else if (obj->type == OBJ_TAG) | 498 | else if (obj->type == OBJ_TAG) |
499 | page = "tag"; | 499 | page = "tag"; |
500 | else | 500 | else |
501 | page = "blob"; | 501 | page = "blob"; |
502 | name = fmt("%s %s...", typename(obj->type), shortrev); | 502 | name = fmt("%s %s...", typename(obj->type), shortrev); |
503 | reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL); | 503 | reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL); |
504 | } | 504 | } |
505 | 505 | ||
506 | void cgit_print_date(time_t secs, const char *format, int local_time) | 506 | void cgit_print_date(time_t secs, const char *format, int local_time) |
507 | { | 507 | { |
508 | char buf[64]; | 508 | char buf[64]; |
509 | struct tm *time; | 509 | struct tm *time; |
510 | 510 | ||
511 | if (!secs) | 511 | if (!secs) |
512 | return; | 512 | return; |
513 | if(local_time) | 513 | if(local_time) |
514 | time = localtime(&secs); | 514 | time = localtime(&secs); |
515 | else | 515 | else |
516 | time = gmtime(&secs); | 516 | time = gmtime(&secs); |
517 | strftime(buf, sizeof(buf)-1, format, time); | 517 | strftime(buf, sizeof(buf)-1, format, time); |
518 | html_txt(buf); | 518 | html_txt(buf); |
519 | } | 519 | } |
520 | 520 | ||
521 | void cgit_print_age(time_t t, time_t max_relative, const char *format) | 521 | void cgit_print_age(time_t t, time_t max_relative, const char *format) |
522 | { | 522 | { |
523 | time_t now, secs; | 523 | time_t now, secs; |
524 | 524 | ||
525 | if (!t) | 525 | if (!t) |
526 | return; | 526 | return; |
527 | time(&now); | 527 | time(&now); |
528 | secs = now - t; | 528 | secs = now - t; |
529 | 529 | ||
530 | if (secs > max_relative && max_relative >= 0) { | 530 | if (secs > max_relative && max_relative >= 0) { |
531 | cgit_print_date(t, format, ctx.cfg.local_time); | 531 | cgit_print_date(t, format, ctx.cfg.local_time); |
532 | return; | 532 | return; |
533 | } | 533 | } |
534 | 534 | ||
535 | if (secs < TM_HOUR * 2) { | 535 | if (secs < TM_HOUR * 2) { |
536 | htmlf("<span class='age-mins'>%.0f min.</span>", | 536 | htmlf("<span class='age-mins'>%.0f min.</span>", |
537 | secs * 1.0 / TM_MIN); | 537 | secs * 1.0 / TM_MIN); |
538 | return; | 538 | return; |
539 | } | 539 | } |
540 | if (secs < TM_DAY * 2) { | 540 | if (secs < TM_DAY * 2) { |
541 | htmlf("<span class='age-hours'>%.0f hours</span>", | 541 | htmlf("<span class='age-hours'>%.0f hours</span>", |
542 | secs * 1.0 / TM_HOUR); | 542 | secs * 1.0 / TM_HOUR); |
543 | return; | 543 | return; |
544 | } | 544 | } |
545 | if (secs < TM_WEEK * 2) { | 545 | if (secs < TM_WEEK * 2) { |
546 | htmlf("<span class='age-days'>%.0f days</span>", | 546 | htmlf("<span class='age-days'>%.0f days</span>", |
547 | secs * 1.0 / TM_DAY); | 547 | secs * 1.0 / TM_DAY); |
548 | return; | 548 | return; |
549 | } | 549 | } |
550 | if (secs < TM_MONTH * 2) { | 550 | if (secs < TM_MONTH * 2) { |
551 | htmlf("<span class='age-weeks'>%.0f weeks</span>", | 551 | htmlf("<span class='age-weeks'>%.0f weeks</span>", |
552 | secs * 1.0 / TM_WEEK); | 552 | secs * 1.0 / TM_WEEK); |
553 | return; | 553 | return; |
554 | } | 554 | } |
555 | if (secs < TM_YEAR * 2) { | 555 | if (secs < TM_YEAR * 2) { |
556 | htmlf("<span class='age-months'>%.0f months</span>", | 556 | htmlf("<span class='age-months'>%.0f months</span>", |
557 | secs * 1.0 / TM_MONTH); | 557 | secs * 1.0 / TM_MONTH); |
558 | return; | 558 | return; |
559 | } | 559 | } |
560 | htmlf("<span class='age-years'>%.0f years</span>", | 560 | htmlf("<span class='age-years'>%.0f years</span>", |
561 | secs * 1.0 / TM_YEAR); | 561 | secs * 1.0 / TM_YEAR); |
562 | } | 562 | } |
563 | 563 | ||
564 | void cgit_print_http_headers(struct cgit_context *ctx) | 564 | void cgit_print_http_headers(struct cgit_context *ctx) |
565 | { | 565 | { |
566 | if (ctx->env.no_http && !strcmp(ctx->env.no_http, "1")) | 566 | if (ctx->env.no_http && !strcmp(ctx->env.no_http, "1")) |
567 | return; | 567 | return; |
568 | 568 | ||
569 | if (ctx->page.status) | 569 | if (ctx->page.status) |
570 | htmlf("Status: %d %s\n", ctx->page.status, ctx->page.statusmsg); | 570 | htmlf("Status: %d %s\n", ctx->page.status, ctx->page.statusmsg); |
571 | if (ctx->page.mimetype && ctx->page.charset) | 571 | if (ctx->page.mimetype && ctx->page.charset) |
572 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, | 572 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, |
573 | ctx->page.charset); | 573 | ctx->page.charset); |
574 | else if (ctx->page.mimetype) | 574 | else if (ctx->page.mimetype) |
575 | htmlf("Content-Type: %s\n", ctx->page.mimetype); | 575 | htmlf("Content-Type: %s\n", ctx->page.mimetype); |
576 | if (ctx->page.size) | 576 | if (ctx->page.size) |
577 | htmlf("Content-Length: %ld\n", ctx->page.size); | 577 | htmlf("Content-Length: %ld\n", ctx->page.size); |
578 | if (ctx->page.filename) | 578 | if (ctx->page.filename) |
579 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", | 579 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", |
580 | ctx->page.filename); | 580 | ctx->page.filename); |
581 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); | 581 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); |
582 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); | 582 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); |
583 | if (ctx->page.etag) | 583 | if (ctx->page.etag) |
584 | htmlf("ETag: \"%s\"\n", ctx->page.etag); | 584 | htmlf("ETag: \"%s\"\n", ctx->page.etag); |
585 | html("\n"); | 585 | html("\n"); |
586 | if (ctx->env.request_method && !strcmp(ctx->env.request_method, "HEAD")) | 586 | if (ctx->env.request_method && !strcmp(ctx->env.request_method, "HEAD")) |
587 | exit(0); | 587 | exit(0); |
588 | } | 588 | } |
589 | 589 | ||
590 | void cgit_print_docstart(struct cgit_context *ctx) | 590 | void cgit_print_docstart(struct cgit_context *ctx) |
591 | { | 591 | { |
592 | if (ctx->cfg.embedded) { | 592 | if (ctx->cfg.embedded) { |
593 | if (ctx->cfg.header) | 593 | if (ctx->cfg.header) |
594 | html_include(ctx->cfg.header); | 594 | html_include(ctx->cfg.header); |
595 | return; | 595 | return; |
596 | } | 596 | } |
597 | 597 | ||
598 | char *host = cgit_hosturl(); | 598 | char *host = cgit_hosturl(); |
599 | html(cgit_doctype); | 599 | html(cgit_doctype); |
600 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); | 600 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); |
601 | html("<head>\n"); | 601 | html("<head>\n"); |
602 | html("<title>"); | 602 | html("<title>"); |
603 | html_txt(ctx->page.title); | 603 | html_txt(ctx->page.title); |
604 | html("</title>\n"); | 604 | html("</title>\n"); |
605 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); | 605 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); |
606 | if (ctx->cfg.robots && *ctx->cfg.robots) | 606 | if (ctx->cfg.robots && *ctx->cfg.robots) |
607 | htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); | 607 | htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); |
608 | html("<link rel='stylesheet' type='text/css' href='"); | 608 | html("<link rel='stylesheet' type='text/css' href='"); |
609 | html_attr(ctx->cfg.css); | 609 | html_attr(ctx->cfg.css); |
610 | html("'/>\n"); | 610 | html("'/>\n"); |
611 | if (ctx->cfg.favicon) { | 611 | if (ctx->cfg.favicon) { |
612 | html("<link rel='shortcut icon' href='"); | 612 | html("<link rel='shortcut icon' href='"); |
613 | html_attr(ctx->cfg.favicon); | 613 | html_attr(ctx->cfg.favicon); |
614 | html("'/>\n"); | 614 | html("'/>\n"); |
615 | } | 615 | } |
616 | if (host && ctx->repo) { | 616 | if (host && ctx->repo) { |
617 | html("<link rel='alternate' title='Atom feed' href='"); | 617 | html("<link rel='alternate' title='Atom feed' href='"); |
618 | html(cgit_httpscheme()); | 618 | html(cgit_httpscheme()); |
619 | html_attr(cgit_hosturl()); | 619 | html_attr(cgit_hosturl()); |
620 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.vpath, | 620 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.vpath, |
621 | fmt("h=%s", ctx->qry.head))); | 621 | fmt("h=%s", ctx->qry.head))); |
622 | html("' type='application/atom+xml'/>\n"); | 622 | html("' type='application/atom+xml'/>\n"); |
623 | } | 623 | } |
624 | if (ctx->cfg.head_include) | 624 | if (ctx->cfg.head_include) |
625 | html_include(ctx->cfg.head_include); | 625 | html_include(ctx->cfg.head_include); |
626 | html("</head>\n"); | 626 | html("</head>\n"); |
627 | html("<body>\n"); | 627 | html("<body>\n"); |
628 | if (ctx->cfg.header) | 628 | if (ctx->cfg.header) |
629 | html_include(ctx->cfg.header); | 629 | html_include(ctx->cfg.header); |
630 | } | 630 | } |
631 | 631 | ||
632 | void cgit_print_docend() | 632 | void cgit_print_docend() |
633 | { | 633 | { |
634 | html("</div> <!-- class=content -->\n"); | 634 | html("</div> <!-- class=content -->\n"); |
635 | if (ctx.cfg.embedded) { | 635 | if (ctx.cfg.embedded) { |
636 | html("</div> <!-- id=cgit -->\n"); | 636 | html("</div> <!-- id=cgit -->\n"); |
637 | if (ctx.cfg.footer) | 637 | if (ctx.cfg.footer) |
638 | html_include(ctx.cfg.footer); | 638 | html_include(ctx.cfg.footer); |
639 | return; | 639 | return; |
640 | } | 640 | } |
641 | if (ctx.cfg.footer) | 641 | if (ctx.cfg.footer) |
642 | html_include(ctx.cfg.footer); | 642 | html_include(ctx.cfg.footer); |
643 | else { | 643 | else { |
644 | htmlf("<div class='footer'>generated by cgit %s at ", | 644 | htmlf("<div class='footer'>generated by cgit %s at ", |
645 | cgit_version); | 645 | cgit_version); |
646 | cgit_print_date(time(NULL), FMT_LONGDATE, ctx.cfg.local_time); | 646 | cgit_print_date(time(NULL), FMT_LONGDATE, ctx.cfg.local_time); |
647 | html("</div>\n"); | 647 | html("</div>\n"); |
648 | } | 648 | } |
649 | html("</div> <!-- id=cgit -->\n"); | 649 | html("</div> <!-- id=cgit -->\n"); |
650 | html("</body>\n</html>\n"); | 650 | html("</body>\n</html>\n"); |
651 | } | 651 | } |
652 | 652 | ||
653 | int print_branch_option(const char *refname, const unsigned char *sha1, | 653 | int print_branch_option(const char *refname, const unsigned char *sha1, |
654 | int flags, void *cb_data) | 654 | int flags, void *cb_data) |
655 | { | 655 | { |
656 | char *name = (char *)refname; | 656 | char *name = (char *)refname; |
657 | html_option(name, name, ctx.qry.head); | 657 | html_option(name, name, ctx.qry.head); |
658 | return 0; | 658 | return 0; |
659 | } | 659 | } |
660 | 660 | ||
661 | int print_archive_ref(const char *refname, const unsigned char *sha1, | 661 | int print_archive_ref(const char *refname, const unsigned char *sha1, |
662 | int flags, void *cb_data) | 662 | int flags, void *cb_data) |
663 | { | 663 | { |
664 | struct tag *tag; | 664 | struct tag *tag; |
665 | struct taginfo *info; | 665 | struct taginfo *info; |
666 | struct object *obj; | 666 | struct object *obj; |
667 | char buf[256], *url; | 667 | char buf[256], *url; |
668 | unsigned char fileid[20]; | 668 | unsigned char fileid[20]; |
669 | int *header = (int *)cb_data; | 669 | int *header = (int *)cb_data; |
670 | 670 | ||
671 | if (prefixcmp(refname, "refs/archives")) | 671 | if (prefixcmp(refname, "refs/archives")) |
672 | return 0; | 672 | return 0; |
673 | strncpy(buf, refname+14, sizeof(buf)); | 673 | strncpy(buf, refname+14, sizeof(buf)); |
674 | obj = parse_object(sha1); | 674 | obj = parse_object(sha1); |
675 | if (!obj) | 675 | if (!obj) |
676 | return 1; | 676 | return 1; |
677 | if (obj->type == OBJ_TAG) { | 677 | if (obj->type == OBJ_TAG) { |
678 | tag = lookup_tag(sha1); | 678 | tag = lookup_tag(sha1); |
679 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) | 679 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) |
680 | return 0; | 680 | return 0; |
681 | hashcpy(fileid, tag->tagged->sha1); | 681 | hashcpy(fileid, tag->tagged->sha1); |
682 | } else if (obj->type != OBJ_BLOB) { | 682 | } else if (obj->type != OBJ_BLOB) { |
683 | return 0; | 683 | return 0; |
684 | } else { | 684 | } else { |
685 | hashcpy(fileid, sha1); | 685 | hashcpy(fileid, sha1); |
686 | } | 686 | } |
687 | if (!*header) { | 687 | if (!*header) { |
688 | html("<h1>download</h1>\n"); | 688 | html("<h1>download</h1>\n"); |
689 | *header = 1; | 689 | *header = 1; |
690 | } | 690 | } |
691 | url = cgit_pageurl(ctx.qry.repo, "blob", | 691 | url = cgit_pageurl(ctx.qry.repo, "blob", |
692 | fmt("id=%s&path=%s", sha1_to_hex(fileid), | 692 | fmt("id=%s&path=%s", sha1_to_hex(fileid), |
693 | buf)); | 693 | buf)); |
694 | html_link_open(url, NULL, "menu"); | 694 | html_link_open(url, NULL, "menu"); |
695 | html_txt(strlpart(buf, 20)); | 695 | html_txt(strlpart(buf, 20)); |
696 | html_link_close(); | 696 | html_link_close(); |
697 | return 0; | 697 | return 0; |
698 | } | 698 | } |
699 | 699 | ||
700 | void cgit_add_hidden_formfields(int incl_head, int incl_search, | 700 | void cgit_add_hidden_formfields(int incl_head, int incl_search, |
701 | const char *page) | 701 | const char *page) |
702 | { | 702 | { |
703 | char *url; | 703 | char *url; |
704 | 704 | ||
705 | if (!ctx.cfg.virtual_root) { | 705 | if (!ctx.cfg.virtual_root) { |
706 | url = fmt("%s/%s", ctx.qry.repo, page); | 706 | url = fmt("%s/%s", ctx.qry.repo, page); |
707 | if (ctx.qry.vpath) | 707 | if (ctx.qry.vpath) |
708 | url = fmt("%s/%s", url, ctx.qry.vpath); | 708 | url = fmt("%s/%s", url, ctx.qry.vpath); |
709 | html_hidden("url", url); | 709 | html_hidden("url", url); |
710 | } | 710 | } |
711 | 711 | ||
712 | if (incl_head && ctx.qry.head && ctx.repo->defbranch && | 712 | if (incl_head && ctx.qry.head && ctx.repo->defbranch && |
713 | strcmp(ctx.qry.head, ctx.repo->defbranch)) | 713 | strcmp(ctx.qry.head, ctx.repo->defbranch)) |
714 | html_hidden("h", ctx.qry.head); | 714 | html_hidden("h", ctx.qry.head); |
715 | 715 | ||
716 | if (ctx.qry.sha1) | 716 | if (ctx.qry.sha1) |
717 | html_hidden("id", ctx.qry.sha1); | 717 | html_hidden("id", ctx.qry.sha1); |
718 | if (ctx.qry.sha2) | 718 | if (ctx.qry.sha2) |
719 | html_hidden("id2", ctx.qry.sha2); | 719 | html_hidden("id2", ctx.qry.sha2); |
720 | if (ctx.qry.showmsg) | 720 | if (ctx.qry.showmsg) |
721 | html_hidden("showmsg", "1"); | 721 | html_hidden("showmsg", "1"); |
722 | 722 | ||
723 | if (incl_search) { | 723 | if (incl_search) { |
724 | if (ctx.qry.grep) | 724 | if (ctx.qry.grep) |
725 | html_hidden("qt", ctx.qry.grep); | 725 | html_hidden("qt", ctx.qry.grep); |
726 | if (ctx.qry.search) | 726 | if (ctx.qry.search) |
727 | html_hidden("q", ctx.qry.search); | 727 | html_hidden("q", ctx.qry.search); |
728 | } | 728 | } |
729 | } | 729 | } |
730 | 730 | ||
731 | static const char *hc(struct cgit_context *ctx, const char *page) | 731 | static const char *hc(struct cgit_context *ctx, const char *page) |
732 | { | 732 | { |
733 | return strcmp(ctx->qry.page, page) ? NULL : "active"; | 733 | return strcmp(ctx->qry.page, page) ? NULL : "active"; |
734 | } | 734 | } |
735 | 735 | ||
736 | static void cgit_print_path_crumbs(struct cgit_context *ctx, char *path) | 736 | static void cgit_print_path_crumbs(struct cgit_context *ctx, char *path) |
737 | { | 737 | { |
738 | char *old_path = ctx->qry.path; | 738 | char *old_path = ctx->qry.path; |
739 | char *p = path, *q, *end = path + strlen(path); | 739 | char *p = path, *q, *end = path + strlen(path); |
740 | 740 | ||
741 | ctx->qry.path = NULL; | 741 | ctx->qry.path = NULL; |
742 | cgit_self_link("root", NULL, NULL, ctx); | 742 | cgit_self_link("root", NULL, NULL, ctx); |
743 | ctx->qry.path = p = path; | 743 | ctx->qry.path = p = path; |
744 | while (p < end) { | 744 | while (p < end) { |
745 | if (!(q = strchr(p, '/'))) | 745 | if (!(q = strchr(p, '/'))) |
746 | q = end; | 746 | q = end; |
747 | *q = '\0'; | 747 | *q = '\0'; |
748 | html_txt("/"); | 748 | html_txt("/"); |
749 | cgit_self_link(p, NULL, NULL, ctx); | 749 | cgit_self_link(p, NULL, NULL, ctx); |
750 | if (q < end) | 750 | if (q < end) |
751 | *q = '/'; | 751 | *q = '/'; |
752 | p = q + 1; | 752 | p = q + 1; |
753 | } | 753 | } |
754 | ctx->qry.path = old_path; | 754 | ctx->qry.path = old_path; |
755 | } | 755 | } |
756 | 756 | ||
757 | static void print_header(struct cgit_context *ctx) | 757 | static void print_header(struct cgit_context *ctx) |
758 | { | 758 | { |
759 | char *logo = NULL, *logo_link = NULL; | ||
760 | |||
759 | html("<table id='header'>\n"); | 761 | html("<table id='header'>\n"); |
760 | html("<tr>\n"); | 762 | html("<tr>\n"); |
761 | 763 | ||
762 | if (ctx->cfg.logo && ctx->cfg.logo[0] != 0) { | 764 | if (ctx->repo && ctx->repo->logo && *ctx->repo->logo) |
765 | logo = ctx->repo->logo; | ||
766 | else | ||
767 | logo = ctx->cfg.logo; | ||
768 | if (ctx->repo && ctx->repo->logo_link && *ctx->repo->logo_link) | ||
769 | logo_link = ctx->repo->logo_link; | ||
770 | else | ||
771 | logo_link = ctx->cfg.logo_link; | ||
772 | if (logo && *logo) { | ||
763 | html("<td class='logo' rowspan='2'><a href='"); | 773 | html("<td class='logo' rowspan='2'><a href='"); |
764 | if (ctx->cfg.logo_link) | 774 | if (logo_link && *logo_link) |
765 | html_attr(ctx->cfg.logo_link); | 775 | html_attr(logo_link); |
766 | else | 776 | else |
767 | html_attr(cgit_rooturl()); | 777 | html_attr(cgit_rooturl()); |
768 | html("'><img src='"); | 778 | html("'><img src='"); |
769 | html_attr(ctx->cfg.logo); | 779 | html_attr(logo); |
770 | html("' alt='cgit logo'/></a></td>\n"); | 780 | html("' alt='cgit logo'/></a></td>\n"); |
771 | } | 781 | } |
772 | 782 | ||
773 | html("<td class='main'>"); | 783 | html("<td class='main'>"); |
774 | if (ctx->repo) { | 784 | if (ctx->repo) { |
775 | cgit_index_link("index", NULL, NULL, NULL, 0); | 785 | cgit_index_link("index", NULL, NULL, NULL, 0); |
776 | html(" : "); | 786 | html(" : "); |
777 | cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, NULL); | 787 | cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, NULL); |
778 | html("</td><td class='form'>"); | 788 | html("</td><td class='form'>"); |
779 | html("<form method='get' action=''>\n"); | 789 | html("<form method='get' action=''>\n"); |
780 | cgit_add_hidden_formfields(0, 1, ctx->qry.page); | 790 | cgit_add_hidden_formfields(0, 1, ctx->qry.page); |
781 | html("<select name='h' onchange='this.form.submit();'>\n"); | 791 | html("<select name='h' onchange='this.form.submit();'>\n"); |
782 | for_each_branch_ref(print_branch_option, ctx->qry.head); | 792 | for_each_branch_ref(print_branch_option, ctx->qry.head); |
783 | html("</select> "); | 793 | html("</select> "); |
784 | html("<input type='submit' name='' value='switch'/>"); | 794 | html("<input type='submit' name='' value='switch'/>"); |
785 | html("</form>"); | 795 | html("</form>"); |
786 | } else | 796 | } else |
787 | html_txt(ctx->cfg.root_title); | 797 | html_txt(ctx->cfg.root_title); |
788 | html("</td></tr>\n"); | 798 | html("</td></tr>\n"); |
789 | 799 | ||
790 | html("<tr><td class='sub'>"); | 800 | html("<tr><td class='sub'>"); |
791 | if (ctx->repo) { | 801 | if (ctx->repo) { |
792 | html_txt(ctx->repo->desc); | 802 | html_txt(ctx->repo->desc); |
793 | html("</td><td class='sub right'>"); | 803 | html("</td><td class='sub right'>"); |
794 | html_txt(ctx->repo->owner); | 804 | html_txt(ctx->repo->owner); |
795 | } else { | 805 | } else { |
796 | if (ctx->cfg.root_desc) | 806 | if (ctx->cfg.root_desc) |
797 | html_txt(ctx->cfg.root_desc); | 807 | html_txt(ctx->cfg.root_desc); |
798 | else if (ctx->cfg.index_info) | 808 | else if (ctx->cfg.index_info) |
799 | html_include(ctx->cfg.index_info); | 809 | html_include(ctx->cfg.index_info); |
800 | } | 810 | } |
801 | html("</td></tr></table>\n"); | 811 | html("</td></tr></table>\n"); |
802 | } | 812 | } |
803 | 813 | ||
804 | void cgit_print_pageheader(struct cgit_context *ctx) | 814 | void cgit_print_pageheader(struct cgit_context *ctx) |
805 | { | 815 | { |
806 | html("<div id='cgit'>"); | 816 | html("<div id='cgit'>"); |
807 | if (!ctx->cfg.noheader) | 817 | if (!ctx->cfg.noheader) |
808 | print_header(ctx); | 818 | print_header(ctx); |
809 | 819 | ||
810 | html("<table class='tabs'><tr><td>\n"); | 820 | html("<table class='tabs'><tr><td>\n"); |
811 | if (ctx->repo) { | 821 | if (ctx->repo) { |
812 | cgit_summary_link("summary", NULL, hc(ctx, "summary"), | 822 | cgit_summary_link("summary", NULL, hc(ctx, "summary"), |
813 | ctx->qry.head); | 823 | ctx->qry.head); |
814 | cgit_refs_link("refs", NULL, hc(ctx, "refs"), ctx->qry.head, | 824 | cgit_refs_link("refs", NULL, hc(ctx, "refs"), ctx->qry.head, |
815 | ctx->qry.sha1, NULL); | 825 | ctx->qry.sha1, NULL); |
816 | cgit_log_link("log", NULL, hc(ctx, "log"), ctx->qry.head, | 826 | cgit_log_link("log", NULL, hc(ctx, "log"), ctx->qry.head, |
817 | NULL, ctx->qry.vpath, 0, NULL, NULL, | 827 | NULL, ctx->qry.vpath, 0, NULL, NULL, |
818 | ctx->qry.showmsg); | 828 | ctx->qry.showmsg); |
819 | cgit_tree_link("tree", NULL, hc(ctx, "tree"), ctx->qry.head, | 829 | cgit_tree_link("tree", NULL, hc(ctx, "tree"), ctx->qry.head, |
820 | ctx->qry.sha1, ctx->qry.vpath); | 830 | ctx->qry.sha1, ctx->qry.vpath); |
821 | cgit_commit_link("commit", NULL, hc(ctx, "commit"), | 831 | cgit_commit_link("commit", NULL, hc(ctx, "commit"), |
822 | ctx->qry.head, ctx->qry.sha1, ctx->qry.vpath, 0); | 832 | ctx->qry.head, ctx->qry.sha1, ctx->qry.vpath, 0); |
823 | cgit_diff_link("diff", NULL, hc(ctx, "diff"), ctx->qry.head, | 833 | cgit_diff_link("diff", NULL, hc(ctx, "diff"), ctx->qry.head, |
824 | ctx->qry.sha1, ctx->qry.sha2, ctx->qry.vpath, 0); | 834 | ctx->qry.sha1, ctx->qry.sha2, ctx->qry.vpath, 0); |
825 | if (ctx->repo->max_stats) | 835 | if (ctx->repo->max_stats) |
826 | cgit_stats_link("stats", NULL, hc(ctx, "stats"), | 836 | cgit_stats_link("stats", NULL, hc(ctx, "stats"), |
827 | ctx->qry.head, ctx->qry.vpath); | 837 | ctx->qry.head, ctx->qry.vpath); |
828 | if (ctx->repo->readme) | 838 | if (ctx->repo->readme) |
829 | reporevlink("about", "about", NULL, | 839 | reporevlink("about", "about", NULL, |
830 | hc(ctx, "about"), ctx->qry.head, NULL, | 840 | hc(ctx, "about"), ctx->qry.head, NULL, |
831 | NULL); | 841 | NULL); |
832 | html("</td><td class='form'>"); | 842 | html("</td><td class='form'>"); |
833 | html("<form class='right' method='get' action='"); | 843 | html("<form class='right' method='get' action='"); |
834 | if (ctx->cfg.virtual_root) | 844 | if (ctx->cfg.virtual_root) |
835 | html_url_path(cgit_fileurl(ctx->qry.repo, "log", | 845 | html_url_path(cgit_fileurl(ctx->qry.repo, "log", |
836 | ctx->qry.vpath, NULL)); | 846 | ctx->qry.vpath, NULL)); |
837 | html("'>\n"); | 847 | html("'>\n"); |
838 | cgit_add_hidden_formfields(1, 0, "log"); | 848 | cgit_add_hidden_formfields(1, 0, "log"); |
839 | html("<select name='qt'>\n"); | 849 | html("<select name='qt'>\n"); |
840 | html_option("grep", "log msg", ctx->qry.grep); | 850 | html_option("grep", "log msg", ctx->qry.grep); |
841 | html_option("author", "author", ctx->qry.grep); | 851 | html_option("author", "author", ctx->qry.grep); |
842 | html_option("committer", "committer", ctx->qry.grep); | 852 | html_option("committer", "committer", ctx->qry.grep); |
843 | html_option("range", "range", ctx->qry.grep); | 853 | html_option("range", "range", ctx->qry.grep); |
844 | html("</select>\n"); | 854 | html("</select>\n"); |
845 | html("<input class='txt' type='text' size='10' name='q' value='"); | 855 | html("<input class='txt' type='text' size='10' name='q' value='"); |
846 | html_attr(ctx->qry.search); | 856 | html_attr(ctx->qry.search); |
847 | html("'/>\n"); | 857 | html("'/>\n"); |
848 | html("<input type='submit' value='search'/>\n"); | 858 | html("<input type='submit' value='search'/>\n"); |
849 | html("</form>\n"); | 859 | html("</form>\n"); |
850 | } else { | 860 | } else { |
851 | site_link(NULL, "index", NULL, hc(ctx, "repolist"), NULL, 0); | 861 | site_link(NULL, "index", NULL, hc(ctx, "repolist"), NULL, 0); |
852 | if (ctx->cfg.root_readme) | 862 | if (ctx->cfg.root_readme) |
853 | site_link("about", "about", NULL, hc(ctx, "about"), | 863 | site_link("about", "about", NULL, hc(ctx, "about"), |
854 | NULL, 0); | 864 | NULL, 0); |
855 | html("</td><td class='form'>"); | 865 | html("</td><td class='form'>"); |
856 | html("<form method='get' action='"); | 866 | html("<form method='get' action='"); |
857 | html_attr(cgit_rooturl()); | 867 | html_attr(cgit_rooturl()); |
858 | html("'>\n"); | 868 | html("'>\n"); |
859 | html("<input type='text' name='q' size='10' value='"); | 869 | html("<input type='text' name='q' size='10' value='"); |
860 | html_attr(ctx->qry.search); | 870 | html_attr(ctx->qry.search); |
861 | html("'/>\n"); | 871 | html("'/>\n"); |
862 | html("<input type='submit' value='search'/>\n"); | 872 | html("<input type='submit' value='search'/>\n"); |
863 | html("</form>"); | 873 | html("</form>"); |
864 | } | 874 | } |
865 | html("</td></tr></table>\n"); | 875 | html("</td></tr></table>\n"); |
866 | if (ctx->qry.vpath) { | 876 | if (ctx->qry.vpath) { |
867 | html("<div class='path'>"); | 877 | html("<div class='path'>"); |
868 | html("path: "); | 878 | html("path: "); |
869 | cgit_print_path_crumbs(ctx, ctx->qry.vpath); | 879 | cgit_print_path_crumbs(ctx, ctx->qry.vpath); |
870 | html("</div>"); | 880 | html("</div>"); |
871 | } | 881 | } |
872 | html("<div class='content'>"); | 882 | html("<div class='content'>"); |
873 | } | 883 | } |
874 | 884 | ||
875 | void cgit_print_filemode(unsigned short mode) | 885 | void cgit_print_filemode(unsigned short mode) |
876 | { | 886 | { |
877 | if (S_ISDIR(mode)) | 887 | if (S_ISDIR(mode)) |
878 | html("d"); | 888 | html("d"); |
879 | else if (S_ISLNK(mode)) | 889 | else if (S_ISLNK(mode)) |
880 | html("l"); | 890 | html("l"); |
881 | else if (S_ISGITLINK(mode)) | 891 | else if (S_ISGITLINK(mode)) |
882 | html("m"); | 892 | html("m"); |
883 | else | 893 | else |
884 | html("-"); | 894 | html("-"); |
885 | html_fileperm(mode >> 6); | 895 | html_fileperm(mode >> 6); |
886 | html_fileperm(mode >> 3); | 896 | html_fileperm(mode >> 3); |
887 | html_fileperm(mode); | 897 | html_fileperm(mode); |
888 | } | 898 | } |
889 | 899 | ||
890 | void cgit_print_snapshot_links(const char *repo, const char *head, | 900 | void cgit_print_snapshot_links(const char *repo, const char *head, |
891 | const char *hex, int snapshots) | 901 | const char *hex, int snapshots) |
892 | { | 902 | { |
893 | const struct cgit_snapshot_format* f; | 903 | const struct cgit_snapshot_format* f; |
894 | char *prefix; | 904 | char *prefix; |
895 | char *filename; | 905 | char *filename; |
896 | unsigned char sha1[20]; | 906 | unsigned char sha1[20]; |
897 | 907 | ||
898 | if (get_sha1(fmt("refs/tags/%s", hex), sha1) == 0 && | 908 | if (get_sha1(fmt("refs/tags/%s", hex), sha1) == 0 && |
899 | (hex[0] == 'v' || hex[0] == 'V') && isdigit(hex[1])) | 909 | (hex[0] == 'v' || hex[0] == 'V') && isdigit(hex[1])) |
900 | hex++; | 910 | hex++; |
901 | prefix = xstrdup(fmt("%s-%s", cgit_repobasename(repo), hex)); | 911 | prefix = xstrdup(fmt("%s-%s", cgit_repobasename(repo), hex)); |
902 | for (f = cgit_snapshot_formats; f->suffix; f++) { | 912 | for (f = cgit_snapshot_formats; f->suffix; f++) { |
903 | if (!(snapshots & f->bit)) | 913 | if (!(snapshots & f->bit)) |
904 | continue; | 914 | continue; |
905 | filename = fmt("%s%s", prefix, f->suffix); | 915 | filename = fmt("%s%s", prefix, f->suffix); |
906 | cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename); | 916 | cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename); |
907 | html("<br/>"); | 917 | html("<br/>"); |
908 | } | 918 | } |
909 | } | 919 | } |
diff --git a/ui-ssdiff.c b/ui-ssdiff.c index 408e620..2481585 100644 --- a/ui-ssdiff.c +++ b/ui-ssdiff.c | |||
@@ -1,369 +1,383 @@ | |||
1 | #include "cgit.h" | 1 | #include "cgit.h" |
2 | #include "html.h" | 2 | #include "html.h" |
3 | #include "ui-shared.h" | 3 | #include "ui-shared.h" |
4 | #include "ui-diff.h" | ||
4 | 5 | ||
5 | extern int use_ssdiff; | 6 | extern int use_ssdiff; |
6 | 7 | ||
7 | static int current_old_line, current_new_line; | 8 | static int current_old_line, current_new_line; |
8 | 9 | ||
9 | struct deferred_lines { | 10 | struct deferred_lines { |
10 | int line_no; | 11 | int line_no; |
11 | char *line; | 12 | char *line; |
12 | struct deferred_lines *next; | 13 | struct deferred_lines *next; |
13 | }; | 14 | }; |
14 | 15 | ||
15 | static struct deferred_lines *deferred_old, *deferred_old_last; | 16 | static struct deferred_lines *deferred_old, *deferred_old_last; |
16 | static struct deferred_lines *deferred_new, *deferred_new_last; | 17 | static struct deferred_lines *deferred_new, *deferred_new_last; |
17 | 18 | ||
18 | static char *longest_common_subsequence(char *A, char *B) | 19 | static char *longest_common_subsequence(char *A, char *B) |
19 | { | 20 | { |
20 | int i, j, ri; | 21 | int i, j, ri; |
21 | int m = strlen(A); | 22 | int m = strlen(A); |
22 | int n = strlen(B); | 23 | int n = strlen(B); |
23 | int L[m + 1][n + 1]; | 24 | int L[m + 1][n + 1]; |
24 | int tmp1, tmp2; | 25 | int tmp1, tmp2; |
25 | int lcs_length; | 26 | int lcs_length; |
26 | char *result; | 27 | char *result; |
27 | 28 | ||
28 | for (i = m; i >= 0; i--) { | 29 | for (i = m; i >= 0; i--) { |
29 | for (j = n; j >= 0; j--) { | 30 | for (j = n; j >= 0; j--) { |
30 | if (A[i] == '\0' || B[j] == '\0') { | 31 | if (A[i] == '\0' || B[j] == '\0') { |
31 | L[i][j] = 0; | 32 | L[i][j] = 0; |
32 | } else if (A[i] == B[j]) { | 33 | } else if (A[i] == B[j]) { |
33 | L[i][j] = 1 + L[i + 1][j + 1]; | 34 | L[i][j] = 1 + L[i + 1][j + 1]; |
34 | } else { | 35 | } else { |
35 | tmp1 = L[i + 1][j]; | 36 | tmp1 = L[i + 1][j]; |
36 | tmp2 = L[i][j + 1]; | 37 | tmp2 = L[i][j + 1]; |
37 | L[i][j] = (tmp1 > tmp2 ? tmp1 : tmp2); | 38 | L[i][j] = (tmp1 > tmp2 ? tmp1 : tmp2); |
38 | } | 39 | } |
39 | } | 40 | } |
40 | } | 41 | } |
41 | 42 | ||
42 | lcs_length = L[0][0]; | 43 | lcs_length = L[0][0]; |
43 | result = xmalloc(lcs_length + 2); | 44 | result = xmalloc(lcs_length + 2); |
44 | memset(result, 0, sizeof(*result) * (lcs_length + 2)); | 45 | memset(result, 0, sizeof(*result) * (lcs_length + 2)); |
45 | 46 | ||
46 | ri = 0; | 47 | ri = 0; |
47 | i = 0; | 48 | i = 0; |
48 | j = 0; | 49 | j = 0; |
49 | while (i < m && j < n) { | 50 | while (i < m && j < n) { |
50 | if (A[i] == B[j]) { | 51 | if (A[i] == B[j]) { |
51 | result[ri] = A[i]; | 52 | result[ri] = A[i]; |
52 | ri += 1; | 53 | ri += 1; |
53 | i += 1; | 54 | i += 1; |
54 | j += 1; | 55 | j += 1; |
55 | } else if (L[i + 1][j] >= L[i][j + 1]) { | 56 | } else if (L[i + 1][j] >= L[i][j + 1]) { |
56 | i += 1; | 57 | i += 1; |
57 | } else { | 58 | } else { |
58 | j += 1; | 59 | j += 1; |
59 | } | 60 | } |
60 | } | 61 | } |
61 | return result; | 62 | return result; |
62 | } | 63 | } |
63 | 64 | ||
64 | static int line_from_hunk(char *line, char type) | 65 | static int line_from_hunk(char *line, char type) |
65 | { | 66 | { |
66 | char *buf1, *buf2; | 67 | char *buf1, *buf2; |
67 | int len; | 68 | int len; |
68 | 69 | ||
69 | buf1 = strchr(line, type); | 70 | buf1 = strchr(line, type); |
70 | if (buf1 == NULL) | 71 | if (buf1 == NULL) |
71 | return 0; | 72 | return 0; |
72 | buf1 += 1; | 73 | buf1 += 1; |
73 | buf2 = strchr(buf1, ','); | 74 | buf2 = strchr(buf1, ','); |
74 | if (buf2 == NULL) | 75 | if (buf2 == NULL) |
75 | return 0; | 76 | return 0; |
76 | len = buf2 - buf1; | 77 | len = buf2 - buf1; |
77 | buf2 = xmalloc(len + 1); | 78 | buf2 = xmalloc(len + 1); |
78 | strncpy(buf2, buf1, len); | 79 | strncpy(buf2, buf1, len); |
79 | buf2[len] = '\0'; | 80 | buf2[len] = '\0'; |
80 | int res = atoi(buf2); | 81 | int res = atoi(buf2); |
81 | free(buf2); | 82 | free(buf2); |
82 | return res; | 83 | return res; |
83 | } | 84 | } |
84 | 85 | ||
85 | static char *replace_tabs(char *line) | 86 | static char *replace_tabs(char *line) |
86 | { | 87 | { |
87 | char *prev_buf = line; | 88 | char *prev_buf = line; |
88 | char *cur_buf; | 89 | char *cur_buf; |
89 | int linelen = strlen(line); | 90 | int linelen = strlen(line); |
90 | int n_tabs = 0; | 91 | int n_tabs = 0; |
91 | int i; | 92 | int i; |
92 | char *result; | 93 | char *result; |
93 | char *spaces = " "; | 94 | char *spaces = " "; |
94 | 95 | ||
95 | if (linelen == 0) { | 96 | if (linelen == 0) { |
96 | result = xmalloc(1); | 97 | result = xmalloc(1); |
97 | result[0] = '\0'; | 98 | result[0] = '\0'; |
98 | return result; | 99 | return result; |
99 | } | 100 | } |
100 | 101 | ||
101 | for (i = 0; i < linelen; i++) | 102 | for (i = 0; i < linelen; i++) |
102 | if (line[i] == '\t') | 103 | if (line[i] == '\t') |
103 | n_tabs += 1; | 104 | n_tabs += 1; |
104 | result = xmalloc(linelen + n_tabs * 8 + 1); | 105 | result = xmalloc(linelen + n_tabs * 8 + 1); |
105 | result[0] = '\0'; | 106 | result[0] = '\0'; |
106 | 107 | ||
107 | while (1) { | 108 | while (1) { |
108 | cur_buf = strchr(prev_buf, '\t'); | 109 | cur_buf = strchr(prev_buf, '\t'); |
109 | if (!cur_buf) { | 110 | if (!cur_buf) { |
110 | strcat(result, prev_buf); | 111 | strcat(result, prev_buf); |
111 | break; | 112 | break; |
112 | } else { | 113 | } else { |
113 | strcat(result, " "); | 114 | strcat(result, " "); |
114 | strncat(result, spaces, 8 - (strlen(result) % 8)); | 115 | strncat(result, spaces, 8 - (strlen(result) % 8)); |
115 | strncat(result, prev_buf, cur_buf - prev_buf); | 116 | strncat(result, prev_buf, cur_buf - prev_buf); |
116 | } | 117 | } |
117 | prev_buf = cur_buf + 1; | 118 | prev_buf = cur_buf + 1; |
118 | } | 119 | } |
119 | return result; | 120 | return result; |
120 | } | 121 | } |
121 | 122 | ||
122 | static int calc_deferred_lines(struct deferred_lines *start) | 123 | static int calc_deferred_lines(struct deferred_lines *start) |
123 | { | 124 | { |
124 | struct deferred_lines *item = start; | 125 | struct deferred_lines *item = start; |
125 | int result = 0; | 126 | int result = 0; |
126 | while (item) { | 127 | while (item) { |
127 | result += 1; | 128 | result += 1; |
128 | item = item->next; | 129 | item = item->next; |
129 | } | 130 | } |
130 | return result; | 131 | return result; |
131 | } | 132 | } |
132 | 133 | ||
133 | static void deferred_old_add(char *line, int line_no) | 134 | static void deferred_old_add(char *line, int line_no) |
134 | { | 135 | { |
135 | struct deferred_lines *item = xmalloc(sizeof(struct deferred_lines)); | 136 | struct deferred_lines *item = xmalloc(sizeof(struct deferred_lines)); |
136 | item->line = xstrdup(line); | 137 | item->line = xstrdup(line); |
137 | item->line_no = line_no; | 138 | item->line_no = line_no; |
138 | item->next = NULL; | 139 | item->next = NULL; |
139 | if (deferred_old) { | 140 | if (deferred_old) { |
140 | deferred_old_last->next = item; | 141 | deferred_old_last->next = item; |
141 | deferred_old_last = item; | 142 | deferred_old_last = item; |
142 | } else { | 143 | } else { |
143 | deferred_old = deferred_old_last = item; | 144 | deferred_old = deferred_old_last = item; |
144 | } | 145 | } |
145 | } | 146 | } |
146 | 147 | ||
147 | static void deferred_new_add(char *line, int line_no) | 148 | static void deferred_new_add(char *line, int line_no) |
148 | { | 149 | { |
149 | struct deferred_lines *item = xmalloc(sizeof(struct deferred_lines)); | 150 | struct deferred_lines *item = xmalloc(sizeof(struct deferred_lines)); |
150 | item->line = xstrdup(line); | 151 | item->line = xstrdup(line); |
151 | item->line_no = line_no; | 152 | item->line_no = line_no; |
152 | item->next = NULL; | 153 | item->next = NULL; |
153 | if (deferred_new) { | 154 | if (deferred_new) { |
154 | deferred_new_last->next = item; | 155 | deferred_new_last->next = item; |
155 | deferred_new_last = item; | 156 | deferred_new_last = item; |
156 | } else { | 157 | } else { |
157 | deferred_new = deferred_new_last = item; | 158 | deferred_new = deferred_new_last = item; |
158 | } | 159 | } |
159 | } | 160 | } |
160 | 161 | ||
161 | static void print_part_with_lcs(char *class, char *line, char *lcs) | 162 | static void print_part_with_lcs(char *class, char *line, char *lcs) |
162 | { | 163 | { |
163 | int line_len = strlen(line); | 164 | int line_len = strlen(line); |
164 | int i, j; | 165 | int i, j; |
165 | char c[2] = " "; | 166 | char c[2] = " "; |
166 | int same = 1; | 167 | int same = 1; |
167 | 168 | ||
168 | j = 0; | 169 | j = 0; |
169 | for (i = 0; i < line_len; i++) { | 170 | for (i = 0; i < line_len; i++) { |
170 | c[0] = line[i]; | 171 | c[0] = line[i]; |
171 | if (same) { | 172 | if (same) { |
172 | if (line[i] == lcs[j]) | 173 | if (line[i] == lcs[j]) |
173 | j += 1; | 174 | j += 1; |
174 | else { | 175 | else { |
175 | same = 0; | 176 | same = 0; |
176 | htmlf("<span class='%s'>", class); | 177 | htmlf("<span class='%s'>", class); |
177 | } | 178 | } |
178 | } else if (line[i] == lcs[j]) { | 179 | } else if (line[i] == lcs[j]) { |
179 | same = 1; | 180 | same = 1; |
180 | htmlf("</span>"); | 181 | htmlf("</span>"); |
181 | j += 1; | 182 | j += 1; |
182 | } | 183 | } |
183 | html_txt(c); | 184 | html_txt(c); |
184 | } | 185 | } |
185 | } | 186 | } |
186 | 187 | ||
187 | static void print_ssdiff_line(char *class, | 188 | static void print_ssdiff_line(char *class, |
188 | int old_line_no, | 189 | int old_line_no, |
189 | char *old_line, | 190 | char *old_line, |
190 | int new_line_no, | 191 | int new_line_no, |
191 | char *new_line, int individual_chars) | 192 | char *new_line, int individual_chars) |
192 | { | 193 | { |
193 | char *lcs = NULL; | 194 | char *lcs = NULL; |
195 | |||
194 | if (old_line) | 196 | if (old_line) |
195 | old_line = replace_tabs(old_line + 1); | 197 | old_line = replace_tabs(old_line + 1); |
196 | if (new_line) | 198 | if (new_line) |
197 | new_line = replace_tabs(new_line + 1); | 199 | new_line = replace_tabs(new_line + 1); |
198 | if (individual_chars && old_line && new_line) | 200 | if (individual_chars && old_line && new_line) |
199 | lcs = longest_common_subsequence(old_line, new_line); | 201 | lcs = longest_common_subsequence(old_line, new_line); |
200 | html("<tr>"); | 202 | html("<tr>\n"); |
201 | if (old_line_no > 0) | 203 | if (old_line_no > 0) { |
202 | htmlf("<td class='lineno'>%d</td><td class='%s'>", | 204 | struct diff_filespec *old_file = cgit_get_current_old_file(); |
203 | old_line_no, class); | 205 | char *lineno_str = fmt("n%d", old_line_no); |
204 | else if (old_line) | 206 | char *id_str = fmt("%s#%s", is_null_sha1(old_file->sha1)?"HEAD":sha1_to_hex(old_rev_sha1), lineno_str); |
207 | html("<td class='lineno'><a class='no' href='"); | ||
208 | html(cgit_fileurl(ctx.repo->url, "tree", old_file->path, id_str)); | ||
209 | htmlf("' id='%s' name='%s'>%s</a>", lineno_str, lineno_str, lineno_str + 1); | ||
210 | html("</td>"); | ||
211 | htmlf("<td class='%s'>", class); | ||
212 | } else if (old_line) | ||
205 | htmlf("<td class='lineno'></td><td class='%s'>", class); | 213 | htmlf("<td class='lineno'></td><td class='%s'>", class); |
206 | else | 214 | else |
207 | htmlf("<td class='lineno'></td><td class='%s_dark'>", class); | 215 | htmlf("<td class='lineno'></td><td class='%s_dark'>", class); |
208 | if (old_line) { | 216 | if (old_line) { |
209 | if (lcs) | 217 | if (lcs) |
210 | print_part_with_lcs("del", old_line, lcs); | 218 | print_part_with_lcs("del", old_line, lcs); |
211 | else | 219 | else |
212 | html_txt(old_line); | 220 | html_txt(old_line); |
213 | } | 221 | } |
214 | 222 | ||
215 | html("</td>"); | 223 | html("</td>\n"); |
216 | if (new_line_no > 0) | 224 | if (new_line_no > 0) { |
217 | htmlf("<td class='lineno'>%d</td><td class='%s'>", | 225 | struct diff_filespec *new_file = cgit_get_current_new_file(); |
218 | new_line_no, class); | 226 | char *lineno_str = fmt("n%d", new_line_no); |
219 | else if (new_line) | 227 | char *id_str = fmt("%s#%s", is_null_sha1(new_file->sha1)?"HEAD":sha1_to_hex(new_rev_sha1), lineno_str); |
228 | html("<td class='lineno'><a class='no' href='"); | ||
229 | html(cgit_fileurl(ctx.repo->url, "tree", new_file->path, id_str)); | ||
230 | htmlf("' id='%s' name='%s'>%s</a>", lineno_str, lineno_str, lineno_str + 1); | ||
231 | html("</td>"); | ||
232 | htmlf("<td class='%s'>", class); | ||
233 | } else if (new_line) | ||
220 | htmlf("<td class='lineno'></td><td class='%s'>", class); | 234 | htmlf("<td class='lineno'></td><td class='%s'>", class); |
221 | else | 235 | else |
222 | htmlf("<td class='lineno'></td><td class='%s_dark'>", class); | 236 | htmlf("<td class='lineno'></td><td class='%s_dark'>", class); |
223 | if (new_line) { | 237 | if (new_line) { |
224 | if (lcs) | 238 | if (lcs) |
225 | print_part_with_lcs("add", new_line, lcs); | 239 | print_part_with_lcs("add", new_line, lcs); |
226 | else | 240 | else |
227 | html_txt(new_line); | 241 | html_txt(new_line); |
228 | } | 242 | } |
229 | 243 | ||
230 | html("</td></tr>"); | 244 | html("</td></tr>"); |
231 | if (lcs) | 245 | if (lcs) |
232 | free(lcs); | 246 | free(lcs); |
233 | if (new_line) | 247 | if (new_line) |
234 | free(new_line); | 248 | free(new_line); |
235 | if (old_line) | 249 | if (old_line) |
236 | free(old_line); | 250 | free(old_line); |
237 | } | 251 | } |
238 | 252 | ||
239 | static void print_deferred_old_lines() | 253 | static void print_deferred_old_lines() |
240 | { | 254 | { |
241 | struct deferred_lines *iter_old, *tmp; | 255 | struct deferred_lines *iter_old, *tmp; |
242 | iter_old = deferred_old; | 256 | iter_old = deferred_old; |
243 | while (iter_old) { | 257 | while (iter_old) { |
244 | print_ssdiff_line("del", iter_old->line_no, | 258 | print_ssdiff_line("del", iter_old->line_no, |
245 | iter_old->line, -1, NULL, 0); | 259 | iter_old->line, -1, NULL, 0); |
246 | tmp = iter_old->next; | 260 | tmp = iter_old->next; |
247 | free(iter_old); | 261 | free(iter_old); |
248 | iter_old = tmp; | 262 | iter_old = tmp; |
249 | } | 263 | } |
250 | } | 264 | } |
251 | 265 | ||
252 | static void print_deferred_new_lines() | 266 | static void print_deferred_new_lines() |
253 | { | 267 | { |
254 | struct deferred_lines *iter_new, *tmp; | 268 | struct deferred_lines *iter_new, *tmp; |
255 | iter_new = deferred_new; | 269 | iter_new = deferred_new; |
256 | while (iter_new) { | 270 | while (iter_new) { |
257 | print_ssdiff_line("add", -1, NULL, | 271 | print_ssdiff_line("add", -1, NULL, |
258 | iter_new->line_no, iter_new->line, 0); | 272 | iter_new->line_no, iter_new->line, 0); |
259 | tmp = iter_new->next; | 273 | tmp = iter_new->next; |
260 | free(iter_new); | 274 | free(iter_new); |
261 | iter_new = tmp; | 275 | iter_new = tmp; |
262 | } | 276 | } |
263 | } | 277 | } |
264 | 278 | ||
265 | static void print_deferred_changed_lines() | 279 | static void print_deferred_changed_lines() |
266 | { | 280 | { |
267 | struct deferred_lines *iter_old, *iter_new, *tmp; | 281 | struct deferred_lines *iter_old, *iter_new, *tmp; |
268 | int n_old_lines = calc_deferred_lines(deferred_old); | 282 | int n_old_lines = calc_deferred_lines(deferred_old); |
269 | int n_new_lines = calc_deferred_lines(deferred_new); | 283 | int n_new_lines = calc_deferred_lines(deferred_new); |
270 | int individual_chars = (n_old_lines == n_new_lines ? 1 : 0); | 284 | int individual_chars = (n_old_lines == n_new_lines ? 1 : 0); |
271 | 285 | ||
272 | iter_old = deferred_old; | 286 | iter_old = deferred_old; |
273 | iter_new = deferred_new; | 287 | iter_new = deferred_new; |
274 | while (iter_old || iter_new) { | 288 | while (iter_old || iter_new) { |
275 | if (iter_old && iter_new) | 289 | if (iter_old && iter_new) |
276 | print_ssdiff_line("changed", iter_old->line_no, | 290 | print_ssdiff_line("changed", iter_old->line_no, |
277 | iter_old->line, | 291 | iter_old->line, |
278 | iter_new->line_no, iter_new->line, | 292 | iter_new->line_no, iter_new->line, |
279 | individual_chars); | 293 | individual_chars); |
280 | else if (iter_old) | 294 | else if (iter_old) |
281 | print_ssdiff_line("changed", iter_old->line_no, | 295 | print_ssdiff_line("changed", iter_old->line_no, |
282 | iter_old->line, -1, NULL, 0); | 296 | iter_old->line, -1, NULL, 0); |
283 | else if (iter_new) | 297 | else if (iter_new) |
284 | print_ssdiff_line("changed", -1, NULL, | 298 | print_ssdiff_line("changed", -1, NULL, |
285 | iter_new->line_no, iter_new->line, 0); | 299 | iter_new->line_no, iter_new->line, 0); |
286 | if (iter_old) { | 300 | if (iter_old) { |
287 | tmp = iter_old->next; | 301 | tmp = iter_old->next; |
288 | free(iter_old); | 302 | free(iter_old); |
289 | iter_old = tmp; | 303 | iter_old = tmp; |
290 | } | 304 | } |
291 | 305 | ||
292 | if (iter_new) { | 306 | if (iter_new) { |
293 | tmp = iter_new->next; | 307 | tmp = iter_new->next; |
294 | free(iter_new); | 308 | free(iter_new); |
295 | iter_new = tmp; | 309 | iter_new = tmp; |
296 | } | 310 | } |
297 | } | 311 | } |
298 | } | 312 | } |
299 | 313 | ||
300 | void cgit_ssdiff_print_deferred_lines() | 314 | void cgit_ssdiff_print_deferred_lines() |
301 | { | 315 | { |
302 | if (!deferred_old && !deferred_new) | 316 | if (!deferred_old && !deferred_new) |
303 | return; | 317 | return; |
304 | if (deferred_old && !deferred_new) | 318 | if (deferred_old && !deferred_new) |
305 | print_deferred_old_lines(); | 319 | print_deferred_old_lines(); |
306 | else if (!deferred_old && deferred_new) | 320 | else if (!deferred_old && deferred_new) |
307 | print_deferred_new_lines(); | 321 | print_deferred_new_lines(); |
308 | else | 322 | else |
309 | print_deferred_changed_lines(); | 323 | print_deferred_changed_lines(); |
310 | deferred_old = deferred_old_last = NULL; | 324 | deferred_old = deferred_old_last = NULL; |
311 | deferred_new = deferred_new_last = NULL; | 325 | deferred_new = deferred_new_last = NULL; |
312 | } | 326 | } |
313 | 327 | ||
314 | /* | 328 | /* |
315 | * print a single line returned from xdiff | 329 | * print a single line returned from xdiff |
316 | */ | 330 | */ |
317 | void cgit_ssdiff_line_cb(char *line, int len) | 331 | void cgit_ssdiff_line_cb(char *line, int len) |
318 | { | 332 | { |
319 | char c = line[len - 1]; | 333 | char c = line[len - 1]; |
320 | line[len - 1] = '\0'; | 334 | line[len - 1] = '\0'; |
321 | if (line[0] == '@') { | 335 | if (line[0] == '@') { |
322 | current_old_line = line_from_hunk(line, '-'); | 336 | current_old_line = line_from_hunk(line, '-'); |
323 | current_new_line = line_from_hunk(line, '+'); | 337 | current_new_line = line_from_hunk(line, '+'); |
324 | } | 338 | } |
325 | 339 | ||
326 | if (line[0] == ' ') { | 340 | if (line[0] == ' ') { |
327 | if (deferred_old || deferred_new) | 341 | if (deferred_old || deferred_new) |
328 | cgit_ssdiff_print_deferred_lines(); | 342 | cgit_ssdiff_print_deferred_lines(); |
329 | print_ssdiff_line("ctx", current_old_line, line, | 343 | print_ssdiff_line("ctx", current_old_line, line, |
330 | current_new_line, line, 0); | 344 | current_new_line, line, 0); |
331 | current_old_line += 1; | 345 | current_old_line += 1; |
332 | current_new_line += 1; | 346 | current_new_line += 1; |
333 | } else if (line[0] == '+') { | 347 | } else if (line[0] == '+') { |
334 | deferred_new_add(line, current_new_line); | 348 | deferred_new_add(line, current_new_line); |
335 | current_new_line += 1; | 349 | current_new_line += 1; |
336 | } else if (line[0] == '-') { | 350 | } else if (line[0] == '-') { |
337 | deferred_old_add(line, current_old_line); | 351 | deferred_old_add(line, current_old_line); |
338 | current_old_line += 1; | 352 | current_old_line += 1; |
339 | } else if (line[0] == '@') { | 353 | } else if (line[0] == '@') { |
340 | html("<tr><td colspan='4' class='hunk'>"); | 354 | html("<tr><td colspan='4' class='hunk'>"); |
341 | html_txt(line); | 355 | html_txt(line); |
342 | html("</td></tr>"); | 356 | html("</td></tr>"); |
343 | } else { | 357 | } else { |
344 | html("<tr><td colspan='4' class='ctx'>"); | 358 | html("<tr><td colspan='4' class='ctx'>"); |
345 | html_txt(line); | 359 | html_txt(line); |
346 | html("</td></tr>"); | 360 | html("</td></tr>"); |
347 | } | 361 | } |
348 | line[len - 1] = c; | 362 | line[len - 1] = c; |
349 | } | 363 | } |
350 | 364 | ||
351 | void cgit_ssdiff_header_begin() | 365 | void cgit_ssdiff_header_begin() |
352 | { | 366 | { |
353 | current_old_line = -1; | 367 | current_old_line = -1; |
354 | current_new_line = -1; | 368 | current_new_line = -1; |
355 | html("<tr><td class='space' colspan='4'><div></div></td></tr>"); | 369 | html("<tr><td class='space' colspan='4'><div></div></td></tr>"); |
356 | html("<tr><td class='head' colspan='4'>"); | 370 | html("<tr><td class='head' colspan='4'>"); |
357 | } | 371 | } |
358 | 372 | ||
359 | void cgit_ssdiff_header_end() | 373 | void cgit_ssdiff_header_end() |
360 | { | 374 | { |
361 | html("</td><tr>"); | 375 | html("</td><tr>"); |
362 | } | 376 | } |
363 | 377 | ||
364 | void cgit_ssdiff_footer() | 378 | void cgit_ssdiff_footer() |
365 | { | 379 | { |
366 | if (deferred_old || deferred_new) | 380 | if (deferred_old || deferred_new) |
367 | cgit_ssdiff_print_deferred_lines(); | 381 | cgit_ssdiff_print_deferred_lines(); |
368 | html("<tr><td class='foot' colspan='4'></td></tr>"); | 382 | html("<tr><td class='foot' colspan='4'></td></tr>"); |
369 | } | 383 | } |