summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile2
-rw-r--r--cgitrc.5.txt11
m---------git0
-rw-r--r--ui-commit.c2
-rw-r--r--ui-log.c2
-rw-r--r--ui-plain.c3
6 files changed, 8 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 1f9893a..dc9dffd 100644
--- a/Makefile
+++ b/Makefile
@@ -1,104 +1,104 @@
1CGIT_VERSION = v0.8.2.1 1CGIT_VERSION = v0.8.2.1
2CGIT_SCRIPT_NAME = cgit.cgi 2CGIT_SCRIPT_NAME = cgit.cgi
3CGIT_SCRIPT_PATH = /var/www/htdocs/cgit 3CGIT_SCRIPT_PATH = /var/www/htdocs/cgit
4CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH) 4CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH)
5CGIT_CONFIG = /etc/cgitrc 5CGIT_CONFIG = /etc/cgitrc
6CACHE_ROOT = /var/cache/cgit 6CACHE_ROOT = /var/cache/cgit
7SHA1_HEADER = <openssl/sha.h> 7SHA1_HEADER = <openssl/sha.h>
8GIT_VER = 1.6.3.4 8GIT_VER = 1.6.4.3
9GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 9GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2
10INSTALL = install 10INSTALL = install
11 11
12# Define NO_STRCASESTR if you don't have strcasestr. 12# Define NO_STRCASESTR if you don't have strcasestr.
13# 13#
14# Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin). 14# Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin).
15# 15#
16 16
17#-include config.mak 17#-include config.mak
18 18
19# 19#
20# Platform specific tweaks 20# Platform specific tweaks
21# 21#
22 22
23uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') 23uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
24uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not') 24uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
25uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not') 25uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
26 26
27ifeq ($(uname_O),Cygwin) 27ifeq ($(uname_O),Cygwin)
28 NO_STRCASESTR = YesPlease 28 NO_STRCASESTR = YesPlease
29 NEEDS_LIBICONV = YesPlease 29 NEEDS_LIBICONV = YesPlease
30endif 30endif
31 31
32# 32#
33# Let the user override the above settings. 33# Let the user override the above settings.
34# 34#
35-include cgit.conf 35-include cgit.conf
36 36
37# 37#
38# Define a way to invoke make in subdirs quietly, shamelessly ripped 38# Define a way to invoke make in subdirs quietly, shamelessly ripped
39# from git.git 39# from git.git
40# 40#
41QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir 41QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
42QUIET_SUBDIR1 = 42QUIET_SUBDIR1 =
43 43
44ifneq ($(findstring $(MAKEFLAGS),w),w) 44ifneq ($(findstring $(MAKEFLAGS),w),w)
45PRINT_DIR = --no-print-directory 45PRINT_DIR = --no-print-directory
46else # "make -w" 46else # "make -w"
47NO_SUBDIR = : 47NO_SUBDIR = :
48endif 48endif
49 49
50ifndef V 50ifndef V
51 QUIET_CC = @echo ' ' CC $@; 51 QUIET_CC = @echo ' ' CC $@;
52 QUIET_MM = @echo ' ' MM $@; 52 QUIET_MM = @echo ' ' MM $@;
53 QUIET_SUBDIR0 = +@subdir= 53 QUIET_SUBDIR0 = +@subdir=
54 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ 54 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
55 $(MAKE) $(PRINT_DIR) -C $$subdir 55 $(MAKE) $(PRINT_DIR) -C $$subdir
56endif 56endif
57 57
58# 58#
59# Define a pattern rule for automatic dependency building 59# Define a pattern rule for automatic dependency building
60# 60#
61%.d: %.c 61%.d: %.c
62 $(QUIET_MM)$(CC) $(CFLAGS) -MM $< | sed -e 's/\($*\)\.o:/\1.o $@:/g' >$@ 62 $(QUIET_MM)$(CC) $(CFLAGS) -MM $< | sed -e 's/\($*\)\.o:/\1.o $@:/g' >$@
63 63
64# 64#
65# Define a pattern rule for silent object building 65# Define a pattern rule for silent object building
66# 66#
67%.o: %.c 67%.o: %.c
68 $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $< 68 $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $<
69 69
70 70
71EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto 71EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto
72OBJECTS = 72OBJECTS =
73OBJECTS += cache.o 73OBJECTS += cache.o
74OBJECTS += cgit.o 74OBJECTS += cgit.o
75OBJECTS += cmd.o 75OBJECTS += cmd.o
76OBJECTS += configfile.o 76OBJECTS += configfile.o
77OBJECTS += html.o 77OBJECTS += html.o
78OBJECTS += parsing.o 78OBJECTS += parsing.o
79OBJECTS += scan-tree.o 79OBJECTS += scan-tree.o
80OBJECTS += shared.o 80OBJECTS += shared.o
81OBJECTS += ui-atom.o 81OBJECTS += ui-atom.o
82OBJECTS += ui-blob.o 82OBJECTS += ui-blob.o
83OBJECTS += ui-clone.o 83OBJECTS += ui-clone.o
84OBJECTS += ui-commit.o 84OBJECTS += ui-commit.o
85OBJECTS += ui-diff.o 85OBJECTS += ui-diff.o
86OBJECTS += ui-log.o 86OBJECTS += ui-log.o
87OBJECTS += ui-patch.o 87OBJECTS += ui-patch.o
88OBJECTS += ui-plain.o 88OBJECTS += ui-plain.o
89OBJECTS += ui-refs.o 89OBJECTS += ui-refs.o
90OBJECTS += ui-repolist.o 90OBJECTS += ui-repolist.o
91OBJECTS += ui-shared.o 91OBJECTS += ui-shared.o
92OBJECTS += ui-snapshot.o 92OBJECTS += ui-snapshot.o
93OBJECTS += ui-stats.o 93OBJECTS += ui-stats.o
94OBJECTS += ui-summary.o 94OBJECTS += ui-summary.o
95OBJECTS += ui-tag.o 95OBJECTS += ui-tag.o
96OBJECTS += ui-tree.o 96OBJECTS += ui-tree.o
97 97
98ifdef NEEDS_LIBICONV 98ifdef NEEDS_LIBICONV
99 EXTLIBS += -liconv 99 EXTLIBS += -liconv
100endif 100endif
101 101
102 102
103.PHONY: all libgit test install uninstall clean force-version get-git \ 103.PHONY: all libgit test install uninstall clean force-version get-git \
104 doc man-doc html-doc clean-doc 104 doc man-doc html-doc clean-doc
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index ac5c58c..3b16db9 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -128,200 +128,195 @@ include::
128index-header:: 128index-header::
129 The content of the file specified with this option will be included 129 The content of the file specified with this option will be included
130 verbatim above the repository index. This setting is deprecated, and 130 verbatim above the repository index. This setting is deprecated, and
131 will not be supported by cgit-1.0 (use root-readme instead). Default 131 will not be supported by cgit-1.0 (use root-readme instead). Default
132 value: none. 132 value: none.
133 133
134index-info:: 134index-info::
135 The content of the file specified with this option will be included 135 The content of the file specified with this option will be included
136 verbatim below the heading on the repository index page. This setting 136 verbatim below the heading on the repository index page. This setting
137 is deprecated, and will not be supported by cgit-1.0 (use root-desc 137 is deprecated, and will not be supported by cgit-1.0 (use root-desc
138 instead). Default value: none. 138 instead). Default value: none.
139 139
140local-time:: 140local-time::
141 Flag which, if set to "1", makes cgit print commit and tag times in the 141 Flag which, if set to "1", makes cgit print commit and tag times in the
142 servers timezone. Default value: "0". 142 servers timezone. Default value: "0".
143 143
144logo:: 144logo::
145 Url which specifies the source of an image which will be used as a logo 145 Url which specifies the source of an image which will be used as a logo
146 on all cgit pages. Default value: "/cgit.png". 146 on all cgit pages. Default value: "/cgit.png".
147 147
148logo-link:: 148logo-link::
149 Url loaded when clicking on the cgit logo image. If unspecified the 149 Url loaded when clicking on the cgit logo image. If unspecified the
150 calculated url of the repository index page will be used. Default 150 calculated url of the repository index page will be used. Default
151 value: none. 151 value: none.
152 152
153max-commit-count:: 153max-commit-count::
154 Specifies the number of entries to list per page in "log" view. Default 154 Specifies the number of entries to list per page in "log" view. Default
155 value: "50". 155 value: "50".
156 156
157max-message-length:: 157max-message-length::
158 Specifies the maximum number of commit message characters to display in 158 Specifies the maximum number of commit message characters to display in
159 "log" view. Default value: "80". 159 "log" view. Default value: "80".
160 160
161max-repo-count:: 161max-repo-count::
162 Specifies the number of entries to list per page on therepository 162 Specifies the number of entries to list per page on therepository
163 index page. Default value: "50". 163 index page. Default value: "50".
164 164
165max-repodesc-length:: 165max-repodesc-length::
166 Specifies the maximum number of repo description characters to display 166 Specifies the maximum number of repo description characters to display
167 on the repository index page. Default value: "80". 167 on the repository index page. Default value: "80".
168 168
169max-stats:: 169max-stats::
170 Set the default maximum statistics period. Valid values are "week", 170 Set the default maximum statistics period. Valid values are "week",
171 "month", "quarter" and "year". If unspecified, statistics are 171 "month", "quarter" and "year". If unspecified, statistics are
172 disabled. Default value: none. See also: "repo.max-stats". 172 disabled. Default value: none. See also: "repo.max-stats".
173 173
174mimetype.<ext>:: 174mimetype.<ext>::
175 Set the mimetype for the specified filename extension. This is used 175 Set the mimetype for the specified filename extension. This is used
176 by the `plain` command when returning blob content. 176 by the `plain` command when returning blob content.
177 177
178module-link:: 178module-link::
179 Text which will be used as the formatstring for a hyperlink when a 179 Text which will be used as the formatstring for a hyperlink when a
180 submodule is printed in a directory listing. The arguments for the 180 submodule is printed in a directory listing. The arguments for the
181 formatstring are the path and SHA1 of the submodule commit. Default 181 formatstring are the path and SHA1 of the submodule commit. Default
182 value: "./?repo=%s&page=commit&id=%s" 182 value: "./?repo=%s&page=commit&id=%s"
183 183
184nocache:: 184nocache::
185 If set to the value "1" caching will be disabled. This settings is 185 If set to the value "1" caching will be disabled. This settings is
186 deprecated, and will not be honored starting with cgit-1.0. Default 186 deprecated, and will not be honored starting with cgit-1.0. Default
187 value: "0". 187 value: "0".
188 188
189noplainemail:: 189noplainemail::
190 If set to "1" showing full author email adresses will be disabled. 190 If set to "1" showing full author email adresses will be disabled.
191 Default value: "0". 191 Default value: "0".
192 192
193noheader:: 193noheader::
194 Flag which, when set to "1", will make cgit omit the standard header 194 Flag which, when set to "1", will make cgit omit the standard header
195 on all pages. Default value: none. See also: "embedded". 195 on all pages. Default value: none. See also: "embedded".
196 196
197renamelimit:: 197renamelimit::
198 Maximum number of files to consider when detecting renames. The value 198 Maximum number of files to consider when detecting renames. The value
199 "-1" uses the compiletime value in git (for further info, look at 199 "-1" uses the compiletime value in git (for further info, look at
200 `man git-diff`). Default value: "-1". 200 `man git-diff`). Default value: "-1".
201 201
202repo.group:: 202repo.group::
203 A value for the current repository group, which all repositories 203 A value for the current repository group, which all repositories
204 specified after this setting will inherit. Default value: none. 204 specified after this setting will inherit. Default value: none.
205 205
206robots:: 206robots::
207 Text used as content for the "robots" meta-tag. Default value: 207 Text used as content for the "robots" meta-tag. Default value:
208 "index, nofollow". 208 "index, nofollow".
209 209
210root-desc:: 210root-desc::
211 Text printed below the heading on the repository index page. Default 211 Text printed below the heading on the repository index page. Default
212 value: "a fast webinterface for the git dscm". 212 value: "a fast webinterface for the git dscm".
213 213
214root-readme:: 214root-readme::
215 The content of the file specified with this option will be included 215 The content of the file specified with this option will be included
216 verbatim below the "about" link on the repository index page. Default 216 verbatim below the "about" link on the repository index page. Default
217 value: none. 217 value: none.
218 218
219root-title:: 219root-title::
220 Text printed as heading on the repository index page. Default value: 220 Text printed as heading on the repository index page. Default value:
221 "Git Repository Browser". 221 "Git Repository Browser".
222 222
223snapshots:: 223snapshots::
224 Text which specifies the default (and allowed) set of snapshot formats 224 Text which specifies the default set of snapshot formats generated by
225 supported by cgit. The value is a space-separated list of zero or more 225 cgit. The value is a space-separated list of zero or more of the
226 of the following values: 226 values "tar", "tar.gz", "tar.bz2" and "zip". Default value: none.
227 "tar" uncompressed tar-file
228 "tar.gz"gzip-compressed tar-file
229 "tar.bz2"bzip-compressed tar-file
230 "zip" zip-file
231 Default value: none.
232 227
233source-filter:: 228source-filter::
234 Specifies a command which will be invoked to format plaintext blobs 229 Specifies a command which will be invoked to format plaintext blobs
235 in the tree view. The command will get the blob content on its STDIN 230 in the tree view. The command will get the blob content on its STDIN
236 and the name of the blob as its only command line argument. The STDOUT 231 and the name of the blob as its only command line argument. The STDOUT
237 from the command will be included verbatim as the blob contents, i.e. 232 from the command will be included verbatim as the blob contents, i.e.
238 this can be used to implement e.g. syntax highlighting. Default value: 233 this can be used to implement e.g. syntax highlighting. Default value:
239 none. 234 none.
240 235
241summary-branches:: 236summary-branches::
242 Specifies the number of branches to display in the repository "summary" 237 Specifies the number of branches to display in the repository "summary"
243 view. Default value: "10". 238 view. Default value: "10".
244 239
245summary-log:: 240summary-log::
246 Specifies the number of log entries to display in the repository 241 Specifies the number of log entries to display in the repository
247 "summary" view. Default value: "10". 242 "summary" view. Default value: "10".
248 243
249summary-tags:: 244summary-tags::
250 Specifies the number of tags to display in the repository "summary" 245 Specifies the number of tags to display in the repository "summary"
251 view. Default value: "10". 246 view. Default value: "10".
252 247
253virtual-root:: 248virtual-root::
254 Url which, if specified, will be used as root for all cgit links. It 249 Url which, if specified, will be used as root for all cgit links. It
255 will also cause cgit to generate 'virtual urls', i.e. urls like 250 will also cause cgit to generate 'virtual urls', i.e. urls like
256 '/cgit/tree/README' as opposed to '?r=cgit&p=tree&path=README'. Default 251 '/cgit/tree/README' as opposed to '?r=cgit&p=tree&path=README'. Default
257 value: none. 252 value: none.
258 NOTE: cgit has recently learned how to use PATH_INFO to achieve the 253 NOTE: cgit has recently learned how to use PATH_INFO to achieve the
259 same kind of virtual urls, so this option will probably be deprecated. 254 same kind of virtual urls, so this option will probably be deprecated.
260 255
261REPOSITORY SETTINGS 256REPOSITORY SETTINGS
262------------------- 257-------------------
263repo.about-filter:: 258repo.about-filter::
264 Override the default about-filter. Default value: <about-filter>. 259 Override the default about-filter. Default value: <about-filter>.
265 260
266repo.clone-url:: 261repo.clone-url::
267 A list of space-separated urls which can be used to clone this repo. 262 A list of space-separated urls which can be used to clone this repo.
268 Default value: none. 263 Default value: none.
269 264
270repo.commit-filter:: 265repo.commit-filter::
271 Override the default commit-filter. Default value: <commit-filter>. 266 Override the default commit-filter. Default value: <commit-filter>.
272 267
273repo.defbranch:: 268repo.defbranch::
274 The name of the default branch for this repository. If no such branch 269 The name of the default branch for this repository. If no such branch
275 exists in the repository, the first branch name (when sorted) is used 270 exists in the repository, the first branch name (when sorted) is used
276 as default instead. Default value: "master". 271 as default instead. Default value: "master".
277 272
278repo.desc:: 273repo.desc::
279 The value to show as repository description. Default value: none. 274 The value to show as repository description. Default value: none.
280 275
281repo.enable-log-filecount:: 276repo.enable-log-filecount::
282 A flag which can be used to disable the global setting 277 A flag which can be used to disable the global setting
283 `enable-log-filecount'. Default value: none. 278 `enable-log-filecount'. Default value: none.
284 279
285repo.enable-log-linecount:: 280repo.enable-log-linecount::
286 A flag which can be used to disable the global setting 281 A flag which can be used to disable the global setting
287 `enable-log-linecount'. Default value: none. 282 `enable-log-linecount'. Default value: none.
288 283
289repo.max-stats:: 284repo.max-stats::
290 Override the default maximum statistics period. Valid values are equal 285 Override the default maximum statistics period. Valid values are equal
291 to the values specified for the global "max-stats" setting. Default 286 to the values specified for the global "max-stats" setting. Default
292 value: none. 287 value: none.
293 288
294repo.name:: 289repo.name::
295 The value to show as repository name. Default value: <repo.url>. 290 The value to show as repository name. Default value: <repo.url>.
296 291
297repo.owner:: 292repo.owner::
298 A value used to identify the owner of the repository. Default value: 293 A value used to identify the owner of the repository. Default value:
299 none. 294 none.
300 295
301repo.path:: 296repo.path::
302 An absolute path to the repository directory. For non-bare repositories 297 An absolute path to the repository directory. For non-bare repositories
303 this is the .git-directory. Default value: none. 298 this is the .git-directory. Default value: none.
304 299
305repo.readme:: 300repo.readme::
306 A path (relative to <repo.path>) which specifies a file to include 301 A path (relative to <repo.path>) which specifies a file to include
307 verbatim as the "About" page for this repo. Default value: none. 302 verbatim as the "About" page for this repo. Default value: none.
308 303
309repo.snapshots:: 304repo.snapshots::
310 A mask of allowed snapshot-formats for this repo, restricted by the 305 A mask of allowed snapshot-formats for this repo, restricted by the
311 "snapshots" global setting. Default value: <snapshots>. 306 "snapshots" global setting. Default value: <snapshots>.
312 307
313repo.source-filter:: 308repo.source-filter::
314 Override the default source-filter. Default value: <source-filter>. 309 Override the default source-filter. Default value: <source-filter>.
315 310
316repo.url:: 311repo.url::
317 The relative url used to access the repository. This must be the first 312 The relative url used to access the repository. This must be the first
318 setting specified for each repo. Default value: none. 313 setting specified for each repo. Default value: none.
319 314
320 315
321EXAMPLE CGITRC FILE 316EXAMPLE CGITRC FILE
322------------------- 317-------------------
323 318
324.... 319....
325# Enable caching of up to 1000 output entriess 320# Enable caching of up to 1000 output entriess
326cache-size=1000 321cache-size=1000
327 322
diff --git a/git b/git
Subproject e276f018f2c1f0fc962fbe44a36708d1cdebada Subproject 7fb6bcff2dece2ff9fbc5ebfe526d9b2a7e764c
diff --git a/ui-commit.c b/ui-commit.c
index d6b73ee..f5b0ae5 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -1,118 +1,118 @@
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(DECORATE_FULL_REFS);
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 if (!ctx.cfg.noplainemail) { 43 if (!ctx.cfg.noplainemail) {
44 html(" "); 44 html(" ");
45 html_txt(info->author_email); 45 html_txt(info->author_email);
46 } 46 }
47 html("</td><td class='right'>"); 47 html("</td><td class='right'>");
48 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);
49 html("</td></tr>\n"); 49 html("</td></tr>\n");
50 html("<tr><th>committer</th><td>"); 50 html("<tr><th>committer</th><td>");
51 html_txt(info->committer); 51 html_txt(info->committer);
52 if (!ctx.cfg.noplainemail) { 52 if (!ctx.cfg.noplainemail) {
53 html(" "); 53 html(" ");
54 html_txt(info->committer_email); 54 html_txt(info->committer_email);
55 } 55 }
56 html("</td><td class='right'>"); 56 html("</td><td class='right'>");
57 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);
58 html("</td></tr>\n"); 58 html("</td></tr>\n");
59 html("<tr><th>commit</th><td colspan='2' class='sha1'>"); 59 html("<tr><th>commit</th><td colspan='2' class='sha1'>");
60 tmp = sha1_to_hex(commit->object.sha1); 60 tmp = sha1_to_hex(commit->object.sha1);
61 cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp); 61 cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp);
62 html(" ("); 62 html(" (");
63 cgit_patch_link("patch", NULL, NULL, NULL, tmp); 63 cgit_patch_link("patch", NULL, NULL, NULL, tmp);
64 html(")</td></tr>\n"); 64 html(")</td></tr>\n");
65 html("<tr><th>tree</th><td colspan='2' class='sha1'>"); 65 html("<tr><th>tree</th><td colspan='2' class='sha1'>");
66 tmp = xstrdup(hex); 66 tmp = xstrdup(hex);
67 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,
68 ctx.qry.head, tmp, NULL); 68 ctx.qry.head, tmp, NULL);
69 html("</td></tr>\n"); 69 html("</td></tr>\n");
70 for (p = commit->parents; p ; p = p->next) { 70 for (p = commit->parents; p ; p = p->next) {
71 parent = lookup_commit_reference(p->item->object.sha1); 71 parent = lookup_commit_reference(p->item->object.sha1);
72 if (!parent) { 72 if (!parent) {
73 html("<tr><td colspan='3'>"); 73 html("<tr><td colspan='3'>");
74 cgit_print_error("Error reading parent commit"); 74 cgit_print_error("Error reading parent commit");
75 html("</td></tr>"); 75 html("</td></tr>");
76 continue; 76 continue;
77 } 77 }
78 html("<tr><th>parent</th>" 78 html("<tr><th>parent</th>"
79 "<td colspan='2' class='sha1'>"); 79 "<td colspan='2' class='sha1'>");
80 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,
81 ctx.qry.head, sha1_to_hex(p->item->object.sha1)); 81 ctx.qry.head, sha1_to_hex(p->item->object.sha1));
82 html(" ("); 82 html(" (");
83 cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex, 83 cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex,
84 sha1_to_hex(p->item->object.sha1), NULL); 84 sha1_to_hex(p->item->object.sha1), NULL);
85 html(")</td></tr>"); 85 html(")</td></tr>");
86 parents++; 86 parents++;
87 } 87 }
88 if (ctx.repo->snapshots) { 88 if (ctx.repo->snapshots) {
89 html("<tr><th>download</th><td colspan='2' class='sha1'>"); 89 html("<tr><th>download</th><td colspan='2' class='sha1'>");
90 cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head, 90 cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head,
91 hex, ctx.repo->snapshots); 91 hex, ctx.repo->snapshots);
92 html("</td></tr>"); 92 html("</td></tr>");
93 } 93 }
94 html("</table>\n"); 94 html("</table>\n");
95 html("<div class='commit-subject'>"); 95 html("<div class='commit-subject'>");
96 if (ctx.repo->commit_filter) 96 if (ctx.repo->commit_filter)
97 cgit_open_filter(ctx.repo->commit_filter); 97 cgit_open_filter(ctx.repo->commit_filter);
98 html_txt(info->subject); 98 html_txt(info->subject);
99 if (ctx.repo->commit_filter) 99 if (ctx.repo->commit_filter)
100 cgit_close_filter(ctx.repo->commit_filter); 100 cgit_close_filter(ctx.repo->commit_filter);
101 show_commit_decorations(commit); 101 show_commit_decorations(commit);
102 html("</div>"); 102 html("</div>");
103 html("<div class='commit-msg'>"); 103 html("<div class='commit-msg'>");
104 if (ctx.repo->commit_filter) 104 if (ctx.repo->commit_filter)
105 cgit_open_filter(ctx.repo->commit_filter); 105 cgit_open_filter(ctx.repo->commit_filter);
106 html_txt(info->msg); 106 html_txt(info->msg);
107 if (ctx.repo->commit_filter) 107 if (ctx.repo->commit_filter)
108 cgit_close_filter(ctx.repo->commit_filter); 108 cgit_close_filter(ctx.repo->commit_filter);
109 html("</div>"); 109 html("</div>");
110 if (parents < 3) { 110 if (parents < 3) {
111 if (parents) 111 if (parents)
112 tmp = sha1_to_hex(commit->parents->item->object.sha1); 112 tmp = sha1_to_hex(commit->parents->item->object.sha1);
113 else 113 else
114 tmp = NULL; 114 tmp = NULL;
115 cgit_print_diff(ctx.qry.sha1, tmp, NULL); 115 cgit_print_diff(ctx.qry.sha1, tmp, NULL);
116 } 116 }
117 cgit_free_commitinfo(info); 117 cgit_free_commitinfo(info);
118} 118}
diff --git a/ui-log.c b/ui-log.c
index 0b37785..f3132c9 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -68,167 +68,167 @@ void show_commit_decorations(struct commit *commit)
68 cgit_commit_link(buf, NULL, "deco", ctx.qry.head, 68 cgit_commit_link(buf, NULL, "deco", ctx.qry.head,
69 sha1_to_hex(commit->object.sha1)); 69 sha1_to_hex(commit->object.sha1));
70 } 70 }
71 deco = deco->next; 71 deco = deco->next;
72 } 72 }
73} 73}
74 74
75void print_commit(struct commit *commit) 75void print_commit(struct commit *commit)
76{ 76{
77 struct commitinfo *info; 77 struct commitinfo *info;
78 char *tmp; 78 char *tmp;
79 int cols = 2; 79 int cols = 2;
80 80
81 info = cgit_parse_commit(commit); 81 info = cgit_parse_commit(commit);
82 htmlf("<tr%s><td>", 82 htmlf("<tr%s><td>",
83 ctx.qry.showmsg ? " class='logheader'" : ""); 83 ctx.qry.showmsg ? " class='logheader'" : "");
84 tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1)); 84 tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1));
85 tmp = cgit_pageurl(ctx.repo->url, "commit", tmp); 85 tmp = cgit_pageurl(ctx.repo->url, "commit", tmp);
86 html_link_open(tmp, NULL, NULL); 86 html_link_open(tmp, NULL, NULL);
87 cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); 87 cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE);
88 html_link_close(); 88 html_link_close();
89 htmlf("</td><td%s>", 89 htmlf("</td><td%s>",
90 ctx.qry.showmsg ? " class='logsubject'" : ""); 90 ctx.qry.showmsg ? " class='logsubject'" : "");
91 cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, 91 cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head,
92 sha1_to_hex(commit->object.sha1)); 92 sha1_to_hex(commit->object.sha1));
93 show_commit_decorations(commit); 93 show_commit_decorations(commit);
94 html("</td><td>"); 94 html("</td><td>");
95 html_txt(info->author); 95 html_txt(info->author);
96 if (ctx.repo->enable_log_filecount) { 96 if (ctx.repo->enable_log_filecount) {
97 files = 0; 97 files = 0;
98 add_lines = 0; 98 add_lines = 0;
99 rem_lines = 0; 99 rem_lines = 0;
100 cgit_diff_commit(commit, inspect_files); 100 cgit_diff_commit(commit, inspect_files);
101 html("</td><td>"); 101 html("</td><td>");
102 htmlf("%d", files); 102 htmlf("%d", files);
103 if (ctx.repo->enable_log_linecount) { 103 if (ctx.repo->enable_log_linecount) {
104 html("</td><td>"); 104 html("</td><td>");
105 htmlf("-%d/+%d", rem_lines, add_lines); 105 htmlf("-%d/+%d", rem_lines, add_lines);
106 } 106 }
107 } 107 }
108 html("</td></tr>\n"); 108 html("</td></tr>\n");
109 if (ctx.qry.showmsg) { 109 if (ctx.qry.showmsg) {
110 if (ctx.repo->enable_log_filecount) { 110 if (ctx.repo->enable_log_filecount) {
111 cols++; 111 cols++;
112 if (ctx.repo->enable_log_linecount) 112 if (ctx.repo->enable_log_linecount)
113 cols++; 113 cols++;
114 } 114 }
115 htmlf("<tr class='nohover'><td/><td colspan='%d' class='logmsg'>", 115 htmlf("<tr class='nohover'><td/><td colspan='%d' class='logmsg'>",
116 cols); 116 cols);
117 html_txt(info->msg); 117 html_txt(info->msg);
118 html("</td></tr>\n"); 118 html("</td></tr>\n");
119 } 119 }
120 cgit_free_commitinfo(info); 120 cgit_free_commitinfo(info);
121} 121}
122 122
123static const char *disambiguate_ref(const char *ref) 123static const char *disambiguate_ref(const char *ref)
124{ 124{
125 unsigned char sha1[20]; 125 unsigned char sha1[20];
126 const char *longref; 126 const char *longref;
127 127
128 longref = fmt("refs/heads/%s", ref); 128 longref = fmt("refs/heads/%s", ref);
129 if (get_sha1(longref, sha1) == 0) 129 if (get_sha1(longref, sha1) == 0)
130 return longref; 130 return longref;
131 131
132 return ref; 132 return ref;
133} 133}
134 134
135void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, 135void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern,
136 char *path, int pager) 136 char *path, int pager)
137{ 137{
138 struct rev_info rev; 138 struct rev_info rev;
139 struct commit *commit; 139 struct commit *commit;
140 const char *argv[] = {NULL, NULL, NULL, NULL, NULL}; 140 const char *argv[] = {NULL, NULL, NULL, NULL, NULL};
141 int argc = 2; 141 int argc = 2;
142 int i, columns = 3; 142 int i, columns = 3;
143 143
144 if (!tip) 144 if (!tip)
145 tip = ctx.qry.head; 145 tip = ctx.qry.head;
146 146
147 argv[1] = disambiguate_ref(tip); 147 argv[1] = disambiguate_ref(tip);
148 148
149 if (grep && pattern && (!strcmp(grep, "grep") || 149 if (grep && pattern && (!strcmp(grep, "grep") ||
150 !strcmp(grep, "author") || 150 !strcmp(grep, "author") ||
151 !strcmp(grep, "committer"))) 151 !strcmp(grep, "committer")))
152 argv[argc++] = fmt("--%s=%s", grep, pattern); 152 argv[argc++] = fmt("--%s=%s", grep, pattern);
153 153
154 if (path) { 154 if (path) {
155 argv[argc++] = "--"; 155 argv[argc++] = "--";
156 argv[argc++] = path; 156 argv[argc++] = path;
157 } 157 }
158 init_revisions(&rev, NULL); 158 init_revisions(&rev, NULL);
159 rev.abbrev = DEFAULT_ABBREV; 159 rev.abbrev = DEFAULT_ABBREV;
160 rev.commit_format = CMIT_FMT_DEFAULT; 160 rev.commit_format = CMIT_FMT_DEFAULT;
161 rev.verbose_header = 1; 161 rev.verbose_header = 1;
162 rev.show_root_diff = 0; 162 rev.show_root_diff = 0;
163 setup_revisions(argc, argv, &rev, NULL); 163 setup_revisions(argc, argv, &rev, NULL);
164 load_ref_decorations(); 164 load_ref_decorations(DECORATE_FULL_REFS);
165 rev.show_decorations = 1; 165 rev.show_decorations = 1;
166 rev.grep_filter.regflags |= REG_ICASE; 166 rev.grep_filter.regflags |= REG_ICASE;
167 compile_grep_patterns(&rev.grep_filter); 167 compile_grep_patterns(&rev.grep_filter);
168 prepare_revision_walk(&rev); 168 prepare_revision_walk(&rev);
169 169
170 if (pager) 170 if (pager)
171 html("<table class='list nowrap'>"); 171 html("<table class='list nowrap'>");
172 172
173 html("<tr class='nohover'><th class='left'>Age</th>" 173 html("<tr class='nohover'><th class='left'>Age</th>"
174 "<th class='left'>Commit message"); 174 "<th class='left'>Commit message");
175 if (pager) { 175 if (pager) {
176 html(" ("); 176 html(" (");
177 cgit_log_link(ctx.qry.showmsg ? "Collapse" : "Expand", NULL, 177 cgit_log_link(ctx.qry.showmsg ? "Collapse" : "Expand", NULL,
178 NULL, ctx.qry.head, ctx.qry.sha1, 178 NULL, ctx.qry.head, ctx.qry.sha1,
179 ctx.qry.path, ctx.qry.ofs, ctx.qry.grep, 179 ctx.qry.path, ctx.qry.ofs, ctx.qry.grep,
180 ctx.qry.search, ctx.qry.showmsg ? 0 : 1); 180 ctx.qry.search, ctx.qry.showmsg ? 0 : 1);
181 html(")"); 181 html(")");
182 } 182 }
183 html("</th><th class='left'>Author</th>"); 183 html("</th><th class='left'>Author</th>");
184 if (ctx.repo->enable_log_filecount) { 184 if (ctx.repo->enable_log_filecount) {
185 html("<th class='left'>Files</th>"); 185 html("<th class='left'>Files</th>");
186 columns++; 186 columns++;
187 if (ctx.repo->enable_log_linecount) { 187 if (ctx.repo->enable_log_linecount) {
188 html("<th class='left'>Lines</th>"); 188 html("<th class='left'>Lines</th>");
189 columns++; 189 columns++;
190 } 190 }
191 } 191 }
192 html("</tr>\n"); 192 html("</tr>\n");
193 193
194 if (ofs<0) 194 if (ofs<0)
195 ofs = 0; 195 ofs = 0;
196 196
197 for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { 197 for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) {
198 free(commit->buffer); 198 free(commit->buffer);
199 commit->buffer = NULL; 199 commit->buffer = NULL;
200 free_commit_list(commit->parents); 200 free_commit_list(commit->parents);
201 commit->parents = NULL; 201 commit->parents = NULL;
202 } 202 }
203 203
204 for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { 204 for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) {
205 print_commit(commit); 205 print_commit(commit);
206 free(commit->buffer); 206 free(commit->buffer);
207 commit->buffer = NULL; 207 commit->buffer = NULL;
208 free_commit_list(commit->parents); 208 free_commit_list(commit->parents);
209 commit->parents = NULL; 209 commit->parents = NULL;
210 } 210 }
211 if (pager) { 211 if (pager) {
212 htmlf("</table><div class='pager'>", 212 htmlf("</table><div class='pager'>",
213 columns); 213 columns);
214 if (ofs > 0) { 214 if (ofs > 0) {
215 cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, 215 cgit_log_link("[prev]", NULL, NULL, ctx.qry.head,
216 ctx.qry.sha1, ctx.qry.path, 216 ctx.qry.sha1, ctx.qry.path,
217 ofs - cnt, ctx.qry.grep, 217 ofs - cnt, ctx.qry.grep,
218 ctx.qry.search, ctx.qry.showmsg); 218 ctx.qry.search, ctx.qry.showmsg);
219 html("&nbsp;"); 219 html("&nbsp;");
220 } 220 }
221 if ((commit = get_revision(&rev)) != NULL) { 221 if ((commit = get_revision(&rev)) != NULL) {
222 cgit_log_link("[next]", NULL, NULL, ctx.qry.head, 222 cgit_log_link("[next]", NULL, NULL, ctx.qry.head,
223 ctx.qry.sha1, ctx.qry.path, 223 ctx.qry.sha1, ctx.qry.path,
224 ofs + cnt, ctx.qry.grep, 224 ofs + cnt, ctx.qry.grep,
225 ctx.qry.search, ctx.qry.showmsg); 225 ctx.qry.search, ctx.qry.showmsg);
226 } 226 }
227 html("</div>"); 227 html("</div>");
228 } else if ((commit = get_revision(&rev)) != NULL) { 228 } else if ((commit = get_revision(&rev)) != NULL) {
229 html("<tr class='nohover'><td colspan='3'>"); 229 html("<tr class='nohover'><td colspan='3'>");
230 cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, NULL, 0, 230 cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, NULL, 0,
231 NULL, NULL, ctx.qry.showmsg); 231 NULL, NULL, ctx.qry.showmsg);
232 html("</td></tr>\n"); 232 html("</td></tr>\n");
233 } 233 }
234} 234}
diff --git a/ui-plain.c b/ui-plain.c
index 27c6dae..a4ce077 100644
--- a/ui-plain.c
+++ b/ui-plain.c
@@ -1,93 +1,94 @@
1/* ui-plain.c: functions for output of plain blobs by path 1/* ui-plain.c: functions for output of plain blobs by path
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
13char *curr_rev; 13char *curr_rev;
14char *match_path; 14char *match_path;
15int match; 15int match;
16 16
17static void print_object(const unsigned char *sha1, const char *path) 17static void print_object(const unsigned char *sha1, const char *path)
18{ 18{
19 enum object_type type; 19 enum object_type type;
20 char *buf, *ext; 20 char *buf, *ext;
21 unsigned long size; 21 unsigned long size;
22 struct string_list_item *mime; 22 struct string_list_item *mime;
23 23
24 type = sha1_object_info(sha1, &size); 24 type = sha1_object_info(sha1, &size);
25 if (type == OBJ_BAD) { 25 if (type == OBJ_BAD) {
26 html_status(404, "Not found", 0); 26 html_status(404, "Not found", 0);
27 return; 27 return;
28 } 28 }
29 29
30 buf = read_sha1_file(sha1, &type, &size); 30 buf = read_sha1_file(sha1, &type, &size);
31 if (!buf) { 31 if (!buf) {
32 html_status(404, "Not found", 0); 32 html_status(404, "Not found", 0);
33 return; 33 return;
34 } 34 }
35 ctx.page.mimetype = NULL; 35 ctx.page.mimetype = NULL;
36 ext = strrchr(path, '.'); 36 ext = strrchr(path, '.');
37 if (ext && *(++ext)) { 37 if (ext && *(++ext)) {
38 mime = string_list_lookup(ext, &ctx.cfg.mimetypes); 38 mime = string_list_lookup(ext, &ctx.cfg.mimetypes);
39 if (mime) 39 if (mime)
40 ctx.page.mimetype = (char *)mime->util; 40 ctx.page.mimetype = (char *)mime->util;
41 } 41 }
42 if (!ctx.page.mimetype) { 42 if (!ctx.page.mimetype) {
43 if (buffer_is_binary(buf, size)) 43 if (buffer_is_binary(buf, size))
44 ctx.page.mimetype = "application/octet-stream"; 44 ctx.page.mimetype = "application/octet-stream";
45 else 45 else
46 ctx.page.mimetype = "text/plain"; 46 ctx.page.mimetype = "text/plain";
47 } 47 }
48 ctx.page.filename = fmt("%s", path); 48 ctx.page.filename = fmt("%s", path);
49 ctx.page.size = size; 49 ctx.page.size = size;
50 ctx.page.etag = sha1_to_hex(sha1); 50 ctx.page.etag = sha1_to_hex(sha1);
51 cgit_print_http_headers(&ctx); 51 cgit_print_http_headers(&ctx);
52 html_raw(buf, size); 52 html_raw(buf, size);
53 match = 1; 53 match = 1;
54} 54}
55 55
56static int walk_tree(const unsigned char *sha1, const char *base, int baselen, 56static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
57 const char *pathname, unsigned mode, int stage, 57 const char *pathname, unsigned mode, int stage,
58 void *cbdata) 58 void *cbdata)
59{ 59{
60 if (S_ISDIR(mode)) 60 if (S_ISDIR(mode))
61 return READ_TREE_RECURSIVE; 61 return READ_TREE_RECURSIVE;
62 62
63 if (S_ISREG(mode)) 63 if (S_ISREG(mode) && !strncmp(base, match_path, baselen) &&
64 !strcmp(pathname, match_path + baselen))
64 print_object(sha1, pathname); 65 print_object(sha1, pathname);
65 66
66 return 0; 67 return 0;
67} 68}
68 69
69void cgit_print_plain(struct cgit_context *ctx) 70void cgit_print_plain(struct cgit_context *ctx)
70{ 71{
71 const char *rev = ctx->qry.sha1; 72 const char *rev = ctx->qry.sha1;
72 unsigned char sha1[20]; 73 unsigned char sha1[20];
73 struct commit *commit; 74 struct commit *commit;
74 const char *paths[] = {ctx->qry.path, NULL}; 75 const char *paths[] = {ctx->qry.path, NULL};
75 76
76 if (!rev) 77 if (!rev)
77 rev = ctx->qry.head; 78 rev = ctx->qry.head;
78 79
79 curr_rev = xstrdup(rev); 80 curr_rev = xstrdup(rev);
80 if (get_sha1(rev, sha1)) { 81 if (get_sha1(rev, sha1)) {
81 html_status(404, "Not found", 0); 82 html_status(404, "Not found", 0);
82 return; 83 return;
83 } 84 }
84 commit = lookup_commit_reference(sha1); 85 commit = lookup_commit_reference(sha1);
85 if (!commit || parse_commit(commit)) { 86 if (!commit || parse_commit(commit)) {
86 html_status(404, "Not found", 0); 87 html_status(404, "Not found", 0);
87 return; 88 return;
88 } 89 }
89 match_path = ctx->qry.path; 90 match_path = ctx->qry.path;
90 read_tree_recursive(commit->tree, NULL, 0, 0, paths, walk_tree, NULL); 91 read_tree_recursive(commit->tree, NULL, 0, 0, paths, walk_tree, NULL);
91 if (!match) 92 if (!match)
92 html_status(404, "Not found", 0); 93 html_status(404, "Not found", 0);
93} 94}