-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 29 | ||||
-rw-r--r-- | cgit.c | 3 | ||||
-rw-r--r-- | cgit.h | 2 | ||||
-rwxr-xr-x | gen-version.sh | 4 | ||||
-rw-r--r-- | shared.c | 2 | ||||
-rw-r--r-- | ui-shared.c | 2 |
7 files changed, 27 insertions, 16 deletions
@@ -1,4 +1,5 @@ | |||
1 | # Files I don't care to see in git-status/commit | 1 | # Files I don't care to see in git-status/commit |
2 | cgit | 2 | cgit |
3 | VERSION | ||
3 | *.o | 4 | *.o |
4 | *~ | 5 | *~ |
@@ -1,87 +1,94 @@ | |||
1 | CGIT_VERSION = 0.5 | ||
2 | |||
3 | prefix = /var/www/htdocs/cgit | 1 | prefix = /var/www/htdocs/cgit |
4 | |||
5 | SHA1_HEADER = <openssl/sha.h> | 2 | SHA1_HEADER = <openssl/sha.h> |
6 | CACHE_ROOT = /var/cache/cgit | 3 | CACHE_ROOT = /var/cache/cgit |
7 | CGIT_CONFIG = /etc/cgitrc | 4 | CGIT_CONFIG = /etc/cgitrc |
8 | CGIT_SCRIPT_NAME = cgit.cgi | 5 | CGIT_SCRIPT_NAME = cgit.cgi |
9 | 6 | ||
10 | # | 7 | # |
11 | # Let the user override the above settings. | 8 | # Let the user override the above settings. |
12 | # | 9 | # |
13 | -include cgit.conf | 10 | -include cgit.conf |
14 | 11 | ||
12 | |||
13 | CGIT_VERSION = 0.5 | ||
14 | |||
15 | all: cgit | ||
16 | |||
17 | VERSION: | ||
18 | gen-version.sh | ||
19 | |||
20 | -include VERSION | ||
21 | |||
22 | |||
15 | EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto | 23 | EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto |
16 | OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \ | 24 | OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \ |
17 | ui-summary.o ui-log.o ui-tree.o ui-commit.o ui-diff.o \ | 25 | ui-summary.o ui-log.o ui-tree.o ui-commit.o ui-diff.o \ |
18 | ui-snapshot.o ui-blob.o | 26 | ui-snapshot.o ui-blob.o |
19 | 27 | ||
20 | CFLAGS += -Wall | 28 | CFLAGS += -Wall |
21 | 29 | ||
22 | ifdef DEBUG | 30 | ifdef DEBUG |
23 | CFLAGS += -g | 31 | CFLAGS += -g |
24 | endif | 32 | endif |
25 | 33 | ||
26 | CFLAGS += -Igit | 34 | CFLAGS += -Igit |
27 | CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)' | 35 | CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)' |
28 | CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' | 36 | CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' |
29 | CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' | 37 | CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' |
30 | CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' | 38 | CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' |
31 | 39 | ||
32 | 40 | ||
33 | # | 41 | # |
34 | # If make is run on a nongit platform, get the git sources as a tarball. | 42 | # If make is run on a nongit platform, get the git sources as a tarball. |
35 | # | 43 | # |
36 | GITVER = $(shell git version 2>/dev/null || echo nogit) | 44 | GITVER = $(shell git version 2>/dev/null || echo nogit) |
37 | ifeq ($(GITVER),nogit) | 45 | ifeq ($(GITVER),nogit) |
38 | GITURL = http://www.kernel.org/pub/software/scm/git/git-1.5.2.tar.bz2 | 46 | GITURL = http://www.kernel.org/pub/software/scm/git/git-1.5.2.tar.bz2 |
39 | INITGIT = test -e git/git.c || ((curl "$(GITURL)" | tar -xj) && mv git-1.5.2 git) | 47 | INITGIT = test -e git/git.c || ((curl "$(GITURL)" | tar -xj) && mv git-1.5.2 git) |
40 | else | 48 | else |
41 | INITGIT = ./submodules.sh -i | 49 | INITGIT = ./submodules.sh -i |
42 | endif | 50 | endif |
43 | 51 | ||
44 | 52 | ||
45 | # | 53 | cgit: cgit.c cgit.h VERSION $(OBJECTS) |
46 | # basic build rules | ||
47 | # | ||
48 | all: cgit | ||
49 | |||
50 | cgit: cgit.c cgit.h $(OBJECTS) | ||
51 | $(CC) $(CFLAGS) cgit.c -o cgit $(OBJECTS) $(EXTLIBS) | 54 | $(CC) $(CFLAGS) cgit.c -o cgit $(OBJECTS) $(EXTLIBS) |
52 | 55 | ||
53 | $(OBJECTS): cgit.h git/libgit.a | 56 | $(OBJECTS): cgit.h git/libgit.a |
54 | 57 | ||
55 | git/libgit.a: | 58 | git/libgit.a: |
56 | $(INITGIT) | 59 | $(INITGIT) |
57 | $(MAKE) -C git | 60 | $(MAKE) -C git |
58 | 61 | ||
59 | # | 62 | # |
60 | # phony targets | 63 | # phony targets |
61 | # | 64 | # |
62 | install: all clean-cache | 65 | install: all clean-cache |
63 | mkdir -p $(prefix) | 66 | mkdir -p $(prefix) |
64 | install cgit $(prefix)/$(CGIT_SCRIPT_NAME) | 67 | install cgit $(prefix)/$(CGIT_SCRIPT_NAME) |
65 | install cgit.css $(prefix)/cgit.css | 68 | install cgit.css $(prefix)/cgit.css |
66 | 69 | ||
67 | clean-cgit: | 70 | clean-cgit: |
68 | rm -f cgit *.o | 71 | rm -f cgit VERSION *.o |
69 | 72 | ||
70 | distclean-cgit: clean-cgit | 73 | distclean-cgit: clean-cgit |
71 | git clean -d -x | 74 | git clean -d -x |
72 | 75 | ||
73 | clean-sub: | 76 | clean-sub: |
74 | $(MAKE) -C git clean | 77 | $(MAKE) -C git clean |
75 | 78 | ||
76 | distclean-sub: clean-sub | 79 | distclean-sub: clean-sub |
77 | $(shell cd git && git clean -d -x) | 80 | $(shell cd git && git clean -d -x) |
78 | 81 | ||
79 | clean-cache: | 82 | clean-cache: |
80 | rm -rf $(CACHE_ROOT)/* | 83 | rm -rf $(CACHE_ROOT)/* |
81 | 84 | ||
82 | clean: clean-cgit clean-sub | 85 | clean: clean-cgit clean-sub |
83 | 86 | ||
84 | distclean: distclean-cgit distclean-sub | 87 | distclean: distclean-cgit distclean-sub |
85 | 88 | ||
89 | version: clean-cgit | ||
90 | ./gen-version.sh | ||
91 | make | ||
92 | |||
86 | .PHONY: all install clean clean-cgit clean-sub clean-cache \ | 93 | .PHONY: all install clean clean-cgit clean-sub clean-cache \ |
87 | distclean distclean-cgit distclean-sub | 94 | distclean distclean-cgit distclean-sub release version |
@@ -1,37 +1,34 @@ | |||
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 | 10 | ||
11 | const char cgit_version[] = CGIT_VERSION; | ||
12 | |||
13 | |||
14 | static int cgit_prepare_cache(struct cacheitem *item) | 11 | static int cgit_prepare_cache(struct cacheitem *item) |
15 | { | 12 | { |
16 | if (!cgit_repo && cgit_query_repo) { | 13 | if (!cgit_repo && cgit_query_repo) { |
17 | char *title = fmt("%s - %s", cgit_root_title, "Bad request"); | 14 | char *title = fmt("%s - %s", cgit_root_title, "Bad request"); |
18 | cgit_print_docstart(title, item); | 15 | cgit_print_docstart(title, item); |
19 | cgit_print_pageheader(title, 0); | 16 | cgit_print_pageheader(title, 0); |
20 | cgit_print_error(fmt("Unknown repo: %s", cgit_query_repo)); | 17 | cgit_print_error(fmt("Unknown repo: %s", cgit_query_repo)); |
21 | cgit_print_docend(); | 18 | cgit_print_docend(); |
22 | return 0; | 19 | return 0; |
23 | } | 20 | } |
24 | 21 | ||
25 | if (!cgit_repo) { | 22 | if (!cgit_repo) { |
26 | item->name = xstrdup(fmt("%s/index.html", cgit_cache_root)); | 23 | item->name = xstrdup(fmt("%s/index.html", cgit_cache_root)); |
27 | item->ttl = cgit_cache_root_ttl; | 24 | item->ttl = cgit_cache_root_ttl; |
28 | return 1; | 25 | return 1; |
29 | } | 26 | } |
30 | 27 | ||
31 | if (!cgit_cmd) { | 28 | if (!cgit_cmd) { |
32 | item->name = xstrdup(fmt("%s/%s/index.html", cgit_cache_root, | 29 | item->name = xstrdup(fmt("%s/%s/index.html", cgit_cache_root, |
33 | cache_safe_filename(cgit_repo->url))); | 30 | cache_safe_filename(cgit_repo->url))); |
34 | item->ttl = cgit_cache_repo_ttl; | 31 | item->ttl = cgit_cache_repo_ttl; |
35 | } else { | 32 | } else { |
36 | item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root, | 33 | item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root, |
37 | cache_safe_filename(cgit_repo->url), cgit_query_page, | 34 | cache_safe_filename(cgit_repo->url), cgit_query_page, |
@@ -77,49 +77,49 @@ struct repolist { | |||
77 | int length; | 77 | int length; |
78 | int count; | 78 | int count; |
79 | struct repoinfo *repos; | 79 | struct repoinfo *repos; |
80 | }; | 80 | }; |
81 | 81 | ||
82 | struct commitinfo { | 82 | struct commitinfo { |
83 | struct commit *commit; | 83 | struct commit *commit; |
84 | char *author; | 84 | char *author; |
85 | char *author_email; | 85 | char *author_email; |
86 | unsigned long author_date; | 86 | unsigned long author_date; |
87 | char *committer; | 87 | char *committer; |
88 | char *committer_email; | 88 | char *committer_email; |
89 | unsigned long committer_date; | 89 | unsigned long committer_date; |
90 | char *subject; | 90 | char *subject; |
91 | char *msg; | 91 | char *msg; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | struct taginfo { | 94 | struct taginfo { |
95 | char *tagger; | 95 | char *tagger; |
96 | char *tagger_email; | 96 | char *tagger_email; |
97 | int tagger_date; | 97 | int tagger_date; |
98 | char *msg; | 98 | char *msg; |
99 | }; | 99 | }; |
100 | 100 | ||
101 | extern const char cgit_version[]; | 101 | extern const char *cgit_version; |
102 | 102 | ||
103 | extern struct repolist cgit_repolist; | 103 | extern struct repolist cgit_repolist; |
104 | extern struct repoinfo *cgit_repo; | 104 | extern struct repoinfo *cgit_repo; |
105 | extern int cgit_cmd; | 105 | extern int cgit_cmd; |
106 | 106 | ||
107 | extern char *cgit_root_title; | 107 | extern char *cgit_root_title; |
108 | extern char *cgit_css; | 108 | extern char *cgit_css; |
109 | extern char *cgit_logo; | 109 | extern char *cgit_logo; |
110 | extern char *cgit_index_header; | 110 | extern char *cgit_index_header; |
111 | extern char *cgit_logo_link; | 111 | extern char *cgit_logo_link; |
112 | extern char *cgit_module_link; | 112 | extern char *cgit_module_link; |
113 | extern char *cgit_agefile; | 113 | extern char *cgit_agefile; |
114 | extern char *cgit_virtual_root; | 114 | extern char *cgit_virtual_root; |
115 | extern char *cgit_script_name; | 115 | extern char *cgit_script_name; |
116 | extern char *cgit_cache_root; | 116 | extern char *cgit_cache_root; |
117 | extern char *cgit_repo_group; | 117 | extern char *cgit_repo_group; |
118 | 118 | ||
119 | extern int cgit_nocache; | 119 | extern int cgit_nocache; |
120 | extern int cgit_snapshots; | 120 | extern int cgit_snapshots; |
121 | extern int cgit_enable_log_filecount; | 121 | extern int cgit_enable_log_filecount; |
122 | extern int cgit_enable_log_linecount; | 122 | extern int cgit_enable_log_linecount; |
123 | extern int cgit_max_lock_attempts; | 123 | extern int cgit_max_lock_attempts; |
124 | extern int cgit_cache_root_ttl; | 124 | extern int cgit_cache_root_ttl; |
125 | extern int cgit_cache_repo_ttl; | 125 | extern int cgit_cache_repo_ttl; |
diff --git a/gen-version.sh b/gen-version.sh new file mode 100755 index 0000000..4c60f60 --- a/dev/null +++ b/gen-version.sh | |||
@@ -0,0 +1,4 @@ | |||
1 | v=$(git-describe --abbrev=4 HEAD | sed -e 's/-/./g') | ||
2 | test -z "$v" && exit 1 | ||
3 | echo "CGIT_VERSION = $v" | ||
4 | echo "CGIT_VERSION = $v" > VERSION | ||
@@ -1,38 +1,40 @@ | |||
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 | ||
11 | struct repolist cgit_repolist; | 11 | struct repolist cgit_repolist; |
12 | struct repoinfo *cgit_repo; | 12 | struct repoinfo *cgit_repo; |
13 | int cgit_cmd; | 13 | int cgit_cmd; |
14 | 14 | ||
15 | const char *cgit_version = CGIT_VERSION; | ||
16 | |||
15 | char *cgit_root_title = "Git repository browser"; | 17 | char *cgit_root_title = "Git repository browser"; |
16 | char *cgit_css = "/cgit.css"; | 18 | char *cgit_css = "/cgit.css"; |
17 | char *cgit_logo = "/git-logo.png"; | 19 | char *cgit_logo = "/git-logo.png"; |
18 | char *cgit_index_header = NULL; | 20 | char *cgit_index_header = NULL; |
19 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; | 21 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; |
20 | char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; | 22 | char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; |
21 | char *cgit_agefile = "info/web/last-modified"; | 23 | char *cgit_agefile = "info/web/last-modified"; |
22 | char *cgit_virtual_root = NULL; | 24 | char *cgit_virtual_root = NULL; |
23 | char *cgit_script_name = CGIT_SCRIPT_NAME; | 25 | char *cgit_script_name = CGIT_SCRIPT_NAME; |
24 | char *cgit_cache_root = "/var/cache/cgit"; | 26 | char *cgit_cache_root = "/var/cache/cgit"; |
25 | char *cgit_repo_group = NULL; | 27 | char *cgit_repo_group = NULL; |
26 | 28 | ||
27 | int cgit_nocache = 0; | 29 | int cgit_nocache = 0; |
28 | int cgit_snapshots = 0; | 30 | int cgit_snapshots = 0; |
29 | int cgit_enable_log_filecount = 0; | 31 | int cgit_enable_log_filecount = 0; |
30 | int cgit_enable_log_linecount = 0; | 32 | int cgit_enable_log_linecount = 0; |
31 | int cgit_max_lock_attempts = 5; | 33 | int cgit_max_lock_attempts = 5; |
32 | int cgit_cache_root_ttl = 5; | 34 | int cgit_cache_root_ttl = 5; |
33 | int cgit_cache_repo_ttl = 5; | 35 | int cgit_cache_repo_ttl = 5; |
34 | int cgit_cache_dynamic_ttl = 5; | 36 | int cgit_cache_dynamic_ttl = 5; |
35 | int cgit_cache_static_ttl = -1; | 37 | int cgit_cache_static_ttl = -1; |
36 | int cgit_cache_max_create_time = 5; | 38 | int cgit_cache_max_create_time = 5; |
37 | int cgit_summary_log = 0; | 39 | int cgit_summary_log = 0; |
38 | 40 | ||
diff --git a/ui-shared.c b/ui-shared.c index 15d8254..110c696 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -241,49 +241,49 @@ void cgit_print_age(time_t t, time_t max_relative, char *format) | |||
241 | return; | 241 | return; |
242 | } | 242 | } |
243 | if (secs < TM_YEAR * 2) { | 243 | if (secs < TM_YEAR * 2) { |
244 | htmlf("<span class='age-months'>%.0f months</span>", | 244 | htmlf("<span class='age-months'>%.0f months</span>", |
245 | secs * 1.0 / TM_MONTH); | 245 | secs * 1.0 / TM_MONTH); |
246 | return; | 246 | return; |
247 | } | 247 | } |
248 | htmlf("<span class='age-years'>%.0f years</span>", | 248 | htmlf("<span class='age-years'>%.0f years</span>", |
249 | secs * 1.0 / TM_YEAR); | 249 | secs * 1.0 / TM_YEAR); |
250 | } | 250 | } |
251 | 251 | ||
252 | void cgit_print_docstart(char *title, struct cacheitem *item) | 252 | void cgit_print_docstart(char *title, struct cacheitem *item) |
253 | { | 253 | { |
254 | html("Content-Type: text/html; charset=utf-8\n"); | 254 | html("Content-Type: text/html; charset=utf-8\n"); |
255 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); | 255 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); |
256 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + | 256 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + |
257 | ttl_seconds(item->ttl))); | 257 | ttl_seconds(item->ttl))); |
258 | html("\n"); | 258 | html("\n"); |
259 | html(cgit_doctype); | 259 | html(cgit_doctype); |
260 | html("<html>\n"); | 260 | html("<html>\n"); |
261 | html("<head>\n"); | 261 | html("<head>\n"); |
262 | html("<title>"); | 262 | html("<title>"); |
263 | html_txt(title); | 263 | html_txt(title); |
264 | html("</title>\n"); | 264 | html("</title>\n"); |
265 | htmlf("<meta name='generator' content='cgit v%s'/>\n", cgit_version); | 265 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); |
266 | html("<link rel='stylesheet' type='text/css' href='"); | 266 | html("<link rel='stylesheet' type='text/css' href='"); |
267 | html_attr(cgit_css); | 267 | html_attr(cgit_css); |
268 | html("'/>\n"); | 268 | html("'/>\n"); |
269 | html("</head>\n"); | 269 | html("</head>\n"); |
270 | html("<body>\n"); | 270 | html("<body>\n"); |
271 | } | 271 | } |
272 | 272 | ||
273 | void cgit_print_docend() | 273 | void cgit_print_docend() |
274 | { | 274 | { |
275 | html("</td></tr></table>"); | 275 | html("</td></tr></table>"); |
276 | html("</body>\n</html>\n"); | 276 | html("</body>\n</html>\n"); |
277 | } | 277 | } |
278 | 278 | ||
279 | void cgit_print_pageheader(char *title, int show_search) | 279 | void cgit_print_pageheader(char *title, int show_search) |
280 | { | 280 | { |
281 | html("<table id='layout'>"); | 281 | html("<table id='layout'>"); |
282 | html("<tr><td id='header'>"); | 282 | html("<tr><td id='header'>"); |
283 | html(cgit_root_title); | 283 | html(cgit_root_title); |
284 | html("</td><td id='logo'>"); | 284 | html("</td><td id='logo'>"); |
285 | html("<a href='"); | 285 | html("<a href='"); |
286 | html_attr(cgit_logo_link); | 286 | html_attr(cgit_logo_link); |
287 | htmlf("'><img src='%s' alt='logo'/></a>", cgit_logo); | 287 | htmlf("'><img src='%s' alt='logo'/></a>", cgit_logo); |
288 | html("</td></tr>"); | 288 | html("</td></tr>"); |
289 | html("<tr><td id='crumb'>"); | 289 | html("<tr><td id='crumb'>"); |