author | Lars Hjemli <hjemli@gmail.com> | 2007-02-03 14:02:55 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-02-04 20:47:46 (UTC) |
commit | ce1c7336e5b3e3ebe8f8c9029c405aedec98c208 (patch) (unidiff) | |
tree | b51a59a9552b32519cf694c0f5dc68c5a739069c | |
parent | ebd7b0fbc378e9beca0b275c5cd9150c930bde56 (diff) | |
download | cgit-ce1c7336e5b3e3ebe8f8c9029c405aedec98c208.zip cgit-ce1c7336e5b3e3ebe8f8c9029c405aedec98c208.tar.gz cgit-ce1c7336e5b3e3ebe8f8c9029c405aedec98c208.tar.bz2 |
Read repo-info from /etc/cgitrc
This makes cgit read all repo-info from the configfile, instead of scanning for
possible git-dirs below a common root path. This is primarily done to get
better security (separate physical path from logical repo-name).
In /etc/cgitrc each repo is registered with the following keys:
repo.url
repo.name
repo.path
repo.desc
repo.owner
Note:
*Required keys are repo.url and repo.path, all others are optional
*Each occurrence of repo.url starts a new repository registration
*Default value for repo.name is taken from repo.url
*The value of repo.url cannot contain characters with special meaning for
urls (i.e. one of /?%&), while repo.name can contain anything.
Example:
repo.url=cgit-pub
repo.name=cgit/public
repo.path=/pub/git/cgit
repo.desc=My public cgit repo
repo.owner=Lars Hjemli
repo.url=cgit-priv
repo.name=cgit/private
repo.path=/home/larsh/src/cgit/.git
repo.desc=My private cgit repo
repo.owner=Lars Hjemli
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.c | 64 | ||||
-rw-r--r-- | cgit.h | 18 | ||||
-rw-r--r-- | cgitrc | 13 | ||||
-rw-r--r-- | shared.c | 41 | ||||
-rw-r--r-- | ui-repolist.c | 39 |
5 files changed, 120 insertions, 55 deletions
@@ -1,185 +1,219 @@ | |||
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; | 11 | const char cgit_version[] = CGIT_VERSION; |
12 | 12 | ||
13 | static void cgit_prepare_cache(struct cacheitem *item) | 13 | |
14 | static struct repoinfo *cgit_get_repoinfo(char *url) | ||
15 | { | ||
16 | int i; | ||
17 | struct repoinfo *repo; | ||
18 | |||
19 | for (i=0; i<cgit_repolist.count; i++) { | ||
20 | repo = &cgit_repolist.repos[i]; | ||
21 | if (!strcmp(repo->url, url)) | ||
22 | return repo; | ||
23 | } | ||
24 | return NULL; | ||
25 | } | ||
26 | |||
27 | |||
28 | static int cgit_prepare_cache(struct cacheitem *item) | ||
14 | { | 29 | { |
15 | if (!cgit_query_repo) { | 30 | if (!cgit_query_repo) { |
16 | item->name = xstrdup(fmt("%s/index.html", cgit_cache_root)); | 31 | item->name = xstrdup(fmt("%s/index.html", cgit_cache_root)); |
17 | item->ttl = cgit_cache_root_ttl; | 32 | item->ttl = cgit_cache_root_ttl; |
18 | } else if (!cgit_query_page) { | 33 | return 1; |
34 | } | ||
35 | cgit_repo = cgit_get_repoinfo(cgit_query_repo); | ||
36 | if (!cgit_repo) { | ||
37 | char *title = fmt("%s - %s", cgit_root_title, "Bad request"); | ||
38 | cgit_print_docstart(title, item); | ||
39 | cgit_print_pageheader(title, 0); | ||
40 | cgit_print_error(fmt("Unknown repo: %s", cgit_query_repo)); | ||
41 | cgit_print_docend(); | ||
42 | return 0; | ||
43 | } | ||
44 | |||
45 | if (!cgit_query_page) { | ||
19 | item->name = xstrdup(fmt("%s/%s/index.html", cgit_cache_root, | 46 | item->name = xstrdup(fmt("%s/%s/index.html", cgit_cache_root, |
20 | cgit_query_repo)); | 47 | cgit_repo->url)); |
21 | item->ttl = cgit_cache_repo_ttl; | 48 | item->ttl = cgit_cache_repo_ttl; |
22 | } else { | 49 | } else { |
23 | item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root, | 50 | item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root, |
24 | cgit_query_repo, cgit_query_page, | 51 | cgit_repo->url, cgit_query_page, |
25 | cache_safe_filename(cgit_querystring))); | 52 | cache_safe_filename(cgit_querystring))); |
26 | if (cgit_query_has_symref) | 53 | if (cgit_query_has_symref) |
27 | item->ttl = cgit_cache_dynamic_ttl; | 54 | item->ttl = cgit_cache_dynamic_ttl; |
28 | else if (cgit_query_has_sha1) | 55 | else if (cgit_query_has_sha1) |
29 | item->ttl = cgit_cache_static_ttl; | 56 | item->ttl = cgit_cache_static_ttl; |
30 | else | 57 | else |
31 | item->ttl = cgit_cache_repo_ttl; | 58 | item->ttl = cgit_cache_repo_ttl; |
32 | } | 59 | } |
60 | return 1; | ||
33 | } | 61 | } |
34 | 62 | ||
35 | static void cgit_print_repo_page(struct cacheitem *item) | 63 | static void cgit_print_repo_page(struct cacheitem *item) |
36 | { | 64 | { |
37 | if (chdir(fmt("%s/%s", cgit_root, cgit_query_repo)) || | 65 | char *title; |
38 | cgit_read_config("info/cgit", cgit_repo_config_cb)) { | 66 | int show_search; |
39 | char *title = fmt("%s - %s", cgit_root_title, "Bad request"); | 67 | |
68 | if (chdir(cgit_repo->path)) { | ||
69 | title = fmt("%s - %s", cgit_root_title, "Bad request"); | ||
40 | cgit_print_docstart(title, item); | 70 | cgit_print_docstart(title, item); |
41 | cgit_print_pageheader(title, 0); | 71 | cgit_print_pageheader(title, 0); |
42 | cgit_print_error(fmt("Unable to scan repository: %s", | 72 | cgit_print_error(fmt("Unable to scan repository: %s", |
43 | strerror(errno))); | 73 | strerror(errno))); |
44 | cgit_print_docend(); | 74 | cgit_print_docend(); |
45 | return; | 75 | return; |
46 | } | 76 | } |
47 | setenv("GIT_DIR", fmt("%s/%s", cgit_root, cgit_query_repo), 1); | 77 | |
48 | char *title = fmt("%s - %s", cgit_repo_name, cgit_repo_desc); | 78 | title = fmt("%s - %s", cgit_repo->name, cgit_repo->desc); |
49 | int show_search = 0; | 79 | show_search = 0; |
80 | setenv("GIT_DIR", cgit_repo->path, 1); | ||
50 | if (cgit_query_page && !strcmp(cgit_query_page, "log")) | 81 | if (cgit_query_page && !strcmp(cgit_query_page, "log")) |
51 | show_search = 1; | 82 | show_search = 1; |
52 | cgit_print_docstart(title, item); | 83 | cgit_print_docstart(title, item); |
53 | cgit_print_pageheader(title, show_search); | 84 | cgit_print_pageheader(title, show_search); |
54 | if (!cgit_query_page) { | 85 | if (!cgit_query_page) { |
55 | cgit_print_summary(); | 86 | cgit_print_summary(); |
56 | } else if (!strcmp(cgit_query_page, "log")) { | 87 | } else if (!strcmp(cgit_query_page, "log")) { |
57 | cgit_print_log(cgit_query_head, cgit_query_ofs, 100, cgit_query_search); | 88 | cgit_print_log(cgit_query_head, cgit_query_ofs, 100, cgit_query_search); |
58 | } else if (!strcmp(cgit_query_page, "tree")) { | 89 | } else if (!strcmp(cgit_query_page, "tree")) { |
59 | cgit_print_tree(cgit_query_sha1, cgit_query_path); | 90 | cgit_print_tree(cgit_query_sha1, cgit_query_path); |
60 | } else if (!strcmp(cgit_query_page, "commit")) { | 91 | } else if (!strcmp(cgit_query_page, "commit")) { |
61 | cgit_print_commit(cgit_query_sha1); | 92 | cgit_print_commit(cgit_query_sha1); |
62 | } else if (!strcmp(cgit_query_page, "view")) { | 93 | } else if (!strcmp(cgit_query_page, "view")) { |
63 | cgit_print_view(cgit_query_sha1); | 94 | cgit_print_view(cgit_query_sha1); |
64 | } else if (!strcmp(cgit_query_page, "diff")) { | 95 | } else if (!strcmp(cgit_query_page, "diff")) { |
65 | cgit_print_diff(cgit_query_sha1, cgit_query_sha2); | 96 | cgit_print_diff(cgit_query_sha1, cgit_query_sha2); |
66 | } | 97 | } |
67 | cgit_print_docend(); | 98 | cgit_print_docend(); |
68 | } | 99 | } |
69 | 100 | ||
70 | static void cgit_fill_cache(struct cacheitem *item) | 101 | static void cgit_fill_cache(struct cacheitem *item) |
71 | { | 102 | { |
72 | static char buf[PATH_MAX]; | 103 | static char buf[PATH_MAX]; |
73 | 104 | ||
74 | getcwd(buf, sizeof(buf)); | 105 | getcwd(buf, sizeof(buf)); |
75 | htmlfd = item->fd; | 106 | htmlfd = item->fd; |
76 | item->st.st_mtime = time(NULL); | 107 | item->st.st_mtime = time(NULL); |
77 | if (cgit_query_repo) | 108 | if (cgit_query_repo) |
78 | cgit_print_repo_page(item); | 109 | cgit_print_repo_page(item); |
79 | else | 110 | else |
80 | cgit_print_repolist(item); | 111 | cgit_print_repolist(item); |
81 | chdir(buf); | 112 | chdir(buf); |
82 | } | 113 | } |
83 | 114 | ||
84 | static void cgit_check_cache(struct cacheitem *item) | 115 | static void cgit_check_cache(struct cacheitem *item) |
85 | { | 116 | { |
86 | int i = 0; | 117 | int i = 0; |
87 | 118 | ||
88 | top: | 119 | top: |
89 | if (++i > cgit_max_lock_attempts) { | 120 | if (++i > cgit_max_lock_attempts) { |
90 | die("cgit_refresh_cache: unable to lock %s: %s", | 121 | die("cgit_refresh_cache: unable to lock %s: %s", |
91 | item->name, strerror(errno)); | 122 | item->name, strerror(errno)); |
92 | } | 123 | } |
93 | if (!cache_exist(item)) { | 124 | if (!cache_exist(item)) { |
94 | if (!cache_lock(item)) { | 125 | if (!cache_lock(item)) { |
95 | sleep(1); | 126 | sleep(1); |
96 | goto top; | 127 | goto top; |
97 | } | 128 | } |
98 | if (!cache_exist(item)) { | 129 | if (!cache_exist(item)) { |
99 | cgit_fill_cache(item); | 130 | cgit_fill_cache(item); |
100 | cache_unlock(item); | 131 | cache_unlock(item); |
101 | } else { | 132 | } else { |
102 | cache_cancel_lock(item); | 133 | cache_cancel_lock(item); |
103 | } | 134 | } |
104 | } else if (cache_expired(item) && cache_lock(item)) { | 135 | } else if (cache_expired(item) && cache_lock(item)) { |
105 | if (cache_expired(item)) { | 136 | if (cache_expired(item)) { |
106 | cgit_fill_cache(item); | 137 | cgit_fill_cache(item); |
107 | cache_unlock(item); | 138 | cache_unlock(item); |
108 | } else { | 139 | } else { |
109 | cache_cancel_lock(item); | 140 | cache_cancel_lock(item); |
110 | } | 141 | } |
111 | } | 142 | } |
112 | } | 143 | } |
113 | 144 | ||
114 | static void cgit_print_cache(struct cacheitem *item) | 145 | static void cgit_print_cache(struct cacheitem *item) |
115 | { | 146 | { |
116 | static char buf[4096]; | 147 | static char buf[4096]; |
117 | ssize_t i; | 148 | ssize_t i; |
118 | 149 | ||
119 | int fd = open(item->name, O_RDONLY); | 150 | int fd = open(item->name, O_RDONLY); |
120 | if (fd<0) | 151 | if (fd<0) |
121 | die("Unable to open cached file %s", item->name); | 152 | die("Unable to open cached file %s", item->name); |
122 | 153 | ||
123 | while((i=read(fd, buf, sizeof(buf))) > 0) | 154 | while((i=read(fd, buf, sizeof(buf))) > 0) |
124 | write(STDOUT_FILENO, buf, i); | 155 | write(STDOUT_FILENO, buf, i); |
125 | 156 | ||
126 | close(fd); | 157 | close(fd); |
127 | } | 158 | } |
128 | 159 | ||
129 | static void cgit_parse_args(int argc, const char **argv) | 160 | static void cgit_parse_args(int argc, const char **argv) |
130 | { | 161 | { |
131 | int i; | 162 | int i; |
132 | 163 | ||
133 | for (i = 1; i < argc; i++) { | 164 | for (i = 1; i < argc; i++) { |
134 | if (!strncmp(argv[i], "--root=", 7)) { | ||
135 | cgit_root = xstrdup(argv[i]+7); | ||
136 | } | ||
137 | if (!strncmp(argv[i], "--cache=", 8)) { | 165 | if (!strncmp(argv[i], "--cache=", 8)) { |
138 | cgit_cache_root = xstrdup(argv[i]+8); | 166 | cgit_cache_root = xstrdup(argv[i]+8); |
139 | } | 167 | } |
140 | if (!strcmp(argv[i], "--nocache")) { | 168 | if (!strcmp(argv[i], "--nocache")) { |
141 | cgit_nocache = 1; | 169 | cgit_nocache = 1; |
142 | } | 170 | } |
143 | if (!strncmp(argv[i], "--query=", 8)) { | 171 | if (!strncmp(argv[i], "--query=", 8)) { |
144 | cgit_querystring = xstrdup(argv[i]+8); | 172 | cgit_querystring = xstrdup(argv[i]+8); |
145 | } | 173 | } |
146 | if (!strncmp(argv[i], "--repo=", 7)) { | 174 | if (!strncmp(argv[i], "--repo=", 7)) { |
147 | cgit_query_repo = xstrdup(argv[i]+7); | 175 | cgit_query_repo = xstrdup(argv[i]+7); |
148 | } | 176 | } |
149 | if (!strncmp(argv[i], "--page=", 7)) { | 177 | if (!strncmp(argv[i], "--page=", 7)) { |
150 | cgit_query_page = xstrdup(argv[i]+7); | 178 | cgit_query_page = xstrdup(argv[i]+7); |
151 | } | 179 | } |
152 | if (!strncmp(argv[i], "--head=", 7)) { | 180 | if (!strncmp(argv[i], "--head=", 7)) { |
153 | cgit_query_head = xstrdup(argv[i]+7); | 181 | cgit_query_head = xstrdup(argv[i]+7); |
154 | cgit_query_has_symref = 1; | 182 | cgit_query_has_symref = 1; |
155 | } | 183 | } |
156 | if (!strncmp(argv[i], "--sha1=", 7)) { | 184 | if (!strncmp(argv[i], "--sha1=", 7)) { |
157 | cgit_query_sha1 = xstrdup(argv[i]+7); | 185 | cgit_query_sha1 = xstrdup(argv[i]+7); |
158 | cgit_query_has_sha1 = 1; | 186 | cgit_query_has_sha1 = 1; |
159 | } | 187 | } |
160 | if (!strncmp(argv[i], "--ofs=", 6)) { | 188 | if (!strncmp(argv[i], "--ofs=", 6)) { |
161 | cgit_query_ofs = atoi(argv[i]+6); | 189 | cgit_query_ofs = atoi(argv[i]+6); |
162 | } | 190 | } |
163 | } | 191 | } |
164 | } | 192 | } |
165 | 193 | ||
166 | int main(int argc, const char **argv) | 194 | int main(int argc, const char **argv) |
167 | { | 195 | { |
168 | struct cacheitem item; | 196 | struct cacheitem item; |
169 | 197 | ||
198 | htmlfd = STDOUT_FILENO; | ||
199 | item.st.st_mtime = time(NULL); | ||
200 | cgit_repolist.length = 0; | ||
201 | cgit_repolist.count = 0; | ||
202 | cgit_repolist.repos = NULL; | ||
203 | |||
170 | cgit_read_config("/etc/cgitrc", cgit_global_config_cb); | 204 | cgit_read_config("/etc/cgitrc", cgit_global_config_cb); |
171 | if (getenv("QUERY_STRING")) | 205 | if (getenv("QUERY_STRING")) |
172 | cgit_querystring = xstrdup(getenv("QUERY_STRING")); | 206 | cgit_querystring = xstrdup(getenv("QUERY_STRING")); |
173 | cgit_parse_args(argc, argv); | 207 | cgit_parse_args(argc, argv); |
174 | cgit_parse_query(cgit_querystring, cgit_querystring_cb); | 208 | cgit_parse_query(cgit_querystring, cgit_querystring_cb); |
175 | 209 | if (!cgit_prepare_cache(&item)) | |
176 | cgit_prepare_cache(&item); | 210 | return 0; |
177 | if (cgit_nocache) { | 211 | if (cgit_nocache) { |
178 | item.fd = STDOUT_FILENO; | 212 | item.fd = STDOUT_FILENO; |
179 | cgit_fill_cache(&item); | 213 | cgit_fill_cache(&item); |
180 | } else { | 214 | } else { |
181 | cgit_check_cache(&item); | 215 | cgit_check_cache(&item); |
182 | cgit_print_cache(&item); | 216 | cgit_print_cache(&item); |
183 | } | 217 | } |
184 | return 0; | 218 | return 0; |
185 | } | 219 | } |
@@ -1,126 +1,142 @@ | |||
1 | #ifndef CGIT_H | 1 | #ifndef CGIT_H |
2 | #define CGIT_H | 2 | #define CGIT_H |
3 | 3 | ||
4 | #include "git.h" | 4 | #include "git.h" |
5 | #include <openssl/sha.h> | 5 | #include <openssl/sha.h> |
6 | #include <ctype.h> | 6 | #include <ctype.h> |
7 | #include <sched.h> | 7 | #include <sched.h> |
8 | 8 | ||
9 | typedef void (*configfn)(const char *name, const char *value); | 9 | typedef void (*configfn)(const char *name, const char *value); |
10 | 10 | ||
11 | struct cacheitem { | 11 | struct cacheitem { |
12 | char *name; | 12 | char *name; |
13 | struct stat st; | 13 | struct stat st; |
14 | int ttl; | 14 | int ttl; |
15 | int fd; | 15 | int fd; |
16 | }; | 16 | }; |
17 | 17 | ||
18 | struct repoinfo { | ||
19 | char *url; | ||
20 | char *name; | ||
21 | char *path; | ||
22 | char *desc; | ||
23 | char *owner; | ||
24 | }; | ||
25 | |||
26 | struct repolist { | ||
27 | int length; | ||
28 | int count; | ||
29 | struct repoinfo *repos; | ||
30 | }; | ||
31 | |||
18 | struct commitinfo { | 32 | struct commitinfo { |
19 | struct commit *commit; | 33 | struct commit *commit; |
20 | char *author; | 34 | char *author; |
21 | char *author_email; | 35 | char *author_email; |
22 | unsigned long author_date; | 36 | unsigned long author_date; |
23 | char *committer; | 37 | char *committer; |
24 | char *committer_email; | 38 | char *committer_email; |
25 | unsigned long committer_date; | 39 | unsigned long committer_date; |
26 | char *subject; | 40 | char *subject; |
27 | char *msg; | 41 | char *msg; |
28 | }; | 42 | }; |
29 | 43 | ||
30 | struct taginfo { | 44 | struct taginfo { |
31 | char *tagger; | 45 | char *tagger; |
32 | char *tagger_email; | 46 | char *tagger_email; |
33 | int tagger_date; | 47 | int tagger_date; |
34 | char *msg; | 48 | char *msg; |
35 | }; | 49 | }; |
36 | 50 | ||
37 | extern const char cgit_version[]; | 51 | extern const char cgit_version[]; |
38 | 52 | ||
39 | extern char *cgit_root; | 53 | extern struct repolist cgit_repolist; |
54 | extern struct repoinfo *cgit_repo; | ||
55 | |||
40 | extern char *cgit_root_title; | 56 | extern char *cgit_root_title; |
41 | extern char *cgit_css; | 57 | extern char *cgit_css; |
42 | extern char *cgit_logo; | 58 | extern char *cgit_logo; |
43 | extern char *cgit_logo_link; | 59 | extern char *cgit_logo_link; |
44 | extern char *cgit_virtual_root; | 60 | extern char *cgit_virtual_root; |
45 | extern char *cgit_cache_root; | 61 | extern char *cgit_cache_root; |
46 | 62 | ||
47 | extern int cgit_nocache; | 63 | extern int cgit_nocache; |
48 | extern int cgit_max_lock_attempts; | 64 | extern int cgit_max_lock_attempts; |
49 | extern int cgit_cache_root_ttl; | 65 | extern int cgit_cache_root_ttl; |
50 | extern int cgit_cache_repo_ttl; | 66 | extern int cgit_cache_repo_ttl; |
51 | extern int cgit_cache_dynamic_ttl; | 67 | extern int cgit_cache_dynamic_ttl; |
52 | extern int cgit_cache_static_ttl; | 68 | extern int cgit_cache_static_ttl; |
53 | extern int cgit_cache_max_create_time; | 69 | extern int cgit_cache_max_create_time; |
54 | 70 | ||
55 | extern int cgit_max_msg_len; | 71 | extern int cgit_max_msg_len; |
56 | 72 | ||
57 | extern char *cgit_repo_name; | 73 | extern char *cgit_repo_name; |
58 | extern char *cgit_repo_desc; | 74 | extern char *cgit_repo_desc; |
59 | extern char *cgit_repo_owner; | 75 | extern char *cgit_repo_owner; |
60 | 76 | ||
61 | extern int cgit_query_has_symref; | 77 | extern int cgit_query_has_symref; |
62 | extern int cgit_query_has_sha1; | 78 | extern int cgit_query_has_sha1; |
63 | 79 | ||
64 | extern char *cgit_querystring; | 80 | extern char *cgit_querystring; |
65 | extern char *cgit_query_repo; | 81 | extern char *cgit_query_repo; |
66 | extern char *cgit_query_page; | 82 | extern char *cgit_query_page; |
67 | extern char *cgit_query_search; | 83 | extern char *cgit_query_search; |
68 | extern char *cgit_query_head; | 84 | extern char *cgit_query_head; |
69 | extern char *cgit_query_sha1; | 85 | extern char *cgit_query_sha1; |
70 | extern char *cgit_query_sha2; | 86 | extern char *cgit_query_sha2; |
71 | extern char *cgit_query_path; | 87 | extern char *cgit_query_path; |
72 | extern int cgit_query_ofs; | 88 | extern int cgit_query_ofs; |
73 | 89 | ||
74 | extern int htmlfd; | 90 | extern int htmlfd; |
75 | 91 | ||
76 | extern void cgit_global_config_cb(const char *name, const char *value); | 92 | extern void cgit_global_config_cb(const char *name, const char *value); |
77 | extern void cgit_repo_config_cb(const char *name, const char *value); | 93 | extern void cgit_repo_config_cb(const char *name, const char *value); |
78 | extern void cgit_querystring_cb(const char *name, const char *value); | 94 | extern void cgit_querystring_cb(const char *name, const char *value); |
79 | 95 | ||
80 | extern int hextoint(char c); | 96 | extern int hextoint(char c); |
81 | 97 | ||
82 | extern void *cgit_free_commitinfo(struct commitinfo *info); | 98 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
83 | 99 | ||
84 | extern char *fmt(const char *format,...); | 100 | extern char *fmt(const char *format,...); |
85 | 101 | ||
86 | extern void html(const char *txt); | 102 | extern void html(const char *txt); |
87 | extern void htmlf(const char *format,...); | 103 | extern void htmlf(const char *format,...); |
88 | extern void html_txt(char *txt); | 104 | extern void html_txt(char *txt); |
89 | extern void html_ntxt(int len, char *txt); | 105 | extern void html_ntxt(int len, char *txt); |
90 | extern void html_attr(char *txt); | 106 | extern void html_attr(char *txt); |
91 | extern void html_hidden(char *name, char *value); | 107 | extern void html_hidden(char *name, char *value); |
92 | extern void html_link_open(char *url, char *title, char *class); | 108 | extern void html_link_open(char *url, char *title, char *class); |
93 | extern void html_link_close(void); | 109 | extern void html_link_close(void); |
94 | extern void html_filemode(unsigned short mode); | 110 | extern void html_filemode(unsigned short mode); |
95 | 111 | ||
96 | extern int cgit_read_config(const char *filename, configfn fn); | 112 | extern int cgit_read_config(const char *filename, configfn fn); |
97 | extern int cgit_parse_query(char *txt, configfn fn); | 113 | extern int cgit_parse_query(char *txt, configfn fn); |
98 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); | 114 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
99 | extern struct taginfo *cgit_parse_tag(struct tag *tag); | 115 | extern struct taginfo *cgit_parse_tag(struct tag *tag); |
100 | 116 | ||
101 | extern char *cache_safe_filename(const char *unsafe); | 117 | extern char *cache_safe_filename(const char *unsafe); |
102 | extern int cache_lock(struct cacheitem *item); | 118 | extern int cache_lock(struct cacheitem *item); |
103 | extern int cache_unlock(struct cacheitem *item); | 119 | extern int cache_unlock(struct cacheitem *item); |
104 | extern int cache_cancel_lock(struct cacheitem *item); | 120 | extern int cache_cancel_lock(struct cacheitem *item); |
105 | extern int cache_exist(struct cacheitem *item); | 121 | extern int cache_exist(struct cacheitem *item); |
106 | extern int cache_expired(struct cacheitem *item); | 122 | extern int cache_expired(struct cacheitem *item); |
107 | 123 | ||
108 | extern char *cgit_repourl(const char *reponame); | 124 | extern char *cgit_repourl(const char *reponame); |
109 | extern char *cgit_pageurl(const char *reponame, const char *pagename, | 125 | extern char *cgit_pageurl(const char *reponame, const char *pagename, |
110 | const char *query); | 126 | const char *query); |
111 | 127 | ||
112 | extern void cgit_print_error(char *msg); | 128 | extern void cgit_print_error(char *msg); |
113 | extern void cgit_print_date(unsigned long secs); | 129 | extern void cgit_print_date(unsigned long secs); |
114 | extern void cgit_print_docstart(char *title, struct cacheitem *item); | 130 | extern void cgit_print_docstart(char *title, struct cacheitem *item); |
115 | extern void cgit_print_docend(); | 131 | extern void cgit_print_docend(); |
116 | extern void cgit_print_pageheader(char *title, int show_search); | 132 | extern void cgit_print_pageheader(char *title, int show_search); |
117 | 133 | ||
118 | extern void cgit_print_repolist(struct cacheitem *item); | 134 | extern void cgit_print_repolist(struct cacheitem *item); |
119 | extern void cgit_print_summary(); | 135 | extern void cgit_print_summary(); |
120 | extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep); | 136 | extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep); |
121 | extern void cgit_print_view(const char *hex); | 137 | extern void cgit_print_view(const char *hex); |
122 | extern void cgit_print_tree(const char *hex, char *path); | 138 | extern void cgit_print_tree(const char *hex, char *path); |
123 | extern void cgit_print_commit(const char *hex); | 139 | extern void cgit_print_commit(const char *hex); |
124 | extern void cgit_print_diff(const char *old_hex, const char *new_hex); | 140 | extern void cgit_print_diff(const char *old_hex, const char *new_hex); |
125 | 141 | ||
126 | #endif /* CGIT_H */ | 142 | #endif /* CGIT_H */ |
@@ -1,63 +1,68 @@ | |||
1 | ## | 1 | ## |
2 | ## cgitrc: template for /etc/cgitrc | 2 | ## cgitrc: template for /etc/cgitrc |
3 | ## | 3 | ## |
4 | 4 | ||
5 | 5 | ||
6 | ## root folder for git repos | ||
7 | #root=/usr/src/git | ||
8 | |||
9 | |||
10 | ## base for virtual urls. If specified, rewrite rules must be added to | 6 | ## base for virtual urls. If specified, rewrite rules must be added to |
11 | ## httpd.conf. Possible rules for /git/ when cgit.cgi is accessed as /cgit.cgi: | 7 | ## httpd.conf. Possible rules for /git/ when cgit.cgi is accessed as /cgit.cgi: |
12 | ## | 8 | ## |
13 | ## RewriteRule ^/git/$ /cgit.cgi [L,QSA] | 9 | ## RewriteRule ^/git/$ /cgit.cgi [L,QSA] |
14 | ## RewriteRule ^/git/([^/]+)/$ /cgit.cgi?r=$1 [L,QSA] | 10 | ## RewriteRule ^/git/([^/]+)/$ /cgit.cgi?r=$1 [L,QSA] |
15 | ## RewriteRule ^/git/([^/]+)/([^/]+)/$ /cgit.cgi?r=$1&p=$2 [L,QSA] | 11 | ## RewriteRule ^/git/([^/]+)/([^/]+)/$ /cgit.cgi?r=$1&p=$2 [L,QSA] |
16 | ## | 12 | ## |
17 | #virtual-root=/git | 13 | #virtual-root=/git |
18 | 14 | ||
19 | 15 | ||
20 | ## page title for the root page (repo listing) | 16 | ## page title for the root page (repo listing) |
21 | #root-title=Git repository browser | 17 | #root-title=Git repository browser |
22 | 18 | ||
23 | 19 | ||
24 | ## link to css file | 20 | ## link to css file |
25 | #css=/cgit.css | 21 | #css=/cgit.css |
26 | 22 | ||
27 | 23 | ||
28 | ## link to logo file | 24 | ## link to logo file |
29 | #logo=/git-logo.png | 25 | #logo=/git-logo.png |
30 | 26 | ||
31 | 27 | ||
32 | ## url loaded when clicking the logo | 28 | ## url loaded when clicking the logo |
33 | #logo-link=http://www.kernel.org/pub/software/scm/git/docs/ | 29 | #logo-link=http://www.kernel.org/pub/software/scm/git/docs/ |
34 | 30 | ||
35 | 31 | ||
36 | ## set number of initial chars to show of commit subject message in log views | 32 | ## set number of initial chars to show of commit subject message in log views |
37 | #max-message-length=60 | 33 | #max-message-length=60 |
38 | 34 | ||
39 | 35 | ||
40 | ## Set to 1 to deactivate caching of generated pages | 36 | ## Set to 1 to deactivate caching of generated pages |
41 | #nocache=0 | 37 | #nocache=0 |
42 | 38 | ||
43 | 39 | ||
44 | ## root path for cached output | 40 | ## root path for cached output |
45 | #cache-root=/var/cache/cgit | 41 | #cache-root=/var/cache/cgit |
46 | 42 | ||
47 | 43 | ||
48 | ## | 44 | ## |
49 | ## Time-To-Live settings: specify how long (in minutes) different pages should | 45 | ## Time-To-Live settings: specify how long (in minutes) different pages should |
50 | ## be cached. Specify 0 for instant expiration and -1 for immortal pages | 46 | ## be cached. Specify 0 for instant expiration and -1 for immortal pages |
51 | ## | 47 | ## |
52 | 48 | ||
53 | ## ttl for root page (repo listing) | 49 | ## ttl for root page (repo listing) |
54 | #cache-root-ttl=5 | 50 | #cache-root-ttl=5 |
55 | 51 | ||
56 | ## ttl for repo summary page | 52 | ## ttl for repo summary page |
57 | #cache-repo-ttl=5 | 53 | #cache-repo-ttl=5 |
58 | 54 | ||
59 | ## ttl for other dynamic pages | 55 | ## ttl for other dynamic pages |
60 | #cache-dynamic-ttl=5 | 56 | #cache-dynamic-ttl=5 |
61 | 57 | ||
62 | ## ttl for static pages (addressed by SHA-1) | 58 | ## ttl for static pages (addressed by SHA-1) |
63 | #cache-static-ttl=-1 | 59 | #cache-static-ttl=-1 |
60 | |||
61 | |||
62 | |||
63 | ## Example repository entry | ||
64 | #repo.url=cgit | ||
65 | #repo.name=cgit | ||
66 | #repo.desc=the caching cgi for git | ||
67 | #repo.path=/pub/git/cgit | ||
68 | #repo.owner=Lars Hjemli | ||
@@ -1,135 +1,168 @@ | |||
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 | char *cgit_root = "/usr/src/git"; | 11 | struct repolist cgit_repolist; |
12 | struct repoinfo *cgit_repo; | ||
13 | |||
12 | char *cgit_root_title = "Git repository browser"; | 14 | char *cgit_root_title = "Git repository browser"; |
13 | char *cgit_css = "/cgit.css"; | 15 | char *cgit_css = "/cgit.css"; |
14 | char *cgit_logo = "/git-logo.png"; | 16 | char *cgit_logo = "/git-logo.png"; |
15 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; | 17 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; |
16 | char *cgit_virtual_root = NULL; | 18 | char *cgit_virtual_root = NULL; |
17 | 19 | ||
18 | char *cgit_cache_root = "/var/cache/cgit"; | 20 | char *cgit_cache_root = "/var/cache/cgit"; |
19 | 21 | ||
20 | int cgit_nocache = 0; | 22 | int cgit_nocache = 0; |
21 | int cgit_max_lock_attempts = 5; | 23 | int cgit_max_lock_attempts = 5; |
22 | int cgit_cache_root_ttl = 5; | 24 | int cgit_cache_root_ttl = 5; |
23 | int cgit_cache_repo_ttl = 5; | 25 | int cgit_cache_repo_ttl = 5; |
24 | int cgit_cache_dynamic_ttl = 5; | 26 | int cgit_cache_dynamic_ttl = 5; |
25 | int cgit_cache_static_ttl = -1; | 27 | int cgit_cache_static_ttl = -1; |
26 | int cgit_cache_max_create_time = 5; | 28 | int cgit_cache_max_create_time = 5; |
27 | 29 | ||
28 | int cgit_max_msg_len = 60; | 30 | int cgit_max_msg_len = 60; |
29 | 31 | ||
30 | char *cgit_repo_name = NULL; | 32 | char *cgit_repo_name = NULL; |
31 | char *cgit_repo_desc = NULL; | 33 | char *cgit_repo_desc = NULL; |
32 | char *cgit_repo_owner = NULL; | 34 | char *cgit_repo_owner = NULL; |
33 | 35 | ||
34 | int cgit_query_has_symref = 0; | 36 | int cgit_query_has_symref = 0; |
35 | int cgit_query_has_sha1 = 0; | 37 | int cgit_query_has_sha1 = 0; |
36 | 38 | ||
37 | char *cgit_querystring = NULL; | 39 | char *cgit_querystring = NULL; |
38 | char *cgit_query_repo = NULL; | 40 | char *cgit_query_repo = NULL; |
39 | char *cgit_query_page = NULL; | 41 | char *cgit_query_page = NULL; |
40 | char *cgit_query_head = NULL; | 42 | char *cgit_query_head = NULL; |
41 | char *cgit_query_search = NULL; | 43 | char *cgit_query_search = NULL; |
42 | char *cgit_query_sha1 = NULL; | 44 | char *cgit_query_sha1 = NULL; |
43 | char *cgit_query_sha2 = NULL; | 45 | char *cgit_query_sha2 = NULL; |
44 | char *cgit_query_path = NULL; | 46 | char *cgit_query_path = NULL; |
45 | int cgit_query_ofs = 0; | 47 | int cgit_query_ofs = 0; |
46 | 48 | ||
47 | int htmlfd = 0; | 49 | int htmlfd = 0; |
48 | 50 | ||
51 | struct repoinfo *add_repo(const char *url) | ||
52 | { | ||
53 | struct repoinfo *ret; | ||
54 | |||
55 | if (++cgit_repolist.count > cgit_repolist.length) { | ||
56 | if (cgit_repolist.length == 0) | ||
57 | cgit_repolist.length = 8; | ||
58 | else | ||
59 | cgit_repolist.length *= 2; | ||
60 | cgit_repolist.repos = xrealloc(cgit_repolist.repos, | ||
61 | cgit_repolist.length * | ||
62 | sizeof(struct repoinfo)); | ||
63 | } | ||
64 | |||
65 | ret = &cgit_repolist.repos[cgit_repolist.count-1]; | ||
66 | ret->url = xstrdup(url); | ||
67 | ret->name = ret->url; | ||
68 | ret->path = NULL; | ||
69 | ret->desc = NULL; | ||
70 | ret->owner = NULL; | ||
71 | return ret; | ||
72 | } | ||
73 | |||
49 | void cgit_global_config_cb(const char *name, const char *value) | 74 | void cgit_global_config_cb(const char *name, const char *value) |
50 | { | 75 | { |
51 | if (!strcmp(name, "root")) | 76 | if (!strcmp(name, "root-title")) |
52 | cgit_root = xstrdup(value); | ||
53 | else if (!strcmp(name, "root-title")) | ||
54 | cgit_root_title = xstrdup(value); | 77 | cgit_root_title = xstrdup(value); |
55 | else if (!strcmp(name, "css")) | 78 | else if (!strcmp(name, "css")) |
56 | cgit_css = xstrdup(value); | 79 | cgit_css = xstrdup(value); |
57 | else if (!strcmp(name, "logo")) | 80 | else if (!strcmp(name, "logo")) |
58 | cgit_logo = xstrdup(value); | 81 | cgit_logo = xstrdup(value); |
59 | else if (!strcmp(name, "logo-link")) | 82 | else if (!strcmp(name, "logo-link")) |
60 | cgit_logo_link = xstrdup(value); | 83 | cgit_logo_link = xstrdup(value); |
61 | else if (!strcmp(name, "virtual-root")) | 84 | else if (!strcmp(name, "virtual-root")) |
62 | cgit_virtual_root = xstrdup(value); | 85 | cgit_virtual_root = xstrdup(value); |
63 | else if (!strcmp(name, "nocache")) | 86 | else if (!strcmp(name, "nocache")) |
64 | cgit_nocache = atoi(value); | 87 | cgit_nocache = atoi(value); |
65 | else if (!strcmp(name, "cache-root")) | 88 | else if (!strcmp(name, "cache-root")) |
66 | cgit_cache_root = xstrdup(value); | 89 | cgit_cache_root = xstrdup(value); |
67 | else if (!strcmp(name, "cache-root-ttl")) | 90 | else if (!strcmp(name, "cache-root-ttl")) |
68 | cgit_cache_root_ttl = atoi(value); | 91 | cgit_cache_root_ttl = atoi(value); |
69 | else if (!strcmp(name, "cache-repo-ttl")) | 92 | else if (!strcmp(name, "cache-repo-ttl")) |
70 | cgit_cache_repo_ttl = atoi(value); | 93 | cgit_cache_repo_ttl = atoi(value); |
71 | else if (!strcmp(name, "cache-static-ttl")) | 94 | else if (!strcmp(name, "cache-static-ttl")) |
72 | cgit_cache_static_ttl = atoi(value); | 95 | cgit_cache_static_ttl = atoi(value); |
73 | else if (!strcmp(name, "cache-dynamic-ttl")) | 96 | else if (!strcmp(name, "cache-dynamic-ttl")) |
74 | cgit_cache_dynamic_ttl = atoi(value); | 97 | cgit_cache_dynamic_ttl = atoi(value); |
75 | else if (!strcmp(name, "max-message-length")) | 98 | else if (!strcmp(name, "max-message-length")) |
76 | cgit_max_msg_len = atoi(value); | 99 | cgit_max_msg_len = atoi(value); |
100 | else if (!strcmp(name, "repo.url")) | ||
101 | cgit_repo = add_repo(value); | ||
102 | else if (!strcmp(name, "repo.name")) | ||
103 | cgit_repo->name = xstrdup(value); | ||
104 | else if (cgit_repo && !strcmp(name, "repo.path")) | ||
105 | cgit_repo->path = xstrdup(value); | ||
106 | else if (cgit_repo && !strcmp(name, "repo.desc")) | ||
107 | cgit_repo->desc = xstrdup(value); | ||
108 | else if (cgit_repo && !strcmp(name, "repo.owner")) | ||
109 | cgit_repo->owner = xstrdup(value); | ||
77 | } | 110 | } |
78 | 111 | ||
79 | void cgit_repo_config_cb(const char *name, const char *value) | 112 | void cgit_repo_config_cb(const char *name, const char *value) |
80 | { | 113 | { |
81 | if (!strcmp(name, "name")) | 114 | if (!strcmp(name, "name")) |
82 | cgit_repo_name = xstrdup(value); | 115 | cgit_repo_name = xstrdup(value); |
83 | else if (!strcmp(name, "desc")) | 116 | else if (!strcmp(name, "desc")) |
84 | cgit_repo_desc = xstrdup(value); | 117 | cgit_repo_desc = xstrdup(value); |
85 | else if (!strcmp(name, "owner")) | 118 | else if (!strcmp(name, "owner")) |
86 | cgit_repo_owner = xstrdup(value); | 119 | cgit_repo_owner = xstrdup(value); |
87 | } | 120 | } |
88 | 121 | ||
89 | void cgit_querystring_cb(const char *name, const char *value) | 122 | void cgit_querystring_cb(const char *name, const char *value) |
90 | { | 123 | { |
91 | if (!strcmp(name,"r")) { | 124 | if (!strcmp(name,"r")) { |
92 | cgit_query_repo = xstrdup(value); | 125 | cgit_query_repo = xstrdup(value); |
93 | } else if (!strcmp(name, "p")) { | 126 | } else if (!strcmp(name, "p")) { |
94 | cgit_query_page = xstrdup(value); | 127 | cgit_query_page = xstrdup(value); |
95 | } else if (!strcmp(name, "q")) { | 128 | } else if (!strcmp(name, "q")) { |
96 | cgit_query_search = xstrdup(value); | 129 | cgit_query_search = xstrdup(value); |
97 | } else if (!strcmp(name, "h")) { | 130 | } else if (!strcmp(name, "h")) { |
98 | cgit_query_head = xstrdup(value); | 131 | cgit_query_head = xstrdup(value); |
99 | cgit_query_has_symref = 1; | 132 | cgit_query_has_symref = 1; |
100 | } else if (!strcmp(name, "id")) { | 133 | } else if (!strcmp(name, "id")) { |
101 | cgit_query_sha1 = xstrdup(value); | 134 | cgit_query_sha1 = xstrdup(value); |
102 | cgit_query_has_sha1 = 1; | 135 | cgit_query_has_sha1 = 1; |
103 | } else if (!strcmp(name, "id2")) { | 136 | } else if (!strcmp(name, "id2")) { |
104 | cgit_query_sha2 = xstrdup(value); | 137 | cgit_query_sha2 = xstrdup(value); |
105 | cgit_query_has_sha1 = 1; | 138 | cgit_query_has_sha1 = 1; |
106 | } else if (!strcmp(name, "ofs")) { | 139 | } else if (!strcmp(name, "ofs")) { |
107 | cgit_query_ofs = atoi(value); | 140 | cgit_query_ofs = atoi(value); |
108 | } else if (!strcmp(name, "path")) { | 141 | } else if (!strcmp(name, "path")) { |
109 | cgit_query_path = xstrdup(value); | 142 | cgit_query_path = xstrdup(value); |
110 | } | 143 | } |
111 | } | 144 | } |
112 | 145 | ||
113 | void *cgit_free_commitinfo(struct commitinfo *info) | 146 | void *cgit_free_commitinfo(struct commitinfo *info) |
114 | { | 147 | { |
115 | free(info->author); | 148 | free(info->author); |
116 | free(info->author_email); | 149 | free(info->author_email); |
117 | free(info->committer); | 150 | free(info->committer); |
118 | free(info->committer_email); | 151 | free(info->committer_email); |
119 | free(info->subject); | 152 | free(info->subject); |
120 | free(info); | 153 | free(info); |
121 | return NULL; | 154 | return NULL; |
122 | } | 155 | } |
123 | 156 | ||
124 | int hextoint(char c) | 157 | int hextoint(char c) |
125 | { | 158 | { |
126 | if (c >= 'a' && c <= 'f') | 159 | if (c >= 'a' && c <= 'f') |
127 | return 10 + c - 'a'; | 160 | return 10 + c - 'a'; |
128 | else if (c >= 'A' && c <= 'F') | 161 | else if (c >= 'A' && c <= 'F') |
129 | return 10 + c - 'A'; | 162 | return 10 + c - 'A'; |
130 | else if (c >= '0' && c <= '9') | 163 | else if (c >= '0' && c <= '9') |
131 | return c - '0'; | 164 | return c - '0'; |
132 | else | 165 | else |
133 | return -1; | 166 | return -1; |
134 | } | 167 | } |
135 | 168 | ||
diff --git a/ui-repolist.c b/ui-repolist.c index bd4af59..011ec95 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
@@ -1,63 +1,40 @@ | |||
1 | /* ui-repolist.c: functions for generating the repolist page | 1 | /* ui-repolist.c: functions for generating the repolist 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 | ||
11 | void cgit_print_repolist(struct cacheitem *item) | 11 | void cgit_print_repolist(struct cacheitem *item) |
12 | { | 12 | { |
13 | DIR *d; | 13 | struct repoinfo *repo; |
14 | struct dirent *de; | 14 | int i; |
15 | struct stat st; | ||
16 | char *name; | ||
17 | 15 | ||
18 | chdir(cgit_root); | ||
19 | cgit_print_docstart(cgit_root_title, item); | 16 | cgit_print_docstart(cgit_root_title, item); |
20 | cgit_print_pageheader(cgit_root_title, 0); | 17 | cgit_print_pageheader(cgit_root_title, 0); |
21 | 18 | ||
22 | if (!(d = opendir("."))) { | ||
23 | cgit_print_error(fmt("Unable to scan repository directory: %s", | ||
24 | strerror(errno))); | ||
25 | cgit_print_docend(); | ||
26 | return; | ||
27 | } | ||
28 | |||
29 | html("<h2>Repositories</h2>\n"); | 19 | html("<h2>Repositories</h2>\n"); |
30 | html("<table class='list nowrap'>"); | 20 | html("<table class='list nowrap'>"); |
31 | html("<tr class='nohover'>" | 21 | html("<tr class='nohover'>" |
32 | "<th class='left'>Name</th>" | 22 | "<th class='left'>Name</th>" |
33 | "<th class='left'>Description</th>" | 23 | "<th class='left'>Description</th>" |
34 | "<th class='left'>Owner</th></tr>\n"); | 24 | "<th class='left'>Owner</th></tr>\n"); |
35 | while ((de = readdir(d)) != NULL) { | ||
36 | if (de->d_name[0] == '.') | ||
37 | continue; | ||
38 | if (stat(de->d_name, &st) < 0) | ||
39 | continue; | ||
40 | if (!S_ISDIR(st.st_mode)) | ||
41 | continue; | ||
42 | |||
43 | cgit_repo_name = cgit_repo_desc = cgit_repo_owner = NULL; | ||
44 | name = fmt("%s/info/cgit", de->d_name); | ||
45 | if (cgit_read_config(name, cgit_repo_config_cb)) | ||
46 | continue; | ||
47 | 25 | ||
26 | for (i=0; i<cgit_repolist.count; i++) { | ||
27 | repo = &cgit_repolist.repos[i]; | ||
48 | html("<tr><td>"); | 28 | html("<tr><td>"); |
49 | html_link_open(cgit_repourl(de->d_name), NULL, NULL); | 29 | html_link_open(cgit_repourl(repo->url), NULL, NULL); |
50 | html_txt(cgit_repo_name); | 30 | html_txt(repo->name); |
51 | html_link_close(); | 31 | html_link_close(); |
52 | html("</td><td>"); | 32 | html("</td><td>"); |
53 | html_txt(cgit_repo_desc); | 33 | html_txt(repo->desc); |
54 | html("</td><td>"); | 34 | html("</td><td>"); |
55 | html_txt(cgit_repo_owner); | 35 | html_txt(repo->owner); |
56 | html("</td></tr>\n"); | 36 | html("</td></tr>\n"); |
57 | } | 37 | } |
58 | closedir(d); | ||
59 | html("</table>"); | 38 | html("</table>"); |
60 | cgit_print_docend(); | 39 | cgit_print_docend(); |
61 | } | 40 | } |
62 | |||
63 | |||