|
diff --git a/Makefile b/Makefile index d95a5a3..7857b8e 100644 --- a/ Makefile+++ b/ Makefile |
|
@@ -1,71 +1,72 @@ |
1 | CGIT_VERSION = v0.6 |
1 | CGIT_VERSION = v0.6 |
2 | CGIT_SCRIPT_NAME = cgit.cgi |
2 | CGIT_SCRIPT_NAME = cgit.cgi |
3 | CGIT_SCRIPT_PATH = /var/www/htdocs/cgit |
3 | CGIT_SCRIPT_PATH = /var/www/htdocs/cgit |
4 | CGIT_CONFIG = /etc/cgitrc |
4 | CGIT_CONFIG = /etc/cgitrc |
5 | CACHE_ROOT = /var/cache/cgit |
5 | CACHE_ROOT = /var/cache/cgit |
6 | SHA1_HEADER = <openssl/sha.h> |
6 | SHA1_HEADER = <openssl/sha.h> |
7 | GIT_VER = 1.5.3 |
7 | GIT_VER = 1.5.3 |
8 | GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 |
8 | GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 |
9 | |
9 | |
10 | # |
10 | # |
11 | # Let the user override the above settings. |
11 | # Let the user override the above settings. |
12 | # |
12 | # |
13 | -include cgit.conf |
13 | -include cgit.conf |
14 | |
14 | |
15 | |
15 | |
16 | EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto |
16 | EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto |
17 | OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \ |
17 | OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \ |
18 | ui-summary.o ui-log.o ui-tree.o ui-commit.o ui-diff.o \ |
18 | ui-summary.o ui-log.o ui-tree.o ui-commit.o ui-diff.o \ |
19 | ui-snapshot.o ui-blob.o ui-tag.o |
19 | ui-snapshot.o ui-blob.o ui-tag.o |
20 | |
20 | |
21 | |
21 | |
22 | .PHONY: all git install clean distclean force-version get-git |
22 | .PHONY: all git install clean distclean force-version get-git |
23 | |
23 | |
24 | all: cgit git |
24 | all: cgit git |
25 | |
25 | |
26 | VERSION: force-version |
26 | VERSION: force-version |
27 | @./gen-version.sh "$(CGIT_VERSION)" |
27 | @./gen-version.sh "$(CGIT_VERSION)" |
28 | -include VERSION |
28 | -include VERSION |
29 | |
29 | |
30 | |
30 | |
31 | CFLAGS += -g -Wall -Igit |
31 | CFLAGS += -g -Wall -Igit |
32 | CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)' |
32 | CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)' |
33 | CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' |
33 | CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' |
34 | CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' |
34 | CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' |
35 | CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' |
35 | CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' |
| |
36 | CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"' |
36 | |
37 | |
37 | |
38 | |
38 | cgit: cgit.c $(OBJECTS) |
39 | cgit: cgit.c $(OBJECTS) |
39 | $(CC) $(CFLAGS) cgit.c -o cgit $(OBJECTS) $(EXTLIBS) |
40 | $(CC) $(CFLAGS) cgit.c -o cgit $(OBJECTS) $(EXTLIBS) |
40 | |
41 | |
41 | $(OBJECTS): cgit.h git/xdiff/lib.a git/libgit.a VERSION |
42 | $(OBJECTS): cgit.h git/xdiff/lib.a git/libgit.a VERSION |
42 | |
43 | |
43 | git/xdiff/lib.a: | git |
44 | git/xdiff/lib.a: | git |
44 | |
45 | |
45 | git/libgit.a: | git |
46 | git/libgit.a: | git |
46 | |
47 | |
47 | git: |
48 | git: |
48 | cd git && $(MAKE) xdiff/lib.a |
49 | cd git && $(MAKE) xdiff/lib.a |
49 | cd git && $(MAKE) libgit.a |
50 | cd git && $(MAKE) libgit.a |
50 | |
51 | |
51 | install: all |
52 | install: all |
52 | mkdir -p $(DESTDIR)$(CGIT_SCRIPT_PATH) |
53 | mkdir -p $(DESTDIR)$(CGIT_SCRIPT_PATH) |
53 | install cgit $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME) |
54 | install cgit $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME) |
54 | install cgit.css $(DESTDIR)$(CGIT_SCRIPT_PATH)/cgit.css |
55 | install cgit.css $(DESTDIR)$(CGIT_SCRIPT_PATH)/cgit.css |
55 | rm -rf $(DESTDIR)$(CACHE_ROOT)/* |
56 | rm -rf $(DESTDIR)$(CACHE_ROOT)/* |
56 | |
57 | |
57 | uninstall: |
58 | uninstall: |
58 | rm -f $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME) |
59 | rm -f $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME) |
59 | rm -f $(DESTDIR)$(CGIT_SCRIPT_PATH)/cgit.css |
60 | rm -f $(DESTDIR)$(CGIT_SCRIPT_PATH)/cgit.css |
60 | rm -rf $(DESTDIR)$(CACHE_ROOT) |
61 | rm -rf $(DESTDIR)$(CACHE_ROOT) |
61 | |
62 | |
62 | clean: |
63 | clean: |
63 | rm -f cgit VERSION *.o |
64 | rm -f cgit VERSION *.o |
64 | cd git && $(MAKE) clean |
65 | cd git && $(MAKE) clean |
65 | |
66 | |
66 | distclean: clean |
67 | distclean: clean |
67 | git clean -d -x |
68 | git clean -d -x |
68 | cd git && git clean -d -x |
69 | cd git && git clean -d -x |
69 | |
70 | |
70 | get-git: |
71 | get-git: |
71 | curl $(GIT_URL) | tar -xj && rm -rf git && mv git-$(GIT_VER) git |
72 | curl $(GIT_URL) | tar -xj && rm -rf git && mv git-$(GIT_VER) git |
|
|
diff --git a/shared.c b/shared.c index cd9d68d..1cd60a2 100644 --- a/ shared.c+++ b/ shared.c |
|
@@ -1,90 +1,90 @@ |
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; |
15 | const char *cgit_version = CGIT_VERSION; |
16 | |
16 | |
17 | char *cgit_root_title = "Git repository browser"; |
17 | char *cgit_root_title = "Git repository browser"; |
18 | char *cgit_css = "/cgit.css"; |
18 | char *cgit_css = "/cgit.css"; |
19 | char *cgit_logo = "/git-logo.png"; |
19 | char *cgit_logo = "/git-logo.png"; |
20 | char *cgit_index_header = NULL; |
20 | char *cgit_index_header = NULL; |
21 | 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/"; |
22 | char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; |
22 | char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; |
23 | char *cgit_agefile = "info/web/last-modified"; |
23 | char *cgit_agefile = "info/web/last-modified"; |
24 | char *cgit_virtual_root = NULL; |
24 | char *cgit_virtual_root = NULL; |
25 | char *cgit_script_name = CGIT_SCRIPT_NAME; |
25 | char *cgit_script_name = CGIT_SCRIPT_NAME; |
26 | char *cgit_cache_root = "/var/cache/cgit"; |
26 | char *cgit_cache_root = CGIT_CACHE_ROOT; |
27 | char *cgit_repo_group = NULL; |
27 | char *cgit_repo_group = NULL; |
28 | |
28 | |
29 | int cgit_nocache = 0; |
29 | int cgit_nocache = 0; |
30 | int cgit_snapshots = 0; |
30 | int cgit_snapshots = 0; |
31 | int cgit_enable_index_links = 0; |
31 | int cgit_enable_index_links = 0; |
32 | int cgit_enable_log_filecount = 0; |
32 | int cgit_enable_log_filecount = 0; |
33 | int cgit_enable_log_linecount = 0; |
33 | int cgit_enable_log_linecount = 0; |
34 | int cgit_max_lock_attempts = 5; |
34 | int cgit_max_lock_attempts = 5; |
35 | int cgit_cache_root_ttl = 5; |
35 | int cgit_cache_root_ttl = 5; |
36 | int cgit_cache_repo_ttl = 5; |
36 | int cgit_cache_repo_ttl = 5; |
37 | int cgit_cache_dynamic_ttl = 5; |
37 | int cgit_cache_dynamic_ttl = 5; |
38 | int cgit_cache_static_ttl = -1; |
38 | int cgit_cache_static_ttl = -1; |
39 | int cgit_cache_max_create_time = 5; |
39 | int cgit_cache_max_create_time = 5; |
40 | int cgit_summary_log = 0; |
40 | int cgit_summary_log = 0; |
41 | |
41 | |
42 | int cgit_max_msg_len = 60; |
42 | int cgit_max_msg_len = 60; |
43 | int cgit_max_repodesc_len = 60; |
43 | int cgit_max_repodesc_len = 60; |
44 | int cgit_max_commit_count = 50; |
44 | int cgit_max_commit_count = 50; |
45 | |
45 | |
46 | int cgit_query_has_symref = 0; |
46 | int cgit_query_has_symref = 0; |
47 | int cgit_query_has_sha1 = 0; |
47 | int cgit_query_has_sha1 = 0; |
48 | |
48 | |
49 | char *cgit_querystring = NULL; |
49 | char *cgit_querystring = NULL; |
50 | char *cgit_query_repo = NULL; |
50 | char *cgit_query_repo = NULL; |
51 | char *cgit_query_page = NULL; |
51 | char *cgit_query_page = NULL; |
52 | char *cgit_query_head = NULL; |
52 | char *cgit_query_head = NULL; |
53 | char *cgit_query_search = NULL; |
53 | char *cgit_query_search = NULL; |
54 | char *cgit_query_sha1 = NULL; |
54 | char *cgit_query_sha1 = NULL; |
55 | char *cgit_query_sha2 = NULL; |
55 | char *cgit_query_sha2 = NULL; |
56 | char *cgit_query_path = NULL; |
56 | char *cgit_query_path = NULL; |
57 | char *cgit_query_name = NULL; |
57 | char *cgit_query_name = NULL; |
58 | int cgit_query_ofs = 0; |
58 | int cgit_query_ofs = 0; |
59 | |
59 | |
60 | int htmlfd = 0; |
60 | int htmlfd = 0; |
61 | |
61 | |
62 | |
62 | |
63 | int cgit_get_cmd_index(const char *cmd) |
63 | int cgit_get_cmd_index(const char *cmd) |
64 | { |
64 | { |
65 | static char *cmds[] = {"log", "commit", "diff", "tree", "blob", |
65 | static char *cmds[] = {"log", "commit", "diff", "tree", "blob", |
66 | "snapshot", "tag", NULL}; |
66 | "snapshot", "tag", NULL}; |
67 | int i; |
67 | int i; |
68 | |
68 | |
69 | for(i = 0; cmds[i]; i++) |
69 | for(i = 0; cmds[i]; i++) |
70 | if (!strcmp(cmd, cmds[i])) |
70 | if (!strcmp(cmd, cmds[i])) |
71 | return i + 1; |
71 | return i + 1; |
72 | return 0; |
72 | return 0; |
73 | } |
73 | } |
74 | |
74 | |
75 | int chk_zero(int result, char *msg) |
75 | int chk_zero(int result, char *msg) |
76 | { |
76 | { |
77 | if (result != 0) |
77 | if (result != 0) |
78 | die("%s: %s", msg, strerror(errno)); |
78 | die("%s: %s", msg, strerror(errno)); |
79 | return result; |
79 | return result; |
80 | } |
80 | } |
81 | |
81 | |
82 | int chk_positive(int result, char *msg) |
82 | int chk_positive(int result, char *msg) |
83 | { |
83 | { |
84 | if (result <= 0) |
84 | if (result <= 0) |
85 | die("%s: %s", msg, strerror(errno)); |
85 | die("%s: %s", msg, strerror(errno)); |
86 | return result; |
86 | return result; |
87 | } |
87 | } |
88 | |
88 | |
89 | int chk_non_negative(int result, char *msg) |
89 | int chk_non_negative(int result, char *msg) |
90 | { |
90 | { |
|