summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c2
-rw-r--r--cgit.h1
-rw-r--r--cgitrc.5.txt4
-rw-r--r--ui-atom.c2
-rw-r--r--ui-commit.c12
-rw-r--r--ui-patch.c6
-rw-r--r--ui-tag.c2
7 files changed, 22 insertions, 7 deletions
diff --git a/cgit.c b/cgit.c
index 2039ab1..f6bb0c7 100644
--- a/cgit.c
+++ b/cgit.c
@@ -1,149 +1,151 @@
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 * 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 "cache.h" 10#include "cache.h"
11#include "cmd.h" 11#include "cmd.h"
12#include "configfile.h" 12#include "configfile.h"
13#include "html.h" 13#include "html.h"
14#include "ui-shared.h" 14#include "ui-shared.h"
15#include "ui-stats.h" 15#include "ui-stats.h"
16#include "scan-tree.h" 16#include "scan-tree.h"
17 17
18const char *cgit_version = CGIT_VERSION; 18const char *cgit_version = CGIT_VERSION;
19 19
20void config_cb(const char *name, const char *value) 20void config_cb(const char *name, const char *value)
21{ 21{
22 if (!strcmp(name, "root-title")) 22 if (!strcmp(name, "root-title"))
23 ctx.cfg.root_title = xstrdup(value); 23 ctx.cfg.root_title = xstrdup(value);
24 else if (!strcmp(name, "root-desc")) 24 else if (!strcmp(name, "root-desc"))
25 ctx.cfg.root_desc = xstrdup(value); 25 ctx.cfg.root_desc = xstrdup(value);
26 else if (!strcmp(name, "root-readme")) 26 else if (!strcmp(name, "root-readme"))
27 ctx.cfg.root_readme = xstrdup(value); 27 ctx.cfg.root_readme = xstrdup(value);
28 else if (!strcmp(name, "css")) 28 else if (!strcmp(name, "css"))
29 ctx.cfg.css = xstrdup(value); 29 ctx.cfg.css = xstrdup(value);
30 else if (!strcmp(name, "favicon")) 30 else if (!strcmp(name, "favicon"))
31 ctx.cfg.favicon = xstrdup(value); 31 ctx.cfg.favicon = xstrdup(value);
32 else if (!strcmp(name, "footer")) 32 else if (!strcmp(name, "footer"))
33 ctx.cfg.footer = xstrdup(value); 33 ctx.cfg.footer = xstrdup(value);
34 else if (!strcmp(name, "head-include")) 34 else if (!strcmp(name, "head-include"))
35 ctx.cfg.head_include = xstrdup(value); 35 ctx.cfg.head_include = xstrdup(value);
36 else if (!strcmp(name, "header")) 36 else if (!strcmp(name, "header"))
37 ctx.cfg.header = xstrdup(value); 37 ctx.cfg.header = xstrdup(value);
38 else if (!strcmp(name, "logo")) 38 else if (!strcmp(name, "logo"))
39 ctx.cfg.logo = xstrdup(value); 39 ctx.cfg.logo = xstrdup(value);
40 else if (!strcmp(name, "index-header")) 40 else if (!strcmp(name, "index-header"))
41 ctx.cfg.index_header = xstrdup(value); 41 ctx.cfg.index_header = xstrdup(value);
42 else if (!strcmp(name, "index-info")) 42 else if (!strcmp(name, "index-info"))
43 ctx.cfg.index_info = xstrdup(value); 43 ctx.cfg.index_info = xstrdup(value);
44 else if (!strcmp(name, "logo-link")) 44 else if (!strcmp(name, "logo-link"))
45 ctx.cfg.logo_link = xstrdup(value); 45 ctx.cfg.logo_link = xstrdup(value);
46 else if (!strcmp(name, "module-link")) 46 else if (!strcmp(name, "module-link"))
47 ctx.cfg.module_link = xstrdup(value); 47 ctx.cfg.module_link = xstrdup(value);
48 else if (!strcmp(name, "virtual-root")) { 48 else if (!strcmp(name, "virtual-root")) {
49 ctx.cfg.virtual_root = trim_end(value, '/'); 49 ctx.cfg.virtual_root = trim_end(value, '/');
50 if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) 50 if (!ctx.cfg.virtual_root && (!strcmp(value, "/")))
51 ctx.cfg.virtual_root = ""; 51 ctx.cfg.virtual_root = "";
52 } else if (!strcmp(name, "nocache")) 52 } else if (!strcmp(name, "nocache"))
53 ctx.cfg.nocache = atoi(value); 53 ctx.cfg.nocache = atoi(value);
54 else if (!strcmp(name, "noplainemail"))
55 ctx.cfg.noplainemail = atoi(value);
54 else if (!strcmp(name, "noheader")) 56 else if (!strcmp(name, "noheader"))
55 ctx.cfg.noheader = atoi(value); 57 ctx.cfg.noheader = atoi(value);
56 else if (!strcmp(name, "snapshots")) 58 else if (!strcmp(name, "snapshots"))
57 ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); 59 ctx.cfg.snapshots = cgit_parse_snapshots_mask(value);
58 else if (!strcmp(name, "enable-index-links")) 60 else if (!strcmp(name, "enable-index-links"))
59 ctx.cfg.enable_index_links = atoi(value); 61 ctx.cfg.enable_index_links = atoi(value);
60 else if (!strcmp(name, "enable-log-filecount")) 62 else if (!strcmp(name, "enable-log-filecount"))
61 ctx.cfg.enable_log_filecount = atoi(value); 63 ctx.cfg.enable_log_filecount = atoi(value);
62 else if (!strcmp(name, "enable-log-linecount")) 64 else if (!strcmp(name, "enable-log-linecount"))
63 ctx.cfg.enable_log_linecount = atoi(value); 65 ctx.cfg.enable_log_linecount = atoi(value);
64 else if (!strcmp(name, "max-stats")) 66 else if (!strcmp(name, "max-stats"))
65 ctx.cfg.max_stats = cgit_find_stats_period(value, NULL); 67 ctx.cfg.max_stats = cgit_find_stats_period(value, NULL);
66 else if (!strcmp(name, "cache-size")) 68 else if (!strcmp(name, "cache-size"))
67 ctx.cfg.cache_size = atoi(value); 69 ctx.cfg.cache_size = atoi(value);
68 else if (!strcmp(name, "cache-root")) 70 else if (!strcmp(name, "cache-root"))
69 ctx.cfg.cache_root = xstrdup(value); 71 ctx.cfg.cache_root = xstrdup(value);
70 else if (!strcmp(name, "cache-root-ttl")) 72 else if (!strcmp(name, "cache-root-ttl"))
71 ctx.cfg.cache_root_ttl = atoi(value); 73 ctx.cfg.cache_root_ttl = atoi(value);
72 else if (!strcmp(name, "cache-repo-ttl")) 74 else if (!strcmp(name, "cache-repo-ttl"))
73 ctx.cfg.cache_repo_ttl = atoi(value); 75 ctx.cfg.cache_repo_ttl = atoi(value);
74 else if (!strcmp(name, "cache-static-ttl")) 76 else if (!strcmp(name, "cache-static-ttl"))
75 ctx.cfg.cache_static_ttl = atoi(value); 77 ctx.cfg.cache_static_ttl = atoi(value);
76 else if (!strcmp(name, "cache-dynamic-ttl")) 78 else if (!strcmp(name, "cache-dynamic-ttl"))
77 ctx.cfg.cache_dynamic_ttl = atoi(value); 79 ctx.cfg.cache_dynamic_ttl = atoi(value);
78 else if (!strcmp(name, "embedded")) 80 else if (!strcmp(name, "embedded"))
79 ctx.cfg.embedded = atoi(value); 81 ctx.cfg.embedded = atoi(value);
80 else if (!strcmp(name, "max-message-length")) 82 else if (!strcmp(name, "max-message-length"))
81 ctx.cfg.max_msg_len = atoi(value); 83 ctx.cfg.max_msg_len = atoi(value);
82 else if (!strcmp(name, "max-repodesc-length")) 84 else if (!strcmp(name, "max-repodesc-length"))
83 ctx.cfg.max_repodesc_len = atoi(value); 85 ctx.cfg.max_repodesc_len = atoi(value);
84 else if (!strcmp(name, "max-repo-count")) 86 else if (!strcmp(name, "max-repo-count"))
85 ctx.cfg.max_repo_count = atoi(value); 87 ctx.cfg.max_repo_count = atoi(value);
86 else if (!strcmp(name, "max-commit-count")) 88 else if (!strcmp(name, "max-commit-count"))
87 ctx.cfg.max_commit_count = atoi(value); 89 ctx.cfg.max_commit_count = atoi(value);
88 else if (!strcmp(name, "summary-log")) 90 else if (!strcmp(name, "summary-log"))
89 ctx.cfg.summary_log = atoi(value); 91 ctx.cfg.summary_log = atoi(value);
90 else if (!strcmp(name, "summary-branches")) 92 else if (!strcmp(name, "summary-branches"))
91 ctx.cfg.summary_branches = atoi(value); 93 ctx.cfg.summary_branches = atoi(value);
92 else if (!strcmp(name, "summary-tags")) 94 else if (!strcmp(name, "summary-tags"))
93 ctx.cfg.summary_tags = atoi(value); 95 ctx.cfg.summary_tags = atoi(value);
94 else if (!strcmp(name, "agefile")) 96 else if (!strcmp(name, "agefile"))
95 ctx.cfg.agefile = xstrdup(value); 97 ctx.cfg.agefile = xstrdup(value);
96 else if (!strcmp(name, "renamelimit")) 98 else if (!strcmp(name, "renamelimit"))
97 ctx.cfg.renamelimit = atoi(value); 99 ctx.cfg.renamelimit = atoi(value);
98 else if (!strcmp(name, "robots")) 100 else if (!strcmp(name, "robots"))
99 ctx.cfg.robots = xstrdup(value); 101 ctx.cfg.robots = xstrdup(value);
100 else if (!strcmp(name, "clone-prefix")) 102 else if (!strcmp(name, "clone-prefix"))
101 ctx.cfg.clone_prefix = xstrdup(value); 103 ctx.cfg.clone_prefix = xstrdup(value);
102 else if (!strcmp(name, "local-time")) 104 else if (!strcmp(name, "local-time"))
103 ctx.cfg.local_time = atoi(value); 105 ctx.cfg.local_time = atoi(value);
104 else if (!strcmp(name, "repo.group")) 106 else if (!strcmp(name, "repo.group"))
105 ctx.cfg.repo_group = xstrdup(value); 107 ctx.cfg.repo_group = xstrdup(value);
106 else if (!strcmp(name, "repo.url")) 108 else if (!strcmp(name, "repo.url"))
107 ctx.repo = cgit_add_repo(value); 109 ctx.repo = cgit_add_repo(value);
108 else if (!strcmp(name, "repo.name")) 110 else if (!strcmp(name, "repo.name"))
109 ctx.repo->name = xstrdup(value); 111 ctx.repo->name = xstrdup(value);
110 else if (ctx.repo && !strcmp(name, "repo.path")) 112 else if (ctx.repo && !strcmp(name, "repo.path"))
111 ctx.repo->path = trim_end(value, '/'); 113 ctx.repo->path = trim_end(value, '/');
112 else if (ctx.repo && !strcmp(name, "repo.clone-url")) 114 else if (ctx.repo && !strcmp(name, "repo.clone-url"))
113 ctx.repo->clone_url = xstrdup(value); 115 ctx.repo->clone_url = xstrdup(value);
114 else if (ctx.repo && !strcmp(name, "repo.desc")) 116 else if (ctx.repo && !strcmp(name, "repo.desc"))
115 ctx.repo->desc = xstrdup(value); 117 ctx.repo->desc = xstrdup(value);
116 else if (ctx.repo && !strcmp(name, "repo.owner")) 118 else if (ctx.repo && !strcmp(name, "repo.owner"))
117 ctx.repo->owner = xstrdup(value); 119 ctx.repo->owner = xstrdup(value);
118 else if (ctx.repo && !strcmp(name, "repo.defbranch")) 120 else if (ctx.repo && !strcmp(name, "repo.defbranch"))
119 ctx.repo->defbranch = xstrdup(value); 121 ctx.repo->defbranch = xstrdup(value);
120 else if (ctx.repo && !strcmp(name, "repo.snapshots")) 122 else if (ctx.repo && !strcmp(name, "repo.snapshots"))
121 ctx.repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ 123 ctx.repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */
122 else if (ctx.repo && !strcmp(name, "repo.enable-log-filecount")) 124 else if (ctx.repo && !strcmp(name, "repo.enable-log-filecount"))
123 ctx.repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); 125 ctx.repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value);
124 else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount")) 126 else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount"))
125 ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); 127 ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value);
126 else if (ctx.repo && !strcmp(name, "repo.max-stats")) 128 else if (ctx.repo && !strcmp(name, "repo.max-stats"))
127 ctx.repo->max_stats = cgit_find_stats_period(value, NULL); 129 ctx.repo->max_stats = cgit_find_stats_period(value, NULL);
128 else if (ctx.repo && !strcmp(name, "repo.module-link")) 130 else if (ctx.repo && !strcmp(name, "repo.module-link"))
129 ctx.repo->module_link= xstrdup(value); 131 ctx.repo->module_link= xstrdup(value);
130 else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) { 132 else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) {
131 if (*value == '/') 133 if (*value == '/')
132 ctx.repo->readme = xstrdup(value); 134 ctx.repo->readme = xstrdup(value);
133 else 135 else
134 ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value)); 136 ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value));
135 } else if (!strcmp(name, "include")) 137 } else if (!strcmp(name, "include"))
136 parse_configfile(value, config_cb); 138 parse_configfile(value, config_cb);
137} 139}
138 140
139static void querystring_cb(const char *name, const char *value) 141static void querystring_cb(const char *name, const char *value)
140{ 142{
141 if (!strcmp(name,"r")) { 143 if (!strcmp(name,"r")) {
142 ctx.qry.repo = xstrdup(value); 144 ctx.qry.repo = xstrdup(value);
143 ctx.repo = cgit_get_repoinfo(value); 145 ctx.repo = cgit_get_repoinfo(value);
144 } else if (!strcmp(name, "p")) { 146 } else if (!strcmp(name, "p")) {
145 ctx.qry.page = xstrdup(value); 147 ctx.qry.page = xstrdup(value);
146 } else if (!strcmp(name, "url")) { 148 } else if (!strcmp(name, "url")) {
147 ctx.qry.url = xstrdup(value); 149 ctx.qry.url = xstrdup(value);
148 cgit_parse_url(value); 150 cgit_parse_url(value);
149 } else if (!strcmp(name, "qt")) { 151 } else if (!strcmp(name, "qt")) {
diff --git a/cgit.h b/cgit.h
index 8c64efe..acb5e8f 100644
--- a/cgit.h
+++ b/cgit.h
@@ -75,178 +75,179 @@ struct cgit_repolist {
75struct commitinfo { 75struct commitinfo {
76 struct commit *commit; 76 struct commit *commit;
77 char *author; 77 char *author;
78 char *author_email; 78 char *author_email;
79 unsigned long author_date; 79 unsigned long author_date;
80 char *committer; 80 char *committer;
81 char *committer_email; 81 char *committer_email;
82 unsigned long committer_date; 82 unsigned long committer_date;
83 char *subject; 83 char *subject;
84 char *msg; 84 char *msg;
85 char *msg_encoding; 85 char *msg_encoding;
86}; 86};
87 87
88struct taginfo { 88struct taginfo {
89 char *tagger; 89 char *tagger;
90 char *tagger_email; 90 char *tagger_email;
91 unsigned long tagger_date; 91 unsigned long tagger_date;
92 char *msg; 92 char *msg;
93}; 93};
94 94
95struct refinfo { 95struct refinfo {
96 const char *refname; 96 const char *refname;
97 struct object *object; 97 struct object *object;
98 union { 98 union {
99 struct taginfo *tag; 99 struct taginfo *tag;
100 struct commitinfo *commit; 100 struct commitinfo *commit;
101 }; 101 };
102}; 102};
103 103
104struct reflist { 104struct reflist {
105 struct refinfo **refs; 105 struct refinfo **refs;
106 int alloc; 106 int alloc;
107 int count; 107 int count;
108}; 108};
109 109
110struct cgit_query { 110struct cgit_query {
111 int has_symref; 111 int has_symref;
112 int has_sha1; 112 int has_sha1;
113 char *raw; 113 char *raw;
114 char *repo; 114 char *repo;
115 char *page; 115 char *page;
116 char *search; 116 char *search;
117 char *grep; 117 char *grep;
118 char *head; 118 char *head;
119 char *sha1; 119 char *sha1;
120 char *sha2; 120 char *sha2;
121 char *path; 121 char *path;
122 char *name; 122 char *name;
123 char *mimetype; 123 char *mimetype;
124 char *url; 124 char *url;
125 char *period; 125 char *period;
126 int ofs; 126 int ofs;
127 int nohead; 127 int nohead;
128 char *sort; 128 char *sort;
129 int showmsg; 129 int showmsg;
130}; 130};
131 131
132struct cgit_config { 132struct cgit_config {
133 char *agefile; 133 char *agefile;
134 char *cache_root; 134 char *cache_root;
135 char *clone_prefix; 135 char *clone_prefix;
136 char *css; 136 char *css;
137 char *favicon; 137 char *favicon;
138 char *footer; 138 char *footer;
139 char *head_include; 139 char *head_include;
140 char *header; 140 char *header;
141 char *index_header; 141 char *index_header;
142 char *index_info; 142 char *index_info;
143 char *logo; 143 char *logo;
144 char *logo_link; 144 char *logo_link;
145 char *module_link; 145 char *module_link;
146 char *repo_group; 146 char *repo_group;
147 char *robots; 147 char *robots;
148 char *root_title; 148 char *root_title;
149 char *root_desc; 149 char *root_desc;
150 char *root_readme; 150 char *root_readme;
151 char *script_name; 151 char *script_name;
152 char *virtual_root; 152 char *virtual_root;
153 int cache_size; 153 int cache_size;
154 int cache_dynamic_ttl; 154 int cache_dynamic_ttl;
155 int cache_max_create_time; 155 int cache_max_create_time;
156 int cache_repo_ttl; 156 int cache_repo_ttl;
157 int cache_root_ttl; 157 int cache_root_ttl;
158 int cache_static_ttl; 158 int cache_static_ttl;
159 int embedded; 159 int embedded;
160 int enable_index_links; 160 int enable_index_links;
161 int enable_log_filecount; 161 int enable_log_filecount;
162 int enable_log_linecount; 162 int enable_log_linecount;
163 int local_time; 163 int local_time;
164 int max_repo_count; 164 int max_repo_count;
165 int max_commit_count; 165 int max_commit_count;
166 int max_lock_attempts; 166 int max_lock_attempts;
167 int max_msg_len; 167 int max_msg_len;
168 int max_repodesc_len; 168 int max_repodesc_len;
169 int max_stats; 169 int max_stats;
170 int nocache; 170 int nocache;
171 int noplainemail;
171 int noheader; 172 int noheader;
172 int renamelimit; 173 int renamelimit;
173 int snapshots; 174 int snapshots;
174 int summary_branches; 175 int summary_branches;
175 int summary_log; 176 int summary_log;
176 int summary_tags; 177 int summary_tags;
177}; 178};
178 179
179struct cgit_page { 180struct cgit_page {
180 time_t modified; 181 time_t modified;
181 time_t expires; 182 time_t expires;
182 size_t size; 183 size_t size;
183 char *mimetype; 184 char *mimetype;
184 char *charset; 185 char *charset;
185 char *filename; 186 char *filename;
186 char *etag; 187 char *etag;
187 char *title; 188 char *title;
188 int status; 189 int status;
189 char *statusmsg; 190 char *statusmsg;
190}; 191};
191 192
192struct cgit_context { 193struct cgit_context {
193 struct cgit_query qry; 194 struct cgit_query qry;
194 struct cgit_config cfg; 195 struct cgit_config cfg;
195 struct cgit_repo *repo; 196 struct cgit_repo *repo;
196 struct cgit_page page; 197 struct cgit_page page;
197}; 198};
198 199
199struct cgit_snapshot_format { 200struct cgit_snapshot_format {
200 const char *suffix; 201 const char *suffix;
201 const char *mimetype; 202 const char *mimetype;
202 write_archive_fn_t write_func; 203 write_archive_fn_t write_func;
203 int bit; 204 int bit;
204}; 205};
205 206
206extern const char *cgit_version; 207extern const char *cgit_version;
207 208
208extern struct cgit_repolist cgit_repolist; 209extern struct cgit_repolist cgit_repolist;
209extern struct cgit_context ctx; 210extern struct cgit_context ctx;
210extern const struct cgit_snapshot_format cgit_snapshot_formats[]; 211extern const struct cgit_snapshot_format cgit_snapshot_formats[];
211 212
212extern struct cgit_repo *cgit_add_repo(const char *url); 213extern struct cgit_repo *cgit_add_repo(const char *url);
213extern struct cgit_repo *cgit_get_repoinfo(const char *url); 214extern struct cgit_repo *cgit_get_repoinfo(const char *url);
214extern void cgit_repo_config_cb(const char *name, const char *value); 215extern void cgit_repo_config_cb(const char *name, const char *value);
215 216
216extern int chk_zero(int result, char *msg); 217extern int chk_zero(int result, char *msg);
217extern int chk_positive(int result, char *msg); 218extern int chk_positive(int result, char *msg);
218extern int chk_non_negative(int result, char *msg); 219extern int chk_non_negative(int result, char *msg);
219 220
220extern char *trim_end(const char *str, char c); 221extern char *trim_end(const char *str, char c);
221extern char *strlpart(char *txt, int maxlen); 222extern char *strlpart(char *txt, int maxlen);
222extern char *strrpart(char *txt, int maxlen); 223extern char *strrpart(char *txt, int maxlen);
223 224
224extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); 225extern void cgit_add_ref(struct reflist *list, struct refinfo *ref);
225extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, 226extern int cgit_refs_cb(const char *refname, const unsigned char *sha1,
226 int flags, void *cb_data); 227 int flags, void *cb_data);
227 228
228extern void *cgit_free_commitinfo(struct commitinfo *info); 229extern void *cgit_free_commitinfo(struct commitinfo *info);
229 230
230extern int cgit_diff_files(const unsigned char *old_sha1, 231extern int cgit_diff_files(const unsigned char *old_sha1,
231 const unsigned char *new_sha1, 232 const unsigned char *new_sha1,
232 unsigned long *old_size, unsigned long *new_size, 233 unsigned long *old_size, unsigned long *new_size,
233 int *binary, linediff_fn fn); 234 int *binary, linediff_fn fn);
234 235
235extern void cgit_diff_tree(const unsigned char *old_sha1, 236extern void cgit_diff_tree(const unsigned char *old_sha1,
236 const unsigned char *new_sha1, 237 const unsigned char *new_sha1,
237 filepair_fn fn, const char *prefix); 238 filepair_fn fn, const char *prefix);
238 239
239extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); 240extern void cgit_diff_commit(struct commit *commit, filepair_fn fn);
240 241
241extern char *fmt(const char *format,...); 242extern char *fmt(const char *format,...);
242 243
243extern struct commitinfo *cgit_parse_commit(struct commit *commit); 244extern struct commitinfo *cgit_parse_commit(struct commit *commit);
244extern struct taginfo *cgit_parse_tag(struct tag *tag); 245extern struct taginfo *cgit_parse_tag(struct tag *tag);
245extern void cgit_parse_url(const char *url); 246extern void cgit_parse_url(const char *url);
246 247
247extern const char *cgit_repobasename(const char *reponame); 248extern const char *cgit_repobasename(const char *reponame);
248 249
249extern int cgit_parse_snapshots_mask(const char *str); 250extern int cgit_parse_snapshots_mask(const char *str);
250 251
251 252
252#endif /* CGIT_H */ 253#endif /* CGIT_H */
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index a207fe0..7754923 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -65,192 +65,196 @@ embedded::
65 also: "noheader". 65 also: "noheader".
66 66
67enable-index-links:: 67enable-index-links::
68 Flag which, when set to "1", will make cgit generate extra links for 68 Flag which, when set to "1", will make cgit generate extra links for
69 each repo in the repository index (specifically, to the "summary", 69 each repo in the repository index (specifically, to the "summary",
70 "commit" and "tree" pages). Default value: "0". 70 "commit" and "tree" pages). Default value: "0".
71 71
72enable-log-filecount:: 72enable-log-filecount::
73 Flag which, when set to "1", will make cgit print the number of 73 Flag which, when set to "1", will make cgit print the number of
74 modified files for each commit on the repository log page. Default 74 modified files for each commit on the repository log page. Default
75 value: "0". 75 value: "0".
76 76
77enable-log-linecount:: 77enable-log-linecount::
78 Flag which, when set to "1", will make cgit print the number of added 78 Flag which, when set to "1", will make cgit print the number of added
79 and removed lines for each commit on the repository log page. Default 79 and removed lines for each commit on the repository log page. Default
80 value: "0". 80 value: "0".
81 81
82favicon:: 82favicon::
83 Url used as link to a shortcut icon for cgit. If specified, it is 83 Url used as link to a shortcut icon for cgit. If specified, it is
84 suggested to use the value "/favicon.ico" since certain browsers will 84 suggested to use the value "/favicon.ico" since certain browsers will
85 ignore other values. Default value: none. 85 ignore other values. Default value: none.
86 86
87footer:: 87footer::
88 The content of the file specified with this option will be included 88 The content of the file specified with this option will be included
89 verbatim at the bottom of all pages (i.e. it replaces the standard 89 verbatim at the bottom of all pages (i.e. it replaces the standard
90 "generated by..." message. Default value: none. 90 "generated by..." message. Default value: none.
91 91
92head-include:: 92head-include::
93 The content of the file specified with this option will be included 93 The content of the file specified with this option will be included
94 verbatim in the html HEAD section on all pages. Default value: none. 94 verbatim in the html HEAD section on all pages. Default value: none.
95 95
96header:: 96header::
97 The content of the file specified with this option will be included 97 The content of the file specified with this option will be included
98 verbatim at the top of all pages. Default value: none. 98 verbatim at the top of all pages. Default value: none.
99 99
100include:: 100include::
101 Name of a configfile to include before the rest of the current config- 101 Name of a configfile to include before the rest of the current config-
102 file is parsed. Default value: none. 102 file is parsed. Default value: none.
103 103
104index-header:: 104index-header::
105 The content of the file specified with this option will be included 105 The content of the file specified with this option will be included
106 verbatim above the repository index. This setting is deprecated, and 106 verbatim above the repository index. This setting is deprecated, and
107 will not be supported by cgit-1.0 (use root-readme instead). Default 107 will not be supported by cgit-1.0 (use root-readme instead). Default
108 value: none. 108 value: none.
109 109
110index-info:: 110index-info::
111 The content of the file specified with this option will be included 111 The content of the file specified with this option will be included
112 verbatim below the heading on the repository index page. This setting 112 verbatim below the heading on the repository index page. This setting
113 is deprecated, and will not be supported by cgit-1.0 (use root-desc 113 is deprecated, and will not be supported by cgit-1.0 (use root-desc
114 instead). Default value: none. 114 instead). Default value: none.
115 115
116local-time:: 116local-time::
117 Flag which, if set to "1", makes cgit print commit and tag times in the 117 Flag which, if set to "1", makes cgit print commit and tag times in the
118 servers timezone. Default value: "0". 118 servers timezone. Default value: "0".
119 119
120logo:: 120logo::
121 Url which specifies the source of an image which will be used as a logo 121 Url which specifies the source of an image which will be used as a logo
122 on all cgit pages. 122 on all cgit pages.
123 123
124logo-link:: 124logo-link::
125 Url loaded when clicking on the cgit logo image. If unspecified the 125 Url loaded when clicking on the cgit logo image. If unspecified the
126 calculated url of the repository index page will be used. Default 126 calculated url of the repository index page will be used. Default
127 value: none. 127 value: none.
128 128
129max-commit-count:: 129max-commit-count::
130 Specifies the number of entries to list per page in "log" view. Default 130 Specifies the number of entries to list per page in "log" view. Default
131 value: "50". 131 value: "50".
132 132
133max-message-length:: 133max-message-length::
134 Specifies the maximum number of commit message characters to display in 134 Specifies the maximum number of commit message characters to display in
135 "log" view. Default value: "80". 135 "log" view. Default value: "80".
136 136
137max-repo-count:: 137max-repo-count::
138 Specifies the number of entries to list per page on therepository 138 Specifies the number of entries to list per page on therepository
139 index page. Default value: "50". 139 index page. Default value: "50".
140 140
141max-repodesc-length:: 141max-repodesc-length::
142 Specifies the maximum number of repo description characters to display 142 Specifies the maximum number of repo description characters to display
143 on the repository index page. Default value: "80". 143 on the repository index page. Default value: "80".
144 144
145max-stats:: 145max-stats::
146 Set the default maximum statistics period. Valid values are "week", 146 Set the default maximum statistics period. Valid values are "week",
147 "month", "quarter" and "year". If unspecified, statistics are 147 "month", "quarter" and "year". If unspecified, statistics are
148 disabled. Default value: none. See also: "repo.max-stats". 148 disabled. Default value: none. See also: "repo.max-stats".
149 149
150module-link:: 150module-link::
151 Text which will be used as the formatstring for a hyperlink when a 151 Text which will be used as the formatstring for a hyperlink when a
152 submodule is printed in a directory listing. The arguments for the 152 submodule is printed in a directory listing. The arguments for the
153 formatstring are the path and SHA1 of the submodule commit. Default 153 formatstring are the path and SHA1 of the submodule commit. Default
154 value: "./?repo=%s&page=commit&id=%s" 154 value: "./?repo=%s&page=commit&id=%s"
155 155
156nocache:: 156nocache::
157 If set to the value "1" caching will be disabled. This settings is 157 If set to the value "1" caching will be disabled. This settings is
158 deprecated, and will not be honored starting with cgit-1.0. Default 158 deprecated, and will not be honored starting with cgit-1.0. Default
159 value: "0". 159 value: "0".
160 160
161noplainemail::
162 If set to "1" showing full author email adresses will be disabled.
163 Default value: "0".
164
161noheader:: 165noheader::
162 Flag which, when set to "1", will make cgit omit the standard header 166 Flag which, when set to "1", will make cgit omit the standard header
163 on all pages. Default value: none. See also: "embedded". 167 on all pages. Default value: none. See also: "embedded".
164 168
165renamelimit:: 169renamelimit::
166 Maximum number of files to consider when detecting renames. The value 170 Maximum number of files to consider when detecting renames. The value
167 "-1" uses the compiletime value in git (for further info, look at 171 "-1" uses the compiletime value in git (for further info, look at
168 `man git-diff`). Default value: "-1". 172 `man git-diff`). Default value: "-1".
169 173
170repo.group:: 174repo.group::
171 A value for the current repository group, which all repositories 175 A value for the current repository group, which all repositories
172 specified after this setting will inherit. Default value: none. 176 specified after this setting will inherit. Default value: none.
173 177
174robots:: 178robots::
175 Text used as content for the "robots" meta-tag. Default value: 179 Text used as content for the "robots" meta-tag. Default value:
176 "index, nofollow". 180 "index, nofollow".
177 181
178root-desc:: 182root-desc::
179 Text printed below the heading on the repository index page. Default 183 Text printed below the heading on the repository index page. Default
180 value: "a fast webinterface for the git dscm". 184 value: "a fast webinterface for the git dscm".
181 185
182root-readme:: 186root-readme::
183 The content of the file specified with this option will be included 187 The content of the file specified with this option will be included
184 verbatim below the "about" link on the repository index page. Default 188 verbatim below the "about" link on the repository index page. Default
185 value: none. 189 value: none.
186 190
187root-title:: 191root-title::
188 Text printed as heading on the repository index page. Default value: 192 Text printed as heading on the repository index page. Default value:
189 "Git Repository Browser". 193 "Git Repository Browser".
190 194
191snapshots:: 195snapshots::
192 Text which specifies the default (and allowed) set of snapshot formats 196 Text which specifies the default (and allowed) set of snapshot formats
193 supported by cgit. The value is a space-separated list of zero or more 197 supported by cgit. The value is a space-separated list of zero or more
194 of the following values: 198 of the following values:
195 "tar" uncompressed tar-file 199 "tar" uncompressed tar-file
196 "tar.gz"gzip-compressed tar-file 200 "tar.gz"gzip-compressed tar-file
197 "tar.bz2"bzip-compressed tar-file 201 "tar.bz2"bzip-compressed tar-file
198 "zip" zip-file 202 "zip" zip-file
199 Default value: none. 203 Default value: none.
200 204
201summary-branches:: 205summary-branches::
202 Specifies the number of branches to display in the repository "summary" 206 Specifies the number of branches to display in the repository "summary"
203 view. Default value: "10". 207 view. Default value: "10".
204 208
205summary-log:: 209summary-log::
206 Specifies the number of log entries to display in the repository 210 Specifies the number of log entries to display in the repository
207 "summary" view. Default value: "10". 211 "summary" view. Default value: "10".
208 212
209summary-tags:: 213summary-tags::
210 Specifies the number of tags to display in the repository "summary" 214 Specifies the number of tags to display in the repository "summary"
211 view. Default value: "10". 215 view. Default value: "10".
212 216
213virtual-root:: 217virtual-root::
214 Url which, if specified, will be used as root for all cgit links. It 218 Url which, if specified, will be used as root for all cgit links. It
215 will also cause cgit to generate 'virtual urls', i.e. urls like 219 will also cause cgit to generate 'virtual urls', i.e. urls like
216 '/cgit/tree/README' as opposed to '?r=cgit&p=tree&path=README'. Default 220 '/cgit/tree/README' as opposed to '?r=cgit&p=tree&path=README'. Default
217 value: none. 221 value: none.
218 NOTE: cgit has recently learned how to use PATH_INFO to achieve the 222 NOTE: cgit has recently learned how to use PATH_INFO to achieve the
219 same kind of virtual urls, so this option will probably be deprecated. 223 same kind of virtual urls, so this option will probably be deprecated.
220 224
221REPOSITORY SETTINGS 225REPOSITORY SETTINGS
222------------------- 226-------------------
223repo.clone-url:: 227repo.clone-url::
224 A list of space-separated urls which can be used to clone this repo. 228 A list of space-separated urls which can be used to clone this repo.
225 Default value: none. 229 Default value: none.
226 230
227repo.defbranch:: 231repo.defbranch::
228 The name of the default branch for this repository. If no such branch 232 The name of the default branch for this repository. If no such branch
229 exists in the repository, the first branch name (when sorted) is used 233 exists in the repository, the first branch name (when sorted) is used
230 as default instead. Default value: "master". 234 as default instead. Default value: "master".
231 235
232repo.desc:: 236repo.desc::
233 The value to show as repository description. Default value: none. 237 The value to show as repository description. Default value: none.
234 238
235repo.enable-log-filecount:: 239repo.enable-log-filecount::
236 A flag which can be used to disable the global setting 240 A flag which can be used to disable the global setting
237 `enable-log-filecount'. Default value: none. 241 `enable-log-filecount'. Default value: none.
238 242
239repo.enable-log-linecount:: 243repo.enable-log-linecount::
240 A flag which can be used to disable the global setting 244 A flag which can be used to disable the global setting
241 `enable-log-linecount'. Default value: none. 245 `enable-log-linecount'. Default value: none.
242 246
243repo.max-stats:: 247repo.max-stats::
244 Override the default maximum statistics period. Valid values are equal 248 Override the default maximum statistics period. Valid values are equal
245 to the values specified for the global "max-stats" setting. Default 249 to the values specified for the global "max-stats" setting. Default
246 value: none. 250 value: none.
247 251
248repo.name:: 252repo.name::
249 The value to show as repository name. Default value: <repo.url>. 253 The value to show as repository name. Default value: <repo.url>.
250 254
251repo.owner:: 255repo.owner::
252 A value used to identify the owner of the repository. Default value: 256 A value used to identify the owner of the repository. Default value:
253 none. 257 none.
254 258
255repo.path:: 259repo.path::
256 An absolute path to the repository directory. For non-bare repositories 260 An absolute path to the repository directory. For non-bare repositories
diff --git a/ui-atom.c b/ui-atom.c
index e5c31d9..808b2d0 100644
--- a/ui-atom.c
+++ b/ui-atom.c
@@ -1,131 +1,131 @@
1/* ui-atom.c: functions for atom feeds 1/* ui-atom.c: functions for atom feeds
2 * 2 *
3 * Copyright (C) 2008 Lars Hjemli 3 * Copyright (C) 2008 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 12
13void add_entry(struct commit *commit, char *host) 13void add_entry(struct commit *commit, char *host)
14{ 14{
15 char delim = '&'; 15 char delim = '&';
16 char *hex; 16 char *hex;
17 char *mail, *t, *t2; 17 char *mail, *t, *t2;
18 struct commitinfo *info; 18 struct commitinfo *info;
19 19
20 info = cgit_parse_commit(commit); 20 info = cgit_parse_commit(commit);
21 hex = sha1_to_hex(commit->object.sha1); 21 hex = sha1_to_hex(commit->object.sha1);
22 html("<entry>\n"); 22 html("<entry>\n");
23 html("<title>"); 23 html("<title>");
24 html_txt(info->subject); 24 html_txt(info->subject);
25 html("</title>\n"); 25 html("</title>\n");
26 html("<updated>"); 26 html("<updated>");
27 cgit_print_date(info->author_date, FMT_ATOMDATE, ctx.cfg.local_time); 27 cgit_print_date(info->author_date, FMT_ATOMDATE, ctx.cfg.local_time);
28 html("</updated>\n"); 28 html("</updated>\n");
29 html("<author>\n"); 29 html("<author>\n");
30 if (info->author) { 30 if (info->author) {
31 html("<name>"); 31 html("<name>");
32 html_txt(info->author); 32 html_txt(info->author);
33 html("</name>\n"); 33 html("</name>\n");
34 } 34 }
35 if (info->author_email) { 35 if (info->author_email && !ctx.cfg.noplainemail) {
36 mail = xstrdup(info->author_email); 36 mail = xstrdup(info->author_email);
37 t = strchr(mail, '<'); 37 t = strchr(mail, '<');
38 if (t) 38 if (t)
39 t++; 39 t++;
40 else 40 else
41 t = mail; 41 t = mail;
42 t2 = strchr(t, '>'); 42 t2 = strchr(t, '>');
43 if (t2) 43 if (t2)
44 *t2 = '\0'; 44 *t2 = '\0';
45 html("<email>"); 45 html("<email>");
46 html_txt(t); 46 html_txt(t);
47 html("</email>\n"); 47 html("</email>\n");
48 free(mail); 48 free(mail);
49 } 49 }
50 html("</author>\n"); 50 html("</author>\n");
51 html("<published>"); 51 html("<published>");
52 cgit_print_date(info->author_date, FMT_ATOMDATE, ctx.cfg.local_time); 52 cgit_print_date(info->author_date, FMT_ATOMDATE, ctx.cfg.local_time);
53 html("</published>\n"); 53 html("</published>\n");
54 if (host) { 54 if (host) {
55 html("<link rel='alternate' type='text/html' href='"); 55 html("<link rel='alternate' type='text/html' href='");
56 html(cgit_httpscheme()); 56 html(cgit_httpscheme());
57 html_attr(host); 57 html_attr(host);
58 html_attr(cgit_pageurl(ctx.repo->url, "commit", NULL)); 58 html_attr(cgit_pageurl(ctx.repo->url, "commit", NULL));
59 if (ctx.cfg.virtual_root) 59 if (ctx.cfg.virtual_root)
60 delim = '?'; 60 delim = '?';
61 htmlf("%cid=%s", delim, hex); 61 htmlf("%cid=%s", delim, hex);
62 html("'/>\n"); 62 html("'/>\n");
63 } 63 }
64 htmlf("<id>%s</id>\n", hex); 64 htmlf("<id>%s</id>\n", hex);
65 html("<content type='text'>\n"); 65 html("<content type='text'>\n");
66 html_txt(info->msg); 66 html_txt(info->msg);
67 html("</content>\n"); 67 html("</content>\n");
68 html("<content type='xhtml'>\n"); 68 html("<content type='xhtml'>\n");
69 html("<div xmlns='http://www.w3.org/1999/xhtml'>\n"); 69 html("<div xmlns='http://www.w3.org/1999/xhtml'>\n");
70 html("<pre>\n"); 70 html("<pre>\n");
71 html_txt(info->msg); 71 html_txt(info->msg);
72 html("</pre>\n"); 72 html("</pre>\n");
73 html("</div>\n"); 73 html("</div>\n");
74 html("</content>\n"); 74 html("</content>\n");
75 html("</entry>\n"); 75 html("</entry>\n");
76 cgit_free_commitinfo(info); 76 cgit_free_commitinfo(info);
77} 77}
78 78
79 79
80void cgit_print_atom(char *tip, char *path, int max_count) 80void cgit_print_atom(char *tip, char *path, int max_count)
81{ 81{
82 char *host; 82 char *host;
83 const char *argv[] = {NULL, tip, NULL, NULL, NULL}; 83 const char *argv[] = {NULL, tip, NULL, NULL, NULL};
84 struct commit *commit; 84 struct commit *commit;
85 struct rev_info rev; 85 struct rev_info rev;
86 int argc = 2; 86 int argc = 2;
87 87
88 if (!tip) 88 if (!tip)
89 argv[1] = ctx.qry.head; 89 argv[1] = ctx.qry.head;
90 90
91 if (path) { 91 if (path) {
92 argv[argc++] = "--"; 92 argv[argc++] = "--";
93 argv[argc++] = path; 93 argv[argc++] = path;
94 } 94 }
95 95
96 init_revisions(&rev, NULL); 96 init_revisions(&rev, NULL);
97 rev.abbrev = DEFAULT_ABBREV; 97 rev.abbrev = DEFAULT_ABBREV;
98 rev.commit_format = CMIT_FMT_DEFAULT; 98 rev.commit_format = CMIT_FMT_DEFAULT;
99 rev.verbose_header = 1; 99 rev.verbose_header = 1;
100 rev.show_root_diff = 0; 100 rev.show_root_diff = 0;
101 rev.max_count = max_count; 101 rev.max_count = max_count;
102 setup_revisions(argc, argv, &rev, NULL); 102 setup_revisions(argc, argv, &rev, NULL);
103 prepare_revision_walk(&rev); 103 prepare_revision_walk(&rev);
104 104
105 host = cgit_hosturl(); 105 host = cgit_hosturl();
106 ctx.page.mimetype = "text/xml"; 106 ctx.page.mimetype = "text/xml";
107 ctx.page.charset = "utf-8"; 107 ctx.page.charset = "utf-8";
108 cgit_print_http_headers(&ctx); 108 cgit_print_http_headers(&ctx);
109 html("<feed xmlns='http://www.w3.org/2005/Atom'>\n"); 109 html("<feed xmlns='http://www.w3.org/2005/Atom'>\n");
110 html("<title>"); 110 html("<title>");
111 html_txt(ctx.repo->name); 111 html_txt(ctx.repo->name);
112 html("</title>\n"); 112 html("</title>\n");
113 html("<subtitle>"); 113 html("<subtitle>");
114 html_txt(ctx.repo->desc); 114 html_txt(ctx.repo->desc);
115 html("</subtitle>\n"); 115 html("</subtitle>\n");
116 if (host) { 116 if (host) {
117 html("<link rel='alternate' type='text/html' href='"); 117 html("<link rel='alternate' type='text/html' href='");
118 html(cgit_httpscheme()); 118 html(cgit_httpscheme());
119 html_attr(host); 119 html_attr(host);
120 html_attr(cgit_repourl(ctx.repo->url)); 120 html_attr(cgit_repourl(ctx.repo->url));
121 html("'/>\n"); 121 html("'/>\n");
122 } 122 }
123 while ((commit = get_revision(&rev)) != NULL) { 123 while ((commit = get_revision(&rev)) != NULL) {
124 add_entry(commit, host); 124 add_entry(commit, host);
125 free(commit->buffer); 125 free(commit->buffer);
126 commit->buffer = NULL; 126 commit->buffer = NULL;
127 free_commit_list(commit->parents); 127 free_commit_list(commit->parents);
128 commit->parents = NULL; 128 commit->parents = NULL;
129 } 129 }
130 html("</feed>\n"); 130 html("</feed>\n");
131} 131}
diff --git a/ui-commit.c b/ui-commit.c
index 41ce70e..9fdb8ee 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -1,106 +1,110 @@
1/* ui-commit.c: generate commit view 1/* ui-commit.c: generate commit view
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-diff.h" 12#include "ui-diff.h"
13#include "ui-log.h" 13#include "ui-log.h"
14 14
15void cgit_print_commit(char *hex) 15void cgit_print_commit(char *hex)
16{ 16{
17 struct commit *commit, *parent; 17 struct commit *commit, *parent;
18 struct commitinfo *info; 18 struct commitinfo *info;
19 struct commit_list *p; 19 struct commit_list *p;
20 unsigned char sha1[20]; 20 unsigned char sha1[20];
21 char *tmp; 21 char *tmp;
22 int parents = 0; 22 int parents = 0;
23 23
24 if (!hex) 24 if (!hex)
25 hex = ctx.qry.head; 25 hex = ctx.qry.head;
26 26
27 if (get_sha1(hex, sha1)) { 27 if (get_sha1(hex, sha1)) {
28 cgit_print_error(fmt("Bad object id: %s", hex)); 28 cgit_print_error(fmt("Bad object id: %s", hex));
29 return; 29 return;
30 } 30 }
31 commit = lookup_commit_reference(sha1); 31 commit = lookup_commit_reference(sha1);
32 if (!commit) { 32 if (!commit) {
33 cgit_print_error(fmt("Bad commit reference: %s", hex)); 33 cgit_print_error(fmt("Bad commit reference: %s", hex));
34 return; 34 return;
35 } 35 }
36 info = cgit_parse_commit(commit); 36 info = cgit_parse_commit(commit);
37 37
38 load_ref_decorations(); 38 load_ref_decorations();
39 39
40 html("<table summary='commit info' class='commit-info'>\n"); 40 html("<table summary='commit info' class='commit-info'>\n");
41 html("<tr><th>author</th><td>"); 41 html("<tr><th>author</th><td>");
42 html_txt(info->author); 42 html_txt(info->author);
43 html(" "); 43 if (!ctx.cfg.noplainemail) {
44 html_txt(info->author_email); 44 html(" ");
45 html_txt(info->author_email);
46 }
45 html("</td><td class='right'>"); 47 html("</td><td class='right'>");
46 cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time); 48 cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time);
47 html("</td></tr>\n"); 49 html("</td></tr>\n");
48 html("<tr><th>committer</th><td>"); 50 html("<tr><th>committer</th><td>");
49 html_txt(info->committer); 51 html_txt(info->committer);
50 html(" "); 52 if (!ctx.cfg.noplainemail) {
51 html_txt(info->committer_email); 53 html(" ");
54 html_txt(info->committer_email);
55 }
52 html("</td><td class='right'>"); 56 html("</td><td class='right'>");
53 cgit_print_date(info->committer_date, FMT_LONGDATE, ctx.cfg.local_time); 57 cgit_print_date(info->committer_date, FMT_LONGDATE, ctx.cfg.local_time);
54 html("</td></tr>\n"); 58 html("</td></tr>\n");
55 html("<tr><th>commit</th><td colspan='2' class='sha1'>"); 59 html("<tr><th>commit</th><td colspan='2' class='sha1'>");
56 tmp = sha1_to_hex(commit->object.sha1); 60 tmp = sha1_to_hex(commit->object.sha1);
57 cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp); 61 cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp);
58 html(" ("); 62 html(" (");
59 cgit_patch_link("patch", NULL, NULL, NULL, tmp); 63 cgit_patch_link("patch", NULL, NULL, NULL, tmp);
60 html(")</td></tr>\n"); 64 html(")</td></tr>\n");
61 html("<tr><th>tree</th><td colspan='2' class='sha1'>"); 65 html("<tr><th>tree</th><td colspan='2' class='sha1'>");
62 tmp = xstrdup(hex); 66 tmp = xstrdup(hex);
63 cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL, 67 cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL,
64 ctx.qry.head, tmp, NULL); 68 ctx.qry.head, tmp, NULL);
65 html("</td></tr>\n"); 69 html("</td></tr>\n");
66 for (p = commit->parents; p ; p = p->next) { 70 for (p = commit->parents; p ; p = p->next) {
67 parent = lookup_commit_reference(p->item->object.sha1); 71 parent = lookup_commit_reference(p->item->object.sha1);
68 if (!parent) { 72 if (!parent) {
69 html("<tr><td colspan='3'>"); 73 html("<tr><td colspan='3'>");
70 cgit_print_error("Error reading parent commit"); 74 cgit_print_error("Error reading parent commit");
71 html("</td></tr>"); 75 html("</td></tr>");
72 continue; 76 continue;
73 } 77 }
74 html("<tr><th>parent</th>" 78 html("<tr><th>parent</th>"
75 "<td colspan='2' class='sha1'>"); 79 "<td colspan='2' class='sha1'>");
76 cgit_commit_link(sha1_to_hex(p->item->object.sha1), NULL, NULL, 80 cgit_commit_link(sha1_to_hex(p->item->object.sha1), NULL, NULL,
77 ctx.qry.head, sha1_to_hex(p->item->object.sha1)); 81 ctx.qry.head, sha1_to_hex(p->item->object.sha1));
78 html(" ("); 82 html(" (");
79 cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex, 83 cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex,
80 sha1_to_hex(p->item->object.sha1), NULL); 84 sha1_to_hex(p->item->object.sha1), NULL);
81 html(")</td></tr>"); 85 html(")</td></tr>");
82 parents++; 86 parents++;
83 } 87 }
84 if (ctx.repo->snapshots) { 88 if (ctx.repo->snapshots) {
85 html("<tr><th>download</th><td colspan='2' class='sha1'>"); 89 html("<tr><th>download</th><td colspan='2' class='sha1'>");
86 cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head, 90 cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head,
87 hex, ctx.repo->snapshots); 91 hex, ctx.repo->snapshots);
88 html("</td></tr>"); 92 html("</td></tr>");
89 } 93 }
90 html("</table>\n"); 94 html("</table>\n");
91 html("<div class='commit-subject'>"); 95 html("<div class='commit-subject'>");
92 html_txt(info->subject); 96 html_txt(info->subject);
93 show_commit_decorations(commit); 97 show_commit_decorations(commit);
94 html("</div>"); 98 html("</div>");
95 html("<div class='commit-msg'>"); 99 html("<div class='commit-msg'>");
96 html_txt(info->msg); 100 html_txt(info->msg);
97 html("</div>"); 101 html("</div>");
98 if (parents < 3) { 102 if (parents < 3) {
99 if (parents) 103 if (parents)
100 tmp = sha1_to_hex(commit->parents->item->object.sha1); 104 tmp = sha1_to_hex(commit->parents->item->object.sha1);
101 else 105 else
102 tmp = NULL; 106 tmp = NULL;
103 cgit_print_diff(ctx.qry.sha1, tmp, NULL); 107 cgit_print_diff(ctx.qry.sha1, tmp, NULL);
104 } 108 }
105 cgit_free_commitinfo(info); 109 cgit_free_commitinfo(info);
106} 110}
diff --git a/ui-patch.c b/ui-patch.c
index 5d665d3..2a8f7a5 100644
--- a/ui-patch.c
+++ b/ui-patch.c
@@ -15,111 +15,115 @@ static void print_line(char *line, int len)
15 char c = line[len-1]; 15 char c = line[len-1];
16 16
17 line[len-1] = '\0'; 17 line[len-1] = '\0';
18 htmlf("%s\n", line); 18 htmlf("%s\n", line);
19 line[len-1] = c; 19 line[len-1] = c;
20} 20}
21 21
22static void header(unsigned char *sha1, char *path1, int mode1, 22static void header(unsigned char *sha1, char *path1, int mode1,
23 unsigned char *sha2, char *path2, int mode2) 23 unsigned char *sha2, char *path2, int mode2)
24{ 24{
25 char *abbrev1, *abbrev2; 25 char *abbrev1, *abbrev2;
26 int subproject; 26 int subproject;
27 27
28 subproject = (S_ISGITLINK(mode1) || S_ISGITLINK(mode2)); 28 subproject = (S_ISGITLINK(mode1) || S_ISGITLINK(mode2));
29 htmlf("diff --git a/%s b/%s\n", path1, path2); 29 htmlf("diff --git a/%s b/%s\n", path1, path2);
30 30
31 if (is_null_sha1(sha1)) 31 if (is_null_sha1(sha1))
32 path1 = "dev/null"; 32 path1 = "dev/null";
33 if (is_null_sha1(sha2)) 33 if (is_null_sha1(sha2))
34 path2 = "dev/null"; 34 path2 = "dev/null";
35 35
36 if (mode1 == 0) 36 if (mode1 == 0)
37 htmlf("new file mode %.6o\n", mode2); 37 htmlf("new file mode %.6o\n", mode2);
38 38
39 if (mode2 == 0) 39 if (mode2 == 0)
40 htmlf("deleted file mode %.6o\n", mode1); 40 htmlf("deleted file mode %.6o\n", mode1);
41 41
42 if (!subproject) { 42 if (!subproject) {
43 abbrev1 = xstrdup(find_unique_abbrev(sha1, DEFAULT_ABBREV)); 43 abbrev1 = xstrdup(find_unique_abbrev(sha1, DEFAULT_ABBREV));
44 abbrev2 = xstrdup(find_unique_abbrev(sha2, DEFAULT_ABBREV)); 44 abbrev2 = xstrdup(find_unique_abbrev(sha2, DEFAULT_ABBREV));
45 htmlf("index %s..%s", abbrev1, abbrev2); 45 htmlf("index %s..%s", abbrev1, abbrev2);
46 free(abbrev1); 46 free(abbrev1);
47 free(abbrev2); 47 free(abbrev2);
48 if (mode1 != 0 && mode2 != 0) { 48 if (mode1 != 0 && mode2 != 0) {
49 htmlf(" %.6o", mode1); 49 htmlf(" %.6o", mode1);
50 if (mode2 != mode1) 50 if (mode2 != mode1)
51 htmlf("..%.6o", mode2); 51 htmlf("..%.6o", mode2);
52 } 52 }
53 htmlf("\n--- a/%s\n", path1); 53 htmlf("\n--- a/%s\n", path1);
54 htmlf("+++ b/%s\n", path2); 54 htmlf("+++ b/%s\n", path2);
55 } 55 }
56} 56}
57 57
58static void filepair_cb(struct diff_filepair *pair) 58static void filepair_cb(struct diff_filepair *pair)
59{ 59{
60 unsigned long old_size = 0; 60 unsigned long old_size = 0;
61 unsigned long new_size = 0; 61 unsigned long new_size = 0;
62 int binary = 0; 62 int binary = 0;
63 63
64 header(pair->one->sha1, pair->one->path, pair->one->mode, 64 header(pair->one->sha1, pair->one->path, pair->one->mode,
65 pair->two->sha1, pair->two->path, pair->two->mode); 65 pair->two->sha1, pair->two->path, pair->two->mode);
66 if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) { 66 if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) {
67 if (S_ISGITLINK(pair->one->mode)) 67 if (S_ISGITLINK(pair->one->mode))
68 print_line(fmt("-Subproject %s", sha1_to_hex(pair->one->sha1)), 52); 68 print_line(fmt("-Subproject %s", sha1_to_hex(pair->one->sha1)), 52);
69 if (S_ISGITLINK(pair->two->mode)) 69 if (S_ISGITLINK(pair->two->mode))
70 print_line(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52); 70 print_line(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52);
71 return; 71 return;
72 } 72 }
73 if (cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, 73 if (cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size,
74 &new_size, &binary, print_line)) 74 &new_size, &binary, print_line))
75 html("Error running diff"); 75 html("Error running diff");
76 if (binary) 76 if (binary)
77 html("Binary files differ\n"); 77 html("Binary files differ\n");
78} 78}
79 79
80void cgit_print_patch(char *hex) 80void cgit_print_patch(char *hex)
81{ 81{
82 struct commit *commit; 82 struct commit *commit;
83 struct commitinfo *info; 83 struct commitinfo *info;
84 unsigned char sha1[20], old_sha1[20]; 84 unsigned char sha1[20], old_sha1[20];
85 char *patchname; 85 char *patchname;
86 86
87 if (!hex) 87 if (!hex)
88 hex = ctx.qry.head; 88 hex = ctx.qry.head;
89 89
90 if (get_sha1(hex, sha1)) { 90 if (get_sha1(hex, sha1)) {
91 cgit_print_error(fmt("Bad object id: %s", hex)); 91 cgit_print_error(fmt("Bad object id: %s", hex));
92 return; 92 return;
93 } 93 }
94 commit = lookup_commit_reference(sha1); 94 commit = lookup_commit_reference(sha1);
95 if (!commit) { 95 if (!commit) {
96 cgit_print_error(fmt("Bad commit reference: %s", hex)); 96 cgit_print_error(fmt("Bad commit reference: %s", hex));
97 return; 97 return;
98 } 98 }
99 info = cgit_parse_commit(commit); 99 info = cgit_parse_commit(commit);
100 100
101 if (commit->parents && commit->parents->item) 101 if (commit->parents && commit->parents->item)
102 hashcpy(old_sha1, commit->parents->item->object.sha1); 102 hashcpy(old_sha1, commit->parents->item->object.sha1);
103 else 103 else
104 hashclr(old_sha1); 104 hashclr(old_sha1);
105 105
106 patchname = fmt("%s.patch", sha1_to_hex(sha1)); 106 patchname = fmt("%s.patch", sha1_to_hex(sha1));
107 ctx.page.mimetype = "text/plain"; 107 ctx.page.mimetype = "text/plain";
108 ctx.page.filename = patchname; 108 ctx.page.filename = patchname;
109 cgit_print_http_headers(&ctx); 109 cgit_print_http_headers(&ctx);
110 htmlf("From %s Mon Sep 17 00:00:00 2001\n", sha1_to_hex(sha1)); 110 htmlf("From %s Mon Sep 17 00:00:00 2001\n", sha1_to_hex(sha1));
111 htmlf("From: %s %s\n", info->author, info->author_email); 111 htmlf("From: %s", info->author);
112 if (!ctx.cfg.noplainemail) {
113 htmlf(" %s", info->author_email);
114 }
115 html("\n");
112 html("Date: "); 116 html("Date: ");
113 cgit_print_date(info->author_date, "%a, %d %b %Y %H:%M:%S %z%n", ctx.cfg.local_time); 117 cgit_print_date(info->author_date, "%a, %d %b %Y %H:%M:%S %z%n", ctx.cfg.local_time);
114 htmlf("Subject: %s\n\n", info->subject); 118 htmlf("Subject: %s\n\n", info->subject);
115 if (info->msg && *info->msg) { 119 if (info->msg && *info->msg) {
116 htmlf("%s", info->msg); 120 htmlf("%s", info->msg);
117 if (info->msg[strlen(info->msg) - 1] != '\n') 121 if (info->msg[strlen(info->msg) - 1] != '\n')
118 html("\n"); 122 html("\n");
119 } 123 }
120 html("---\n"); 124 html("---\n");
121 cgit_diff_tree(old_sha1, sha1, filepair_cb, NULL); 125 cgit_diff_tree(old_sha1, sha1, filepair_cb, NULL);
122 html("--\n"); 126 html("--\n");
123 htmlf("cgit %s\n", CGIT_VERSION); 127 htmlf("cgit %s\n", CGIT_VERSION);
124 cgit_free_commitinfo(info); 128 cgit_free_commitinfo(info);
125} 129}
diff --git a/ui-tag.c b/ui-tag.c
index 0e056e0..a9c8670 100644
--- a/ui-tag.c
+++ b/ui-tag.c
@@ -1,89 +1,89 @@
1/* ui-tag.c: display a tag 1/* ui-tag.c: display a tag
2 * 2 *
3 * Copyright (C) 2007 Lars Hjemli 3 * Copyright (C) 2007 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 12
13static void print_tag_content(char *buf) 13static void print_tag_content(char *buf)
14{ 14{
15 char *p; 15 char *p;
16 16
17 if (!buf) 17 if (!buf)
18 return; 18 return;
19 19
20 html("<div class='commit-subject'>"); 20 html("<div class='commit-subject'>");
21 p = strchr(buf, '\n'); 21 p = strchr(buf, '\n');
22 if (p) 22 if (p)
23 *p = '\0'; 23 *p = '\0';
24 html_txt(buf); 24 html_txt(buf);
25 html("</div>"); 25 html("</div>");
26 if (p) { 26 if (p) {
27 html("<div class='commit-msg'>"); 27 html("<div class='commit-msg'>");
28 html_txt(++p); 28 html_txt(++p);
29 html("</div>"); 29 html("</div>");
30 } 30 }
31} 31}
32 32
33void cgit_print_tag(char *revname) 33void cgit_print_tag(char *revname)
34{ 34{
35 unsigned char sha1[20]; 35 unsigned char sha1[20];
36 struct object *obj; 36 struct object *obj;
37 struct tag *tag; 37 struct tag *tag;
38 struct taginfo *info; 38 struct taginfo *info;
39 39
40 if (get_sha1(revname, sha1)) { 40 if (get_sha1(revname, sha1)) {
41 cgit_print_error(fmt("Bad tag reference: %s", revname)); 41 cgit_print_error(fmt("Bad tag reference: %s", revname));
42 return; 42 return;
43 } 43 }
44 obj = parse_object(sha1); 44 obj = parse_object(sha1);
45 if (!obj) { 45 if (!obj) {
46 cgit_print_error(fmt("Bad object id: %s", sha1_to_hex(sha1))); 46 cgit_print_error(fmt("Bad object id: %s", sha1_to_hex(sha1)));
47 return; 47 return;
48 } 48 }
49 if (obj->type == OBJ_TAG) { 49 if (obj->type == OBJ_TAG) {
50 tag = lookup_tag(sha1); 50 tag = lookup_tag(sha1);
51 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) { 51 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) {
52 cgit_print_error(fmt("Bad tag object: %s", revname)); 52 cgit_print_error(fmt("Bad tag object: %s", revname));
53 return; 53 return;
54 } 54 }
55 html("<table class='commit-info'>\n"); 55 html("<table class='commit-info'>\n");
56 htmlf("<tr><td>Tag name</td><td>"); 56 htmlf("<tr><td>Tag name</td><td>");
57 html_txt(revname); 57 html_txt(revname);
58 htmlf(" (%s)</td></tr>\n", sha1_to_hex(sha1)); 58 htmlf(" (%s)</td></tr>\n", sha1_to_hex(sha1));
59 if (info->tagger_date > 0) { 59 if (info->tagger_date > 0) {
60 html("<tr><td>Tag date</td><td>"); 60 html("<tr><td>Tag date</td><td>");
61 cgit_print_date(info->tagger_date, FMT_LONGDATE, ctx.cfg.local_time); 61 cgit_print_date(info->tagger_date, FMT_LONGDATE, ctx.cfg.local_time);
62 html("</td></tr>\n"); 62 html("</td></tr>\n");
63 } 63 }
64 if (info->tagger) { 64 if (info->tagger) {
65 html("<tr><td>Tagged by</td><td>"); 65 html("<tr><td>Tagged by</td><td>");
66 html_txt(info->tagger); 66 html_txt(info->tagger);
67 if (info->tagger_email) { 67 if (info->tagger_email && !ctx.cfg.noplainemail) {
68 html(" "); 68 html(" ");
69 html_txt(info->tagger_email); 69 html_txt(info->tagger_email);
70 } 70 }
71 html("</td></tr>\n"); 71 html("</td></tr>\n");
72 } 72 }
73 html("<tr><td>Tagged object</td><td>"); 73 html("<tr><td>Tagged object</td><td>");
74 cgit_object_link(tag->tagged); 74 cgit_object_link(tag->tagged);
75 html("</td></tr>\n"); 75 html("</td></tr>\n");
76 html("</table>\n"); 76 html("</table>\n");
77 print_tag_content(info->msg); 77 print_tag_content(info->msg);
78 } else { 78 } else {
79 html("<table class='commit-info'>\n"); 79 html("<table class='commit-info'>\n");
80 htmlf("<tr><td>Tag name</td><td>"); 80 htmlf("<tr><td>Tag name</td><td>");
81 html_txt(revname); 81 html_txt(revname);
82 html("</td></tr>\n"); 82 html("</td></tr>\n");
83 html("<tr><td>Tagged object</td><td>"); 83 html("<tr><td>Tagged object</td><td>");
84 cgit_object_link(obj); 84 cgit_object_link(obj);
85 html("</td></tr>\n"); 85 html("</td></tr>\n");
86 html("</table>\n"); 86 html("</table>\n");
87 } 87 }
88 return; 88 return;
89} 89}