summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.h1
-rw-r--r--cgitrc5
-rw-r--r--shared.c3
-rw-r--r--ui-summary.c8
4 files changed, 16 insertions, 1 deletions
diff --git a/cgit.h b/cgit.h
index d6bcde2..2f3fca1 100644
--- a/cgit.h
+++ b/cgit.h
@@ -2,226 +2,227 @@
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 <xdiff/xdiff.h> 18#include <xdiff/xdiff.h>
19 19
20 20
21/* 21/*
22 * The valid cgit repo-commands 22 * The valid cgit repo-commands
23 */ 23 */
24#define CMD_LOG 1 24#define CMD_LOG 1
25#define CMD_COMMIT 2 25#define CMD_COMMIT 2
26#define CMD_DIFF 3 26#define CMD_DIFF 3
27#define CMD_TREE 4 27#define CMD_TREE 4
28#define CMD_VIEW 5 28#define CMD_VIEW 5
29#define CMD_BLOB 6 29#define CMD_BLOB 6
30#define CMD_SNAPSHOT 7 30#define CMD_SNAPSHOT 7
31 31
32 32
33/* 33/*
34 * Dateformats used on misc. pages 34 * Dateformats used on misc. pages
35 */ 35 */
36#define FMT_LONGDATE "%Y-%m-%d %H:%M:%S" 36#define FMT_LONGDATE "%Y-%m-%d %H:%M:%S"
37#define FMT_SHORTDATE "%Y-%m-%d" 37#define FMT_SHORTDATE "%Y-%m-%d"
38 38
39 39
40/* 40/*
41 * Limits used for relative dates 41 * Limits used for relative dates
42 */ 42 */
43#define TM_MIN 60 43#define TM_MIN 60
44#define TM_HOUR (TM_MIN * 60) 44#define TM_HOUR (TM_MIN * 60)
45#define TM_DAY (TM_HOUR * 24) 45#define TM_DAY (TM_HOUR * 24)
46#define TM_WEEK (TM_DAY * 7) 46#define TM_WEEK (TM_DAY * 7)
47#define TM_YEAR (TM_DAY * 365) 47#define TM_YEAR (TM_DAY * 365)
48#define TM_MONTH (TM_YEAR / 12.0) 48#define TM_MONTH (TM_YEAR / 12.0)
49 49
50 50
51typedef void (*configfn)(const char *name, const char *value); 51typedef void (*configfn)(const char *name, const char *value);
52typedef void (*filepair_fn)(struct diff_filepair *pair); 52typedef void (*filepair_fn)(struct diff_filepair *pair);
53typedef void (*linediff_fn)(char *line, int len); 53typedef void (*linediff_fn)(char *line, int len);
54 54
55struct cacheitem { 55struct cacheitem {
56 char *name; 56 char *name;
57 struct stat st; 57 struct stat st;
58 int ttl; 58 int ttl;
59 int fd; 59 int fd;
60}; 60};
61 61
62struct repoinfo { 62struct repoinfo {
63 char *url; 63 char *url;
64 char *name; 64 char *name;
65 char *path; 65 char *path;
66 char *desc; 66 char *desc;
67 char *owner; 67 char *owner;
68 char *defbranch; 68 char *defbranch;
69 char *group; 69 char *group;
70 char *module_link; 70 char *module_link;
71 char *readme; 71 char *readme;
72 int snapshots; 72 int snapshots;
73 int enable_log_filecount; 73 int enable_log_filecount;
74 int enable_log_linecount; 74 int enable_log_linecount;
75}; 75};
76 76
77struct repolist { 77struct repolist {
78 int length; 78 int length;
79 int count; 79 int count;
80 struct repoinfo *repos; 80 struct repoinfo *repos;
81}; 81};
82 82
83struct commitinfo { 83struct commitinfo {
84 struct commit *commit; 84 struct commit *commit;
85 char *author; 85 char *author;
86 char *author_email; 86 char *author_email;
87 unsigned long author_date; 87 unsigned long author_date;
88 char *committer; 88 char *committer;
89 char *committer_email; 89 char *committer_email;
90 unsigned long committer_date; 90 unsigned long committer_date;
91 char *subject; 91 char *subject;
92 char *msg; 92 char *msg;
93}; 93};
94 94
95struct taginfo { 95struct taginfo {
96 char *tagger; 96 char *tagger;
97 char *tagger_email; 97 char *tagger_email;
98 int tagger_date; 98 int tagger_date;
99 char *msg; 99 char *msg;
100}; 100};
101 101
102extern const char cgit_version[]; 102extern const char cgit_version[];
103 103
104extern struct repolist cgit_repolist; 104extern struct repolist cgit_repolist;
105extern struct repoinfo *cgit_repo; 105extern struct repoinfo *cgit_repo;
106extern int cgit_cmd; 106extern int cgit_cmd;
107 107
108extern char *cgit_root_title; 108extern char *cgit_root_title;
109extern char *cgit_css; 109extern char *cgit_css;
110extern char *cgit_logo; 110extern char *cgit_logo;
111extern char *cgit_index_header; 111extern char *cgit_index_header;
112extern char *cgit_logo_link; 112extern char *cgit_logo_link;
113extern char *cgit_module_link; 113extern char *cgit_module_link;
114extern char *cgit_agefile; 114extern char *cgit_agefile;
115extern char *cgit_virtual_root; 115extern char *cgit_virtual_root;
116extern char *cgit_script_name; 116extern char *cgit_script_name;
117extern char *cgit_cache_root; 117extern char *cgit_cache_root;
118extern char *cgit_repo_group; 118extern char *cgit_repo_group;
119 119
120extern int cgit_nocache; 120extern int cgit_nocache;
121extern int cgit_snapshots; 121extern int cgit_snapshots;
122extern int cgit_enable_log_filecount; 122extern int cgit_enable_log_filecount;
123extern int cgit_enable_log_linecount; 123extern int cgit_enable_log_linecount;
124extern int cgit_max_lock_attempts; 124extern int cgit_max_lock_attempts;
125extern int cgit_cache_root_ttl; 125extern int cgit_cache_root_ttl;
126extern int cgit_cache_repo_ttl; 126extern int cgit_cache_repo_ttl;
127extern int cgit_cache_dynamic_ttl; 127extern int cgit_cache_dynamic_ttl;
128extern int cgit_cache_static_ttl; 128extern int cgit_cache_static_ttl;
129extern int cgit_cache_max_create_time; 129extern int cgit_cache_max_create_time;
130extern int cgit_summary_log;
130 131
131extern int cgit_max_msg_len; 132extern int cgit_max_msg_len;
132extern int cgit_max_repodesc_len; 133extern int cgit_max_repodesc_len;
133extern int cgit_max_commit_count; 134extern int cgit_max_commit_count;
134 135
135extern int cgit_query_has_symref; 136extern int cgit_query_has_symref;
136extern int cgit_query_has_sha1; 137extern int cgit_query_has_sha1;
137 138
138extern char *cgit_querystring; 139extern char *cgit_querystring;
139extern char *cgit_query_repo; 140extern char *cgit_query_repo;
140extern char *cgit_query_page; 141extern char *cgit_query_page;
141extern char *cgit_query_search; 142extern char *cgit_query_search;
142extern char *cgit_query_head; 143extern char *cgit_query_head;
143extern char *cgit_query_sha1; 144extern char *cgit_query_sha1;
144extern char *cgit_query_sha2; 145extern char *cgit_query_sha2;
145extern char *cgit_query_path; 146extern char *cgit_query_path;
146extern char *cgit_query_name; 147extern char *cgit_query_name;
147extern int cgit_query_ofs; 148extern int cgit_query_ofs;
148 149
149extern int htmlfd; 150extern int htmlfd;
150 151
151extern int cgit_get_cmd_index(const char *cmd); 152extern int cgit_get_cmd_index(const char *cmd);
152extern struct repoinfo *cgit_get_repoinfo(const char *url); 153extern struct repoinfo *cgit_get_repoinfo(const char *url);
153extern void cgit_global_config_cb(const char *name, const char *value); 154extern void cgit_global_config_cb(const char *name, const char *value);
154extern void cgit_repo_config_cb(const char *name, const char *value); 155extern void cgit_repo_config_cb(const char *name, const char *value);
155extern void cgit_querystring_cb(const char *name, const char *value); 156extern void cgit_querystring_cb(const char *name, const char *value);
156 157
157extern int chk_zero(int result, char *msg); 158extern int chk_zero(int result, char *msg);
158extern int chk_positive(int result, char *msg); 159extern int chk_positive(int result, char *msg);
159 160
160extern int hextoint(char c); 161extern int hextoint(char c);
161 162
162extern void *cgit_free_commitinfo(struct commitinfo *info); 163extern void *cgit_free_commitinfo(struct commitinfo *info);
163 164
164extern int cgit_diff_files(const unsigned char *old_sha1, 165extern int cgit_diff_files(const unsigned char *old_sha1,
165 const unsigned char *new_sha1, 166 const unsigned char *new_sha1,
166 linediff_fn fn); 167 linediff_fn fn);
167 168
168extern void cgit_diff_tree(const unsigned char *old_sha1, 169extern void cgit_diff_tree(const unsigned char *old_sha1,
169 const unsigned char *new_sha1, 170 const unsigned char *new_sha1,
170 filepair_fn fn); 171 filepair_fn fn);
171 172
172extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); 173extern void cgit_diff_commit(struct commit *commit, filepair_fn fn);
173 174
174extern char *fmt(const char *format,...); 175extern char *fmt(const char *format,...);
175 176
176extern void html(const char *txt); 177extern void html(const char *txt);
177extern void htmlf(const char *format,...); 178extern void htmlf(const char *format,...);
178extern void html_txt(char *txt); 179extern void html_txt(char *txt);
179extern void html_ntxt(int len, char *txt); 180extern void html_ntxt(int len, char *txt);
180extern void html_attr(char *txt); 181extern void html_attr(char *txt);
181extern void html_hidden(char *name, char *value); 182extern void html_hidden(char *name, char *value);
182extern void html_link_open(char *url, char *title, char *class); 183extern void html_link_open(char *url, char *title, char *class);
183extern void html_link_close(void); 184extern void html_link_close(void);
184extern void html_filemode(unsigned short mode); 185extern void html_filemode(unsigned short mode);
185extern int html_include(const char *filename); 186extern int html_include(const char *filename);
186 187
187extern int cgit_read_config(const char *filename, configfn fn); 188extern int cgit_read_config(const char *filename, configfn fn);
188extern int cgit_parse_query(char *txt, configfn fn); 189extern int cgit_parse_query(char *txt, configfn fn);
189extern struct commitinfo *cgit_parse_commit(struct commit *commit); 190extern struct commitinfo *cgit_parse_commit(struct commit *commit);
190extern struct taginfo *cgit_parse_tag(struct tag *tag); 191extern struct taginfo *cgit_parse_tag(struct tag *tag);
191extern void cgit_parse_url(const char *url); 192extern void cgit_parse_url(const char *url);
192 193
193extern char *cache_safe_filename(const char *unsafe); 194extern char *cache_safe_filename(const char *unsafe);
194extern int cache_lock(struct cacheitem *item); 195extern int cache_lock(struct cacheitem *item);
195extern int cache_unlock(struct cacheitem *item); 196extern int cache_unlock(struct cacheitem *item);
196extern int cache_cancel_lock(struct cacheitem *item); 197extern int cache_cancel_lock(struct cacheitem *item);
197extern int cache_exist(struct cacheitem *item); 198extern int cache_exist(struct cacheitem *item);
198extern int cache_expired(struct cacheitem *item); 199extern int cache_expired(struct cacheitem *item);
199 200
200extern char *cgit_repourl(const char *reponame); 201extern char *cgit_repourl(const char *reponame);
201extern char *cgit_pageurl(const char *reponame, const char *pagename, 202extern char *cgit_pageurl(const char *reponame, const char *pagename,
202 const char *query); 203 const char *query);
203 204
204extern void cgit_print_error(char *msg); 205extern void cgit_print_error(char *msg);
205extern void cgit_print_date(time_t secs, char *format); 206extern void cgit_print_date(time_t secs, char *format);
206extern void cgit_print_age(time_t t, time_t max_relative, char *format); 207extern void cgit_print_age(time_t t, time_t max_relative, char *format);
207extern void cgit_print_docstart(char *title, struct cacheitem *item); 208extern void cgit_print_docstart(char *title, struct cacheitem *item);
208extern void cgit_print_docend(); 209extern void cgit_print_docend();
209extern void cgit_print_pageheader(char *title, int show_search); 210extern void cgit_print_pageheader(char *title, int show_search);
210extern void cgit_print_snapshot_start(const char *mimetype, 211extern void cgit_print_snapshot_start(const char *mimetype,
211 const char *filename, 212 const char *filename,
212 struct cacheitem *item); 213 struct cacheitem *item);
213 214
214extern void cgit_print_repolist(struct cacheitem *item); 215extern void cgit_print_repolist(struct cacheitem *item);
215extern void cgit_print_summary(); 216extern void cgit_print_summary();
216extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, int pager); 217extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, int pager);
217extern void cgit_print_view(const char *hex, char *path); 218extern void cgit_print_view(const char *hex, char *path);
218extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); 219extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path);
219extern void cgit_print_tree(const char *rev, const char *hex, char *path); 220extern void cgit_print_tree(const char *rev, const char *hex, char *path);
220extern void cgit_print_commit(const char *hex); 221extern void cgit_print_commit(const char *hex);
221extern void cgit_print_diff(const char *head, const char *old_hex, const char *new_hex, 222extern void cgit_print_diff(const char *head, const char *old_hex, const char *new_hex,
222 char *path); 223 char *path);
223extern void cgit_print_snapshot(struct cacheitem *item, const char *hex, 224extern void cgit_print_snapshot(struct cacheitem *item, const char *hex,
224 const char *format, const char *prefix, 225 const char *format, const char *prefix,
225 const char *filename); 226 const char *filename);
226 227
227#endif /* CGIT_H */ 228#endif /* CGIT_H */
diff --git a/cgitrc b/cgitrc
index 054a708..0f602e4 100644
--- a/cgitrc
+++ b/cgitrc
@@ -1,111 +1,116 @@
1## 1##
2## cgitrc: template for /etc/cgitrc 2## cgitrc: template for /etc/cgitrc
3## 3##
4 4
5 5
6## Uncomment and set to 1 to deactivate caching of generated pages. Mostly 6## Uncomment and set to 1 to deactivate caching of generated pages. Mostly
7## usefull for testing. 7## usefull for testing.
8#nocache=0 8#nocache=0
9 9
10 10
11## Enable/disable snapshots by default. This can be overridden per repo 11## Enable/disable snapshots by default. This can be overridden per repo
12#snapshots=0 12#snapshots=0
13 13
14 14
15## Enable/disable display of 'number of files changed' in log view 15## Enable/disable display of 'number of files changed' in log view
16#enable-log-filecount=0 16#enable-log-filecount=0
17 17
18 18
19## Enable/disable display of 'number of lines changed' in log view 19## Enable/disable display of 'number of lines changed' in log view
20#enable-log-linecount=0 20#enable-log-linecount=0
21 21
22 22
23## Enable/disable display of HEAD shortlog in summary view. Set it to maximum
24## number of commits that should be displayed
25#summary-log=0
26
27
23## Specify a root for virtual urls. This makes cgit generate urls like 28## Specify a root for virtual urls. This makes cgit generate urls like
24## 29##
25## http://localhost/git/repo/log/?id=master 30## http://localhost/git/repo/log/?id=master
26## 31##
27## instead of 32## instead of
28## 33##
29## http://localhost/cgit/cgit.cgi?r=repo&p=log&id=master 34## http://localhost/cgit/cgit.cgi?r=repo&p=log&id=master
30## 35##
31## For this to work with apache, rewrite rules must be added to httpd.conf, 36## For this to work with apache, rewrite rules must be added to httpd.conf,
32## possibly looking something like this: 37## possibly looking something like this:
33## 38##
34## RewriteRule ^/git/$ /cgit/cgit.cgi [L,QSA] 39## RewriteRule ^/git/$ /cgit/cgit.cgi [L,QSA]
35## RewriteRule ^/git/([^/]+)/$ /cgit/cgit.cgi?r=$1 [L,QSA] 40## RewriteRule ^/git/([^/]+)/$ /cgit/cgit.cgi?r=$1 [L,QSA]
36## RewriteRule ^/git/([^/]+)/([^/]+)/$ /cgit/cgit.cgi?r=$1&p=$2 [L,QSA] 41## RewriteRule ^/git/([^/]+)/([^/]+)/$ /cgit/cgit.cgi?r=$1&p=$2 [L,QSA]
37## 42##
38## This setting is disabled by default. 43## This setting is disabled by default.
39#virtual-root=/git 44#virtual-root=/git
40 45
41 46
42## Set the title printed on the root page 47## Set the title printed on the root page
43#root-title=Git repository browser 48#root-title=Git repository browser
44 49
45 50
46## Link to css file 51## Link to css file
47#css=/cgit/cgit.css 52#css=/cgit/cgit.css
48 53
49 54
50## Link to logo file 55## Link to logo file
51#logo=/cgit/git-logo.png 56#logo=/cgit/git-logo.png
52 57
53 58
54## Url loaded when clicking the logo 59## Url loaded when clicking the logo
55#logo-link=http://www.kernel.org/pub/software/scm/git/docs/ 60#logo-link=http://www.kernel.org/pub/software/scm/git/docs/
56 61
57 62
58## Url loaded when clicking a submodule link 63## Url loaded when clicking a submodule link
59#module-link=./?repo=%s&page=commit&id=%s 64#module-link=./?repo=%s&page=commit&id=%s
60 65
61 66
62## Number of chars shown of repo description (in repolist view) 67## Number of chars shown of repo description (in repolist view)
63#max-repodesc-length=60 68#max-repodesc-length=60
64 69
65 70
66## Number of chars shown of commit subject message (in log view) 71## Number of chars shown of commit subject message (in log view)
67#max-message-length=60 72#max-message-length=60
68 73
69 74
70## Number of commits per page in log view 75## Number of commits per page in log view
71#max-commit-count=50 76#max-commit-count=50
72 77
73 78
74## Root of cached output 79## Root of cached output
75#cache-root=/var/cache/cgit 80#cache-root=/var/cache/cgit
76 81
77 82
78## Include another config-file 83## Include another config-file
79#include=/var/cgit/repolist 84#include=/var/cgit/repolist
80 85
81## 86##
82## Time-To-Live settings: specifies how long (in minutes) different pages 87## Time-To-Live settings: specifies how long (in minutes) different pages
83## should be cached (0 for instant expiration, -1 for immortal pages) 88## should be cached (0 for instant expiration, -1 for immortal pages)
84## 89##
85 90
86## ttl for root page 91## ttl for root page
87#cache-root-ttl=5 92#cache-root-ttl=5
88 93
89## ttl for repo summary page 94## ttl for repo summary page
90#cache-repo-ttl=5 95#cache-repo-ttl=5
91 96
92## ttl for other dynamic pages 97## ttl for other dynamic pages
93#cache-dynamic-ttl=5 98#cache-dynamic-ttl=5
94 99
95## ttl for static pages (addressed by SHA-1) 100## ttl for static pages (addressed by SHA-1)
96#cache-static-ttl=-1 101#cache-static-ttl=-1
97 102
98 103
99 104
100## Example repository entry. Required values are repo.url and repo.path (each 105## Example repository entry. Required values are repo.url and repo.path (each
101## repository section must start with repo.url). 106## repository section must start with repo.url).
102#repo.url=cgit 107#repo.url=cgit
103#repo.name=cgit 108#repo.name=cgit
104#repo.desc=the caching cgi for git 109#repo.desc=the caching cgi for git
105#repo.path=/pub/git/cgit 110#repo.path=/pub/git/cgit
106#repo.owner=Lars Hjemli 111#repo.owner=Lars Hjemli
107 #repo.snapshots=1 # override a sitewide snapshot-setting 112 #repo.snapshots=1 # override a sitewide snapshot-setting
108 #repo.enable-log-filecount=0 # override the default filecount setting 113 #repo.enable-log-filecount=0 # override the default filecount setting
109 #repo.enable-log-linecount=0 # override the default linecount setting 114 #repo.enable-log-linecount=0 # override the default linecount setting
110 #repo.module-link=/git/%s/commit/?id=%s # override the standard module-link 115 #repo.module-link=/git/%s/commit/?id=%s # override the standard module-link
111 #repo.readme=info/web/readme # specify a file to include on summary page 116 #repo.readme=info/web/readme # specify a file to include on summary page
diff --git a/shared.c b/shared.c
index e3123a8..b6d2fa1 100644
--- a/shared.c
+++ b/shared.c
@@ -1,294 +1,297 @@
1/* shared.c: global vars + some callback functions 1/* shared.c: global vars + some callback functions
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 10
11struct repolist cgit_repolist; 11struct repolist cgit_repolist;
12struct repoinfo *cgit_repo; 12struct repoinfo *cgit_repo;
13int cgit_cmd; 13int cgit_cmd;
14 14
15char *cgit_root_title = "Git repository browser"; 15char *cgit_root_title = "Git repository browser";
16char *cgit_css = "/cgit.css"; 16char *cgit_css = "/cgit.css";
17char *cgit_logo = "/git-logo.png"; 17char *cgit_logo = "/git-logo.png";
18char *cgit_index_header = NULL; 18char *cgit_index_header = NULL;
19char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; 19char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/";
20char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; 20char *cgit_module_link = "./?repo=%s&page=commit&id=%s";
21char *cgit_agefile = "info/web/last-modified"; 21char *cgit_agefile = "info/web/last-modified";
22char *cgit_virtual_root = NULL; 22char *cgit_virtual_root = NULL;
23char *cgit_script_name = CGIT_SCRIPT_NAME; 23char *cgit_script_name = CGIT_SCRIPT_NAME;
24char *cgit_cache_root = "/var/cache/cgit"; 24char *cgit_cache_root = "/var/cache/cgit";
25char *cgit_repo_group = NULL; 25char *cgit_repo_group = NULL;
26 26
27int cgit_nocache = 0; 27int cgit_nocache = 0;
28int cgit_snapshots = 0; 28int cgit_snapshots = 0;
29int cgit_enable_log_filecount = 0; 29int cgit_enable_log_filecount = 0;
30int cgit_enable_log_linecount = 0; 30int cgit_enable_log_linecount = 0;
31int cgit_max_lock_attempts = 5; 31int cgit_max_lock_attempts = 5;
32int cgit_cache_root_ttl = 5; 32int cgit_cache_root_ttl = 5;
33int cgit_cache_repo_ttl = 5; 33int cgit_cache_repo_ttl = 5;
34int cgit_cache_dynamic_ttl = 5; 34int cgit_cache_dynamic_ttl = 5;
35int cgit_cache_static_ttl = -1; 35int cgit_cache_static_ttl = -1;
36int cgit_cache_max_create_time = 5; 36int cgit_cache_max_create_time = 5;
37int cgit_summary_log = 0;
37 38
38int cgit_max_msg_len = 60; 39int cgit_max_msg_len = 60;
39int cgit_max_repodesc_len = 60; 40int cgit_max_repodesc_len = 60;
40int cgit_max_commit_count = 50; 41int cgit_max_commit_count = 50;
41 42
42int cgit_query_has_symref = 0; 43int cgit_query_has_symref = 0;
43int cgit_query_has_sha1 = 0; 44int cgit_query_has_sha1 = 0;
44 45
45char *cgit_querystring = NULL; 46char *cgit_querystring = NULL;
46char *cgit_query_repo = NULL; 47char *cgit_query_repo = NULL;
47char *cgit_query_page = NULL; 48char *cgit_query_page = NULL;
48char *cgit_query_head = NULL; 49char *cgit_query_head = NULL;
49char *cgit_query_search = NULL; 50char *cgit_query_search = NULL;
50char *cgit_query_sha1 = NULL; 51char *cgit_query_sha1 = NULL;
51char *cgit_query_sha2 = NULL; 52char *cgit_query_sha2 = NULL;
52char *cgit_query_path = NULL; 53char *cgit_query_path = NULL;
53char *cgit_query_name = NULL; 54char *cgit_query_name = NULL;
54int cgit_query_ofs = 0; 55int cgit_query_ofs = 0;
55 56
56int htmlfd = 0; 57int htmlfd = 0;
57 58
58 59
59int cgit_get_cmd_index(const char *cmd) 60int cgit_get_cmd_index(const char *cmd)
60{ 61{
61 static char *cmds[] = {"log", "commit", "diff", "tree", "view", "blob", "snapshot", NULL}; 62 static char *cmds[] = {"log", "commit", "diff", "tree", "view", "blob", "snapshot", NULL};
62 int i; 63 int i;
63 64
64 for(i = 0; cmds[i]; i++) 65 for(i = 0; cmds[i]; i++)
65 if (!strcmp(cmd, cmds[i])) 66 if (!strcmp(cmd, cmds[i]))
66 return i + 1; 67 return i + 1;
67 return 0; 68 return 0;
68} 69}
69 70
70int chk_zero(int result, char *msg) 71int chk_zero(int result, char *msg)
71{ 72{
72 if (result != 0) 73 if (result != 0)
73 die("%s: %s", msg, strerror(errno)); 74 die("%s: %s", msg, strerror(errno));
74 return result; 75 return result;
75} 76}
76 77
77int chk_positive(int result, char *msg) 78int chk_positive(int result, char *msg)
78{ 79{
79 if (result <= 0) 80 if (result <= 0)
80 die("%s: %s", msg, strerror(errno)); 81 die("%s: %s", msg, strerror(errno));
81 return result; 82 return result;
82} 83}
83 84
84struct repoinfo *add_repo(const char *url) 85struct repoinfo *add_repo(const char *url)
85{ 86{
86 struct repoinfo *ret; 87 struct repoinfo *ret;
87 88
88 if (++cgit_repolist.count > cgit_repolist.length) { 89 if (++cgit_repolist.count > cgit_repolist.length) {
89 if (cgit_repolist.length == 0) 90 if (cgit_repolist.length == 0)
90 cgit_repolist.length = 8; 91 cgit_repolist.length = 8;
91 else 92 else
92 cgit_repolist.length *= 2; 93 cgit_repolist.length *= 2;
93 cgit_repolist.repos = xrealloc(cgit_repolist.repos, 94 cgit_repolist.repos = xrealloc(cgit_repolist.repos,
94 cgit_repolist.length * 95 cgit_repolist.length *
95 sizeof(struct repoinfo)); 96 sizeof(struct repoinfo));
96 } 97 }
97 98
98 ret = &cgit_repolist.repos[cgit_repolist.count-1]; 99 ret = &cgit_repolist.repos[cgit_repolist.count-1];
99 ret->url = xstrdup(url); 100 ret->url = xstrdup(url);
100 ret->name = ret->url; 101 ret->name = ret->url;
101 ret->path = NULL; 102 ret->path = NULL;
102 ret->desc = NULL; 103 ret->desc = NULL;
103 ret->owner = NULL; 104 ret->owner = NULL;
104 ret->group = cgit_repo_group; 105 ret->group = cgit_repo_group;
105 ret->defbranch = "master"; 106 ret->defbranch = "master";
106 ret->snapshots = cgit_snapshots; 107 ret->snapshots = cgit_snapshots;
107 ret->enable_log_filecount = cgit_enable_log_filecount; 108 ret->enable_log_filecount = cgit_enable_log_filecount;
108 ret->enable_log_linecount = cgit_enable_log_linecount; 109 ret->enable_log_linecount = cgit_enable_log_linecount;
109 ret->module_link = cgit_module_link; 110 ret->module_link = cgit_module_link;
110 ret->readme = NULL; 111 ret->readme = NULL;
111 return ret; 112 return ret;
112} 113}
113 114
114struct repoinfo *cgit_get_repoinfo(const char *url) 115struct repoinfo *cgit_get_repoinfo(const char *url)
115{ 116{
116 int i; 117 int i;
117 struct repoinfo *repo; 118 struct repoinfo *repo;
118 119
119 for (i=0; i<cgit_repolist.count; i++) { 120 for (i=0; i<cgit_repolist.count; i++) {
120 repo = &cgit_repolist.repos[i]; 121 repo = &cgit_repolist.repos[i];
121 if (!strcmp(repo->url, url)) 122 if (!strcmp(repo->url, url))
122 return repo; 123 return repo;
123 } 124 }
124 return NULL; 125 return NULL;
125} 126}
126 127
127void cgit_global_config_cb(const char *name, const char *value) 128void cgit_global_config_cb(const char *name, const char *value)
128{ 129{
129 if (!strcmp(name, "root-title")) 130 if (!strcmp(name, "root-title"))
130 cgit_root_title = xstrdup(value); 131 cgit_root_title = xstrdup(value);
131 else if (!strcmp(name, "css")) 132 else if (!strcmp(name, "css"))
132 cgit_css = xstrdup(value); 133 cgit_css = xstrdup(value);
133 else if (!strcmp(name, "logo")) 134 else if (!strcmp(name, "logo"))
134 cgit_logo = xstrdup(value); 135 cgit_logo = xstrdup(value);
135 else if (!strcmp(name, "index-header")) 136 else if (!strcmp(name, "index-header"))
136 cgit_index_header = xstrdup(value); 137 cgit_index_header = xstrdup(value);
137 else if (!strcmp(name, "logo-link")) 138 else if (!strcmp(name, "logo-link"))
138 cgit_logo_link = xstrdup(value); 139 cgit_logo_link = xstrdup(value);
139 else if (!strcmp(name, "module-link")) 140 else if (!strcmp(name, "module-link"))
140 cgit_module_link = xstrdup(value); 141 cgit_module_link = xstrdup(value);
141 else if (!strcmp(name, "virtual-root")) 142 else if (!strcmp(name, "virtual-root"))
142 cgit_virtual_root = xstrdup(value); 143 cgit_virtual_root = xstrdup(value);
143 else if (!strcmp(name, "nocache")) 144 else if (!strcmp(name, "nocache"))
144 cgit_nocache = atoi(value); 145 cgit_nocache = atoi(value);
145 else if (!strcmp(name, "snapshots")) 146 else if (!strcmp(name, "snapshots"))
146 cgit_snapshots = atoi(value); 147 cgit_snapshots = atoi(value);
147 else if (!strcmp(name, "enable-log-filecount")) 148 else if (!strcmp(name, "enable-log-filecount"))
148 cgit_enable_log_filecount = atoi(value); 149 cgit_enable_log_filecount = atoi(value);
149 else if (!strcmp(name, "enable-log-linecount")) 150 else if (!strcmp(name, "enable-log-linecount"))
150 cgit_enable_log_linecount = atoi(value); 151 cgit_enable_log_linecount = atoi(value);
151 else if (!strcmp(name, "cache-root")) 152 else if (!strcmp(name, "cache-root"))
152 cgit_cache_root = xstrdup(value); 153 cgit_cache_root = xstrdup(value);
153 else if (!strcmp(name, "cache-root-ttl")) 154 else if (!strcmp(name, "cache-root-ttl"))
154 cgit_cache_root_ttl = atoi(value); 155 cgit_cache_root_ttl = atoi(value);
155 else if (!strcmp(name, "cache-repo-ttl")) 156 else if (!strcmp(name, "cache-repo-ttl"))
156 cgit_cache_repo_ttl = atoi(value); 157 cgit_cache_repo_ttl = atoi(value);
157 else if (!strcmp(name, "cache-static-ttl")) 158 else if (!strcmp(name, "cache-static-ttl"))
158 cgit_cache_static_ttl = atoi(value); 159 cgit_cache_static_ttl = atoi(value);
159 else if (!strcmp(name, "cache-dynamic-ttl")) 160 else if (!strcmp(name, "cache-dynamic-ttl"))
160 cgit_cache_dynamic_ttl = atoi(value); 161 cgit_cache_dynamic_ttl = atoi(value);
161 else if (!strcmp(name, "max-message-length")) 162 else if (!strcmp(name, "max-message-length"))
162 cgit_max_msg_len = atoi(value); 163 cgit_max_msg_len = atoi(value);
163 else if (!strcmp(name, "max-repodesc-length")) 164 else if (!strcmp(name, "max-repodesc-length"))
164 cgit_max_repodesc_len = atoi(value); 165 cgit_max_repodesc_len = atoi(value);
165 else if (!strcmp(name, "max-commit-count")) 166 else if (!strcmp(name, "max-commit-count"))
166 cgit_max_commit_count = atoi(value); 167 cgit_max_commit_count = atoi(value);
168 else if (!strcmp(name, "summary-log"))
169 cgit_summary_log = atoi(value);
167 else if (!strcmp(name, "agefile")) 170 else if (!strcmp(name, "agefile"))
168 cgit_agefile = xstrdup(value); 171 cgit_agefile = xstrdup(value);
169 else if (!strcmp(name, "repo.group")) 172 else if (!strcmp(name, "repo.group"))
170 cgit_repo_group = xstrdup(value); 173 cgit_repo_group = xstrdup(value);
171 else if (!strcmp(name, "repo.url")) 174 else if (!strcmp(name, "repo.url"))
172 cgit_repo = add_repo(value); 175 cgit_repo = add_repo(value);
173 else if (!strcmp(name, "repo.name")) 176 else if (!strcmp(name, "repo.name"))
174 cgit_repo->name = xstrdup(value); 177 cgit_repo->name = xstrdup(value);
175 else if (cgit_repo && !strcmp(name, "repo.path")) 178 else if (cgit_repo && !strcmp(name, "repo.path"))
176 cgit_repo->path = xstrdup(value); 179 cgit_repo->path = xstrdup(value);
177 else if (cgit_repo && !strcmp(name, "repo.desc")) 180 else if (cgit_repo && !strcmp(name, "repo.desc"))
178 cgit_repo->desc = xstrdup(value); 181 cgit_repo->desc = xstrdup(value);
179 else if (cgit_repo && !strcmp(name, "repo.owner")) 182 else if (cgit_repo && !strcmp(name, "repo.owner"))
180 cgit_repo->owner = xstrdup(value); 183 cgit_repo->owner = xstrdup(value);
181 else if (cgit_repo && !strcmp(name, "repo.defbranch")) 184 else if (cgit_repo && !strcmp(name, "repo.defbranch"))
182 cgit_repo->defbranch = xstrdup(value); 185 cgit_repo->defbranch = xstrdup(value);
183 else if (cgit_repo && !strcmp(name, "repo.snapshots")) 186 else if (cgit_repo && !strcmp(name, "repo.snapshots"))
184 cgit_repo->snapshots = cgit_snapshots * atoi(value); 187 cgit_repo->snapshots = cgit_snapshots * atoi(value);
185 else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) 188 else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount"))
186 cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value); 189 cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value);
187 else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) 190 else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount"))
188 cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value); 191 cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value);
189 else if (cgit_repo && !strcmp(name, "repo.module-link")) 192 else if (cgit_repo && !strcmp(name, "repo.module-link"))
190 cgit_repo->module_link= xstrdup(value); 193 cgit_repo->module_link= xstrdup(value);
191 else if (cgit_repo && !strcmp(name, "repo.readme") && value != NULL) { 194 else if (cgit_repo && !strcmp(name, "repo.readme") && value != NULL) {
192 if (*value == '/') 195 if (*value == '/')
193 cgit_repo->readme = xstrdup(value); 196 cgit_repo->readme = xstrdup(value);
194 else 197 else
195 cgit_repo->readme = xstrdup(fmt("%s/%s", cgit_repo->path, value)); 198 cgit_repo->readme = xstrdup(fmt("%s/%s", cgit_repo->path, value));
196 } else if (!strcmp(name, "include")) 199 } else if (!strcmp(name, "include"))
197 cgit_read_config(value, cgit_global_config_cb); 200 cgit_read_config(value, cgit_global_config_cb);
198} 201}
199 202
200void cgit_querystring_cb(const char *name, const char *value) 203void cgit_querystring_cb(const char *name, const char *value)
201{ 204{
202 if (!strcmp(name,"r")) { 205 if (!strcmp(name,"r")) {
203 cgit_query_repo = xstrdup(value); 206 cgit_query_repo = xstrdup(value);
204 cgit_repo = cgit_get_repoinfo(value); 207 cgit_repo = cgit_get_repoinfo(value);
205 } else if (!strcmp(name, "p")) { 208 } else if (!strcmp(name, "p")) {
206 cgit_query_page = xstrdup(value); 209 cgit_query_page = xstrdup(value);
207 cgit_cmd = cgit_get_cmd_index(value); 210 cgit_cmd = cgit_get_cmd_index(value);
208 } else if (!strcmp(name, "url")) { 211 } else if (!strcmp(name, "url")) {
209 cgit_parse_url(value); 212 cgit_parse_url(value);
210 } else if (!strcmp(name, "q")) { 213 } else if (!strcmp(name, "q")) {
211 cgit_query_search = xstrdup(value); 214 cgit_query_search = xstrdup(value);
212 } else if (!strcmp(name, "h")) { 215 } else if (!strcmp(name, "h")) {
213 cgit_query_head = xstrdup(value); 216 cgit_query_head = xstrdup(value);
214 cgit_query_has_symref = 1; 217 cgit_query_has_symref = 1;
215 } else if (!strcmp(name, "id")) { 218 } else if (!strcmp(name, "id")) {
216 cgit_query_sha1 = xstrdup(value); 219 cgit_query_sha1 = xstrdup(value);
217 cgit_query_has_sha1 = 1; 220 cgit_query_has_sha1 = 1;
218 } else if (!strcmp(name, "id2")) { 221 } else if (!strcmp(name, "id2")) {
219 cgit_query_sha2 = xstrdup(value); 222 cgit_query_sha2 = xstrdup(value);
220 cgit_query_has_sha1 = 1; 223 cgit_query_has_sha1 = 1;
221 } else if (!strcmp(name, "ofs")) { 224 } else if (!strcmp(name, "ofs")) {
222 cgit_query_ofs = atoi(value); 225 cgit_query_ofs = atoi(value);
223 } else if (!strcmp(name, "path")) { 226 } else if (!strcmp(name, "path")) {
224 cgit_query_path = xstrdup(value); 227 cgit_query_path = xstrdup(value);
225 } else if (!strcmp(name, "name")) { 228 } else if (!strcmp(name, "name")) {
226 cgit_query_name = xstrdup(value); 229 cgit_query_name = xstrdup(value);
227 } 230 }
228} 231}
229 232
230void *cgit_free_commitinfo(struct commitinfo *info) 233void *cgit_free_commitinfo(struct commitinfo *info)
231{ 234{
232 free(info->author); 235 free(info->author);
233 free(info->author_email); 236 free(info->author_email);
234 free(info->committer); 237 free(info->committer);
235 free(info->committer_email); 238 free(info->committer_email);
236 free(info->subject); 239 free(info->subject);
237 free(info); 240 free(info);
238 return NULL; 241 return NULL;
239} 242}
240 243
241int hextoint(char c) 244int hextoint(char c)
242{ 245{
243 if (c >= 'a' && c <= 'f') 246 if (c >= 'a' && c <= 'f')
244 return 10 + c - 'a'; 247 return 10 + c - 'a';
245 else if (c >= 'A' && c <= 'F') 248 else if (c >= 'A' && c <= 'F')
246 return 10 + c - 'A'; 249 return 10 + c - 'A';
247 else if (c >= '0' && c <= '9') 250 else if (c >= '0' && c <= '9')
248 return c - '0'; 251 return c - '0';
249 else 252 else
250 return -1; 253 return -1;
251} 254}
252 255
253void cgit_diff_tree_cb(struct diff_queue_struct *q, 256void cgit_diff_tree_cb(struct diff_queue_struct *q,
254 struct diff_options *options, void *data) 257 struct diff_options *options, void *data)
255{ 258{
256 int i; 259 int i;
257 260
258 for (i = 0; i < q->nr; i++) { 261 for (i = 0; i < q->nr; i++) {
259 if (q->queue[i]->status == 'U') 262 if (q->queue[i]->status == 'U')
260 continue; 263 continue;
261 ((filepair_fn)data)(q->queue[i]); 264 ((filepair_fn)data)(q->queue[i]);
262 } 265 }
263} 266}
264 267
265static int load_mmfile(mmfile_t *file, const unsigned char *sha1) 268static int load_mmfile(mmfile_t *file, const unsigned char *sha1)
266{ 269{
267 enum object_type type; 270 enum object_type type;
268 271
269 if (is_null_sha1(sha1)) { 272 if (is_null_sha1(sha1)) {
270 file->ptr = (char *)""; 273 file->ptr = (char *)"";
271 file->size = 0; 274 file->size = 0;
272 } else { 275 } else {
273 file->ptr = read_sha1_file(sha1, &type, &file->size); 276 file->ptr = read_sha1_file(sha1, &type, &file->size);
274 } 277 }
275 return 1; 278 return 1;
276} 279}
277 280
278/* 281/*
279 * Receive diff-buffers from xdiff and concatenate them as 282 * Receive diff-buffers from xdiff and concatenate them as
280 * needed across multiple callbacks. 283 * needed across multiple callbacks.
281 * 284 *
282 * This is basically a copy of xdiff-interface.c/xdiff_outf(), 285 * This is basically a copy of xdiff-interface.c/xdiff_outf(),
283 * ripped from git and modified to use globals instead of 286 * ripped from git and modified to use globals instead of
284 * a special callback-struct. 287 * a special callback-struct.
285 */ 288 */
286char *diffbuf = NULL; 289char *diffbuf = NULL;
287int buflen = 0; 290int buflen = 0;
288 291
289int filediff_cb(void *priv, mmbuffer_t *mb, int nbuf) 292int filediff_cb(void *priv, mmbuffer_t *mb, int nbuf)
290{ 293{
291 int i; 294 int i;
292 295
293 for (i = 0; i < nbuf; i++) { 296 for (i = 0; i < nbuf; i++) {
294 if (mb[i].ptr[mb[i].size-1] != '\n') { 297 if (mb[i].ptr[mb[i].size-1] != '\n') {
diff --git a/ui-summary.c b/ui-summary.c
index 15e8aec..4bda4c2 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -1,212 +1,218 @@
1/* ui-summary.c: functions for generating repo summary page 1/* ui-summary.c: functions for generating repo summary page
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 10
11static int header; 11static int header;
12 12
13static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, 13static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1,
14 int flags, void *cb_data) 14 int flags, void *cb_data)
15{ 15{
16 struct commit *commit; 16 struct commit *commit;
17 struct commitinfo *info; 17 struct commitinfo *info;
18 char buf[256], *url; 18 char buf[256], *url;
19 19
20 strncpy(buf, refname, sizeof(buf)); 20 strncpy(buf, refname, sizeof(buf));
21 commit = lookup_commit(sha1); 21 commit = lookup_commit(sha1);
22 // object is not really parsed at this point, because of some fallout
23 // from previous calls to git functions in cgit_print_log()
24 commit->object.parsed = 0;
22 if (commit && !parse_commit(commit)){ 25 if (commit && !parse_commit(commit)){
23 info = cgit_parse_commit(commit); 26 info = cgit_parse_commit(commit);
24 html("<tr><td>"); 27 html("<tr><td>");
25 url = cgit_pageurl(cgit_query_repo, "log", 28 url = cgit_pageurl(cgit_query_repo, "log",
26 fmt("h=%s", refname)); 29 fmt("h=%s", refname));
27 html_link_open(url, NULL, NULL); 30 html_link_open(url, NULL, NULL);
28 html_txt(buf); 31 html_txt(buf);
29 html_link_close(); 32 html_link_close();
30 html("</td><td>"); 33 html("</td><td>");
31 cgit_print_age(commit->date, -1, NULL); 34 cgit_print_age(commit->date, -1, NULL);
32 html("</td><td>"); 35 html("</td><td>");
33 html_txt(info->author); 36 html_txt(info->author);
34 html("</td><td>"); 37 html("</td><td>");
35 url = cgit_pageurl(cgit_query_repo, "commit", 38 url = cgit_pageurl(cgit_query_repo, "commit",
36 fmt("h=%s", sha1_to_hex(sha1))); 39 fmt("h=%s", sha1_to_hex(sha1)));
37 html_link_open(url, NULL, NULL); 40 html_link_open(url, NULL, NULL);
38 html_ntxt(cgit_max_msg_len, info->subject); 41 html_ntxt(cgit_max_msg_len, info->subject);
39 html_link_close(); 42 html_link_close();
40 html("</td></tr>\n"); 43 html("</td></tr>\n");
41 cgit_free_commitinfo(info); 44 cgit_free_commitinfo(info);
42 } else { 45 } else {
43 html("<tr><td>"); 46 html("<tr><td>");
44 html_txt(buf); 47 html_txt(buf);
45 html("</td><td colspan='3'>"); 48 html("</td><td colspan='3'>");
46 htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); 49 htmlf("*** bad ref %s ***", sha1_to_hex(sha1));
47 html("</td></tr>\n"); 50 html("</td></tr>\n");
48 } 51 }
49 return 0; 52 return 0;
50} 53}
51 54
52 55
53static void cgit_print_object_ref(struct object *obj) 56static void cgit_print_object_ref(struct object *obj)
54{ 57{
55 char *page, *arg, *url; 58 char *page, *arg, *url;
56 59
57 if (obj->type == OBJ_COMMIT) { 60 if (obj->type == OBJ_COMMIT) {
58 page = "commit"; 61 page = "commit";
59 arg = "h"; 62 arg = "h";
60 } else if (obj->type == OBJ_TREE) { 63 } else if (obj->type == OBJ_TREE) {
61 page = "tree"; 64 page = "tree";
62 arg = "id"; 65 arg = "id";
63 } else { 66 } else {
64 page = "view"; 67 page = "view";
65 arg = "id"; 68 arg = "id";
66 } 69 }
67 70
68 url = cgit_pageurl(cgit_query_repo, page, 71 url = cgit_pageurl(cgit_query_repo, page,
69 fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); 72 fmt("%s=%s", arg, sha1_to_hex(obj->sha1)));
70 html_link_open(url, NULL, NULL); 73 html_link_open(url, NULL, NULL);
71 htmlf("%s %s", typename(obj->type), 74 htmlf("%s %s", typename(obj->type),
72 sha1_to_hex(obj->sha1)); 75 sha1_to_hex(obj->sha1));
73 html_link_close(); 76 html_link_close();
74} 77}
75 78
76static void print_tag_header() 79static void print_tag_header()
77{ 80{
78 html("<tr class='nohover'><th class='left'>Tag</th>" 81 html("<tr class='nohover'><th class='left'>Tag</th>"
79 "<th class='left'>Age</th>" 82 "<th class='left'>Age</th>"
80 "<th class='left'>Author</th>" 83 "<th class='left'>Author</th>"
81 "<th class='left'>Reference</th></tr>\n"); 84 "<th class='left'>Reference</th></tr>\n");
82 header = 1; 85 header = 1;
83} 86}
84 87
85static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1, 88static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1,
86 int flags, void *cb_data) 89 int flags, void *cb_data)
87{ 90{
88 struct tag *tag; 91 struct tag *tag;
89 struct taginfo *info; 92 struct taginfo *info;
90 struct object *obj; 93 struct object *obj;
91 char buf[256], *url; 94 char buf[256], *url;
92 95
93 strncpy(buf, refname, sizeof(buf)); 96 strncpy(buf, refname, sizeof(buf));
94 obj = parse_object(sha1); 97 obj = parse_object(sha1);
95 if (!obj) 98 if (!obj)
96 return 1; 99 return 1;
97 if (obj->type == OBJ_TAG) { 100 if (obj->type == OBJ_TAG) {
98 tag = lookup_tag(sha1); 101 tag = lookup_tag(sha1);
99 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) 102 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag)))
100 return 2; 103 return 2;
101 if (!header) 104 if (!header)
102 print_tag_header(); 105 print_tag_header();
103 html("<tr><td>"); 106 html("<tr><td>");
104 url = cgit_pageurl(cgit_query_repo, "view", 107 url = cgit_pageurl(cgit_query_repo, "view",
105 fmt("id=%s", sha1_to_hex(sha1))); 108 fmt("id=%s", sha1_to_hex(sha1)));
106 html_link_open(url, NULL, NULL); 109 html_link_open(url, NULL, NULL);
107 html_txt(buf); 110 html_txt(buf);
108 html_link_close(); 111 html_link_close();
109 html("</td><td>"); 112 html("</td><td>");
110 if (info->tagger_date > 0) 113 if (info->tagger_date > 0)
111 cgit_print_age(info->tagger_date, -1, NULL); 114 cgit_print_age(info->tagger_date, -1, NULL);
112 html("</td><td>"); 115 html("</td><td>");
113 if (info->tagger) 116 if (info->tagger)
114 html(info->tagger); 117 html(info->tagger);
115 html("</td><td>"); 118 html("</td><td>");
116 cgit_print_object_ref(tag->tagged); 119 cgit_print_object_ref(tag->tagged);
117 html("</td></tr>\n"); 120 html("</td></tr>\n");
118 } else { 121 } else {
119 if (!header) 122 if (!header)
120 print_tag_header(); 123 print_tag_header();
121 html("<tr><td>"); 124 html("<tr><td>");
122 html_txt(buf); 125 html_txt(buf);
123 html("</td><td colspan='2'/><td>"); 126 html("</td><td colspan='2'/><td>");
124 cgit_print_object_ref(obj); 127 cgit_print_object_ref(obj);
125 html("</td></tr>\n"); 128 html("</td></tr>\n");
126 } 129 }
127 return 0; 130 return 0;
128} 131}
129 132
130static int cgit_print_archive_cb(const char *refname, const unsigned char *sha1, 133static int cgit_print_archive_cb(const char *refname, const unsigned char *sha1,
131 int flags, void *cb_data) 134 int flags, void *cb_data)
132{ 135{
133 struct tag *tag; 136 struct tag *tag;
134 struct taginfo *info; 137 struct taginfo *info;
135 struct object *obj; 138 struct object *obj;
136 char buf[256], *url; 139 char buf[256], *url;
137 unsigned char fileid[20]; 140 unsigned char fileid[20];
138 141
139 if (prefixcmp(refname, "refs/archives")) 142 if (prefixcmp(refname, "refs/archives"))
140 return 0; 143 return 0;
141 strncpy(buf, refname+14, sizeof(buf)); 144 strncpy(buf, refname+14, sizeof(buf));
142 obj = parse_object(sha1); 145 obj = parse_object(sha1);
143 if (!obj) 146 if (!obj)
144 return 1; 147 return 1;
145 if (obj->type == OBJ_TAG) { 148 if (obj->type == OBJ_TAG) {
146 tag = lookup_tag(sha1); 149 tag = lookup_tag(sha1);
147 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) 150 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag)))
148 return 0; 151 return 0;
149 hashcpy(fileid, tag->tagged->sha1); 152 hashcpy(fileid, tag->tagged->sha1);
150 } else if (obj->type != OBJ_BLOB) { 153 } else if (obj->type != OBJ_BLOB) {
151 return 0; 154 return 0;
152 } else { 155 } else {
153 hashcpy(fileid, sha1); 156 hashcpy(fileid, sha1);
154 } 157 }
155 if (!header) { 158 if (!header) {
156 html("<table id='downloads'>"); 159 html("<table id='downloads'>");
157 html("<tr><th>Downloads</th></tr>"); 160 html("<tr><th>Downloads</th></tr>");
158 header = 1; 161 header = 1;
159 } 162 }
160 html("<tr><td>"); 163 html("<tr><td>");
161 url = cgit_pageurl(cgit_query_repo, "blob", 164 url = cgit_pageurl(cgit_query_repo, "blob",
162 fmt("id=%s&amp;path=%s", sha1_to_hex(fileid), 165 fmt("id=%s&amp;path=%s", sha1_to_hex(fileid),
163 buf)); 166 buf));
164 html_link_open(url, NULL, NULL); 167 html_link_open(url, NULL, NULL);
165 html_txt(buf); 168 html_txt(buf);
166 html_link_close(); 169 html_link_close();
167 html("</td></tr>"); 170 html("</td></tr>");
168 return 0; 171 return 0;
169} 172}
170 173
171static void cgit_print_branches() 174static void cgit_print_branches()
172{ 175{
173 html("<tr class='nohover'><th class='left'>Branch</th>" 176 html("<tr class='nohover'><th class='left'>Branch</th>"
174 "<th class='left'>Idle</th>" 177 "<th class='left'>Idle</th>"
175 "<th class='left'>Author</th>" 178 "<th class='left'>Author</th>"
176 "<th class='left'>Head commit</th></tr>\n"); 179 "<th class='left'>Head commit</th></tr>\n");
177 for_each_branch_ref(cgit_print_branch_cb, NULL); 180 for_each_branch_ref(cgit_print_branch_cb, NULL);
178} 181}
179 182
180static void cgit_print_tags() 183static void cgit_print_tags()
181{ 184{
182 header = 0; 185 header = 0;
183 for_each_tag_ref(cgit_print_tag_cb, NULL); 186 for_each_tag_ref(cgit_print_tag_cb, NULL);
184} 187}
185 188
186static void cgit_print_archives() 189static void cgit_print_archives()
187{ 190{
188 header = 0; 191 header = 0;
189 for_each_ref(cgit_print_archive_cb, NULL); 192 for_each_ref(cgit_print_archive_cb, NULL);
190 if (header) 193 if (header)
191 html("</table>"); 194 html("</table>");
192} 195}
193 196
194void cgit_print_summary() 197void cgit_print_summary()
195{ 198{
196 html("<div id='summary'>"); 199 html("<div id='summary'>");
197 cgit_print_archives(); 200 cgit_print_archives();
198 html("<h2>"); 201 html("<h2>");
199 html_txt(cgit_repo->name); 202 html_txt(cgit_repo->name);
200 html(" - "); 203 html(" - ");
201 html_txt(cgit_repo->desc); 204 html_txt(cgit_repo->desc);
202 html("</h2>"); 205 html("</h2>");
203 if (cgit_repo->readme) 206 if (cgit_repo->readme)
204 html_include(cgit_repo->readme); 207 html_include(cgit_repo->readme);
205 html("</div>"); 208 html("</div>");
206 209 if (cgit_summary_log > 0)
210 cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, NULL, 0);
207 html("<table class='list nowrap'>"); 211 html("<table class='list nowrap'>");
212 if (cgit_summary_log > 0)
213 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
208 cgit_print_branches(); 214 cgit_print_branches();
209 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>"); 215 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
210 cgit_print_tags(); 216 cgit_print_tags();
211 html("</table>"); 217 html("</table>");
212} 218}