author | Lars Hjemli <hjemli@gmail.com> | 2007-10-28 14:23:00 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-10-28 14:23:00 (UTC) |
commit | 68ca032dbe7379f78775fb03ef34a9ad2abc409f (patch) (unidiff) | |
tree | 2209ae312eb932bc61b41ae9c774f6cfcc3dd372 | |
parent | 6ec5f36f279a85f59db2851ab476d9acd0015770 (diff) | |
download | cgit-68ca032dbe7379f78775fb03ef34a9ad2abc409f.zip cgit-68ca032dbe7379f78775fb03ef34a9ad2abc409f.tar.gz cgit-68ca032dbe7379f78775fb03ef34a9ad2abc409f.tar.bz2 |
Teach log search about --grep, --author and --committer
This makes the log searching more explicit, using a dropdown box to specify
the commit field to match against.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.c | 2 | ||||
-rw-r--r-- | cgit.css | 19 | ||||
-rw-r--r-- | cgit.h | 4 | ||||
-rw-r--r-- | shared.c | 3 | ||||
-rw-r--r-- | ui-log.c | 9 | ||||
-rw-r--r-- | ui-shared.c | 9 | ||||
-rw-r--r-- | ui-summary.c | 2 |
7 files changed, 39 insertions, 9 deletions
@@ -49,97 +49,97 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
49 | { | 49 | { |
50 | char *title; | 50 | char *title; |
51 | int show_search; | 51 | int show_search; |
52 | 52 | ||
53 | if (!cgit_query_head) | 53 | if (!cgit_query_head) |
54 | cgit_query_head = cgit_repo->defbranch; | 54 | cgit_query_head = cgit_repo->defbranch; |
55 | 55 | ||
56 | if (chdir(cgit_repo->path)) { | 56 | if (chdir(cgit_repo->path)) { |
57 | title = fmt("%s - %s", cgit_root_title, "Bad request"); | 57 | title = fmt("%s - %s", cgit_root_title, "Bad request"); |
58 | cgit_print_docstart(title, item); | 58 | cgit_print_docstart(title, item); |
59 | cgit_print_pageheader(title, 0); | 59 | cgit_print_pageheader(title, 0); |
60 | cgit_print_error(fmt("Unable to scan repository: %s", | 60 | cgit_print_error(fmt("Unable to scan repository: %s", |
61 | strerror(errno))); | 61 | strerror(errno))); |
62 | cgit_print_docend(); | 62 | cgit_print_docend(); |
63 | return; | 63 | return; |
64 | } | 64 | } |
65 | 65 | ||
66 | title = fmt("%s - %s", cgit_repo->name, cgit_repo->desc); | 66 | title = fmt("%s - %s", cgit_repo->name, cgit_repo->desc); |
67 | show_search = 0; | 67 | show_search = 0; |
68 | setenv("GIT_DIR", cgit_repo->path, 1); | 68 | setenv("GIT_DIR", cgit_repo->path, 1); |
69 | 69 | ||
70 | if ((cgit_cmd == CMD_SNAPSHOT) && cgit_repo->snapshots) { | 70 | if ((cgit_cmd == CMD_SNAPSHOT) && cgit_repo->snapshots) { |
71 | cgit_print_snapshot(item, cgit_query_head, cgit_query_sha1, | 71 | cgit_print_snapshot(item, cgit_query_head, cgit_query_sha1, |
72 | cgit_repobasename(cgit_repo->url), | 72 | cgit_repobasename(cgit_repo->url), |
73 | cgit_query_path, | 73 | cgit_query_path, |
74 | cgit_repo->snapshots ); | 74 | cgit_repo->snapshots ); |
75 | return; | 75 | return; |
76 | } | 76 | } |
77 | 77 | ||
78 | if (cgit_cmd == CMD_BLOB) { | 78 | if (cgit_cmd == CMD_BLOB) { |
79 | cgit_print_blob(item, cgit_query_sha1, cgit_query_path); | 79 | cgit_print_blob(item, cgit_query_sha1, cgit_query_path); |
80 | return; | 80 | return; |
81 | } | 81 | } |
82 | 82 | ||
83 | show_search = (cgit_cmd == CMD_LOG); | 83 | show_search = (cgit_cmd == CMD_LOG); |
84 | cgit_print_docstart(title, item); | 84 | cgit_print_docstart(title, item); |
85 | if (!cgit_cmd) { | 85 | if (!cgit_cmd) { |
86 | cgit_print_pageheader("summary", show_search); | 86 | cgit_print_pageheader("summary", show_search); |
87 | cgit_print_summary(); | 87 | cgit_print_summary(); |
88 | cgit_print_docend(); | 88 | cgit_print_docend(); |
89 | return; | 89 | return; |
90 | } | 90 | } |
91 | 91 | ||
92 | cgit_print_pageheader(cgit_query_page, show_search); | 92 | cgit_print_pageheader(cgit_query_page, show_search); |
93 | 93 | ||
94 | switch(cgit_cmd) { | 94 | switch(cgit_cmd) { |
95 | case CMD_LOG: | 95 | case CMD_LOG: |
96 | cgit_print_log(cgit_query_sha1, cgit_query_ofs, | 96 | cgit_print_log(cgit_query_sha1, cgit_query_ofs, |
97 | cgit_max_commit_count, cgit_query_search, | 97 | cgit_max_commit_count, cgit_query_grep, cgit_query_search, |
98 | cgit_query_path, 1); | 98 | cgit_query_path, 1); |
99 | break; | 99 | break; |
100 | case CMD_TREE: | 100 | case CMD_TREE: |
101 | cgit_print_tree(cgit_query_sha1, cgit_query_path); | 101 | cgit_print_tree(cgit_query_sha1, cgit_query_path); |
102 | break; | 102 | break; |
103 | case CMD_COMMIT: | 103 | case CMD_COMMIT: |
104 | cgit_print_commit(cgit_query_sha1); | 104 | cgit_print_commit(cgit_query_sha1); |
105 | break; | 105 | break; |
106 | case CMD_REFS: | 106 | case CMD_REFS: |
107 | cgit_print_refs(); | 107 | cgit_print_refs(); |
108 | break; | 108 | break; |
109 | case CMD_TAG: | 109 | case CMD_TAG: |
110 | cgit_print_tag(cgit_query_sha1); | 110 | cgit_print_tag(cgit_query_sha1); |
111 | break; | 111 | break; |
112 | case CMD_DIFF: | 112 | case CMD_DIFF: |
113 | cgit_print_diff(cgit_query_sha1, cgit_query_sha2, cgit_query_path); | 113 | cgit_print_diff(cgit_query_sha1, cgit_query_sha2, cgit_query_path); |
114 | break; | 114 | break; |
115 | default: | 115 | default: |
116 | cgit_print_error("Invalid request"); | 116 | cgit_print_error("Invalid request"); |
117 | } | 117 | } |
118 | cgit_print_docend(); | 118 | cgit_print_docend(); |
119 | } | 119 | } |
120 | 120 | ||
121 | static void cgit_fill_cache(struct cacheitem *item, int use_cache) | 121 | static void cgit_fill_cache(struct cacheitem *item, int use_cache) |
122 | { | 122 | { |
123 | static char buf[PATH_MAX]; | 123 | static char buf[PATH_MAX]; |
124 | int stdout2; | 124 | int stdout2; |
125 | 125 | ||
126 | getcwd(buf, sizeof(buf)); | 126 | getcwd(buf, sizeof(buf)); |
127 | item->st.st_mtime = time(NULL); | 127 | item->st.st_mtime = time(NULL); |
128 | 128 | ||
129 | if (use_cache) { | 129 | if (use_cache) { |
130 | stdout2 = chk_positive(dup(STDOUT_FILENO), | 130 | stdout2 = chk_positive(dup(STDOUT_FILENO), |
131 | "Preserving STDOUT"); | 131 | "Preserving STDOUT"); |
132 | chk_zero(close(STDOUT_FILENO), "Closing STDOUT"); | 132 | chk_zero(close(STDOUT_FILENO), "Closing STDOUT"); |
133 | chk_positive(dup2(item->fd, STDOUT_FILENO), "Dup2(cachefile)"); | 133 | chk_positive(dup2(item->fd, STDOUT_FILENO), "Dup2(cachefile)"); |
134 | } | 134 | } |
135 | 135 | ||
136 | if (cgit_repo) | 136 | if (cgit_repo) |
137 | cgit_print_repo_page(item); | 137 | cgit_print_repo_page(item); |
138 | else | 138 | else |
139 | cgit_print_repolist(item); | 139 | cgit_print_repolist(item); |
140 | 140 | ||
141 | if (use_cache) { | 141 | if (use_cache) { |
142 | chk_zero(close(STDOUT_FILENO), "Close redirected STDOUT"); | 142 | chk_zero(close(STDOUT_FILENO), "Close redirected STDOUT"); |
143 | chk_positive(dup2(stdout2, STDOUT_FILENO), | 143 | chk_positive(dup2(stdout2, STDOUT_FILENO), |
144 | "Restoring original STDOUT"); | 144 | "Restoring original STDOUT"); |
145 | chk_zero(close(stdout2), "Closing temporary STDOUT"); | 145 | chk_zero(close(stdout2), "Closing temporary STDOUT"); |
@@ -99,105 +99,122 @@ td#header a { | |||
99 | color: #666; | 99 | color: #666; |
100 | } | 100 | } |
101 | 101 | ||
102 | td#header a:hover { | 102 | td#header a:hover { |
103 | text-decoration: underline; | 103 | text-decoration: underline; |
104 | } | 104 | } |
105 | 105 | ||
106 | td#logo { | 106 | td#logo { |
107 | text-align: right; | 107 | text-align: right; |
108 | vertical-align: middle; | 108 | vertical-align: middle; |
109 | padding-right: 0.5em; | 109 | padding-right: 0.5em; |
110 | } | 110 | } |
111 | 111 | ||
112 | td#crumb, td#search { | 112 | td#crumb, td#search { |
113 | color: #ccc; | 113 | color: #ccc; |
114 | border-top: solid 3px #555; | 114 | border-top: solid 3px #555; |
115 | background-color: #666; | 115 | background-color: #666; |
116 | border-bottom: solid 1px #333; | 116 | border-bottom: solid 1px #333; |
117 | padding: 2px 1em; | 117 | padding: 2px 1em; |
118 | } | 118 | } |
119 | 119 | ||
120 | td#crumb { | 120 | td#crumb { |
121 | font-weight: bold; | 121 | font-weight: bold; |
122 | } | 122 | } |
123 | 123 | ||
124 | td#crumb a { | 124 | td#crumb a { |
125 | color: #ccc; | 125 | color: #ccc; |
126 | background-color: #666; | 126 | background-color: #666; |
127 | padding: 0em 0.5em 0em 0.5em; | 127 | padding: 0em 0.5em 0em 0.5em; |
128 | } | 128 | } |
129 | 129 | ||
130 | td#crumb a:hover { | 130 | td#crumb a:hover { |
131 | color: #666; | 131 | color: #666; |
132 | background-color: #ccc; | 132 | background-color: #ccc; |
133 | text-decoration: none; | 133 | text-decoration: none; |
134 | } | 134 | } |
135 | 135 | ||
136 | td#search { | 136 | td#search { |
137 | text-align: right; | 137 | text-align: right; |
138 | vertical-align: middle; | 138 | vertical-align: middle; |
139 | padding-right: 0.5em; | 139 | padding-right: 0.5em; |
140 | } | 140 | } |
141 | 141 | ||
142 | td#search form { | 142 | td#search form { |
143 | margin: 0px; | 143 | margin: 0px; |
144 | padding: 0px; | 144 | padding: 0px; |
145 | } | 145 | } |
146 | 146 | ||
147 | td#search select { | ||
148 | font-size: 9pt; | ||
149 | padding: 0px; | ||
150 | border: solid 1px #333; | ||
151 | color: #333; | ||
152 | background-color: #fff; | ||
153 | } | ||
154 | |||
147 | td#search input { | 155 | td#search input { |
148 | font-size: 9pt; | 156 | font-size: 9pt; |
149 | padding: 0px; | 157 | padding: 0px; |
150 | width: 10em; | 158 | } |
159 | |||
160 | td#search input.txt { | ||
161 | width: 8em; | ||
151 | border: solid 1px #333; | 162 | border: solid 1px #333; |
152 | color: #333; | 163 | color: #333; |
153 | background-color: #fff; | 164 | background-color: #fff; |
154 | } | 165 | } |
155 | 166 | ||
167 | td#search input.btn { | ||
168 | border: solid 1px #333; | ||
169 | color: #333; | ||
170 | background-color: #ccc; | ||
171 | } | ||
172 | |||
156 | div#summary { | 173 | div#summary { |
157 | vertical-align: top; | 174 | vertical-align: top; |
158 | margin-bottom: 1em; | 175 | margin-bottom: 1em; |
159 | } | 176 | } |
160 | 177 | ||
161 | table#downloads { | 178 | table#downloads { |
162 | float: right; | 179 | float: right; |
163 | border-collapse: collapse; | 180 | border-collapse: collapse; |
164 | border: solid 1px #777; | 181 | border: solid 1px #777; |
165 | margin-left: 0.5em; | 182 | margin-left: 0.5em; |
166 | margin-bottom: 0.5em; | 183 | margin-bottom: 0.5em; |
167 | } | 184 | } |
168 | 185 | ||
169 | table#downloads th { | 186 | table#downloads th { |
170 | background-color: #ccc; | 187 | background-color: #ccc; |
171 | } | 188 | } |
172 | 189 | ||
173 | td#content { | 190 | td#content { |
174 | padding: 1em 0.5em; | 191 | padding: 1em 0.5em; |
175 | } | 192 | } |
176 | 193 | ||
177 | div#blob { | 194 | div#blob { |
178 | border: solid 1px black; | 195 | border: solid 1px black; |
179 | } | 196 | } |
180 | 197 | ||
181 | div.error { | 198 | div.error { |
182 | color: red; | 199 | color: red; |
183 | font-weight: bold; | 200 | font-weight: bold; |
184 | margin: 1em 2em; | 201 | margin: 1em 2em; |
185 | } | 202 | } |
186 | 203 | ||
187 | a.ls-blob, a.ls-dir, a.ls-mod { | 204 | a.ls-blob, a.ls-dir, a.ls-mod { |
188 | font-family: monospace; | 205 | font-family: monospace; |
189 | } | 206 | } |
190 | 207 | ||
191 | td.ls-size { | 208 | td.ls-size { |
192 | text-align: right; | 209 | text-align: right; |
193 | } | 210 | } |
194 | 211 | ||
195 | td.ls-size { | 212 | td.ls-size { |
196 | font-family: monospace; | 213 | font-family: monospace; |
197 | } | 214 | } |
198 | 215 | ||
199 | td.ls-mode { | 216 | td.ls-mode { |
200 | font-family: monospace; | 217 | font-family: monospace; |
201 | } | 218 | } |
202 | 219 | ||
203 | table.blob { | 220 | table.blob { |
@@ -113,96 +113,97 @@ struct reflist { | |||
113 | int alloc; | 113 | int alloc; |
114 | int count; | 114 | int count; |
115 | }; | 115 | }; |
116 | 116 | ||
117 | extern const char *cgit_version; | 117 | extern const char *cgit_version; |
118 | 118 | ||
119 | extern struct repolist cgit_repolist; | 119 | extern struct repolist cgit_repolist; |
120 | extern struct repoinfo *cgit_repo; | 120 | extern struct repoinfo *cgit_repo; |
121 | extern int cgit_cmd; | 121 | extern int cgit_cmd; |
122 | 122 | ||
123 | extern char *cgit_root_title; | 123 | extern char *cgit_root_title; |
124 | extern char *cgit_css; | 124 | extern char *cgit_css; |
125 | extern char *cgit_logo; | 125 | extern char *cgit_logo; |
126 | extern char *cgit_index_header; | 126 | extern char *cgit_index_header; |
127 | extern char *cgit_logo_link; | 127 | extern char *cgit_logo_link; |
128 | extern char *cgit_module_link; | 128 | extern char *cgit_module_link; |
129 | extern char *cgit_agefile; | 129 | extern char *cgit_agefile; |
130 | extern char *cgit_virtual_root; | 130 | extern char *cgit_virtual_root; |
131 | extern char *cgit_script_name; | 131 | extern char *cgit_script_name; |
132 | extern char *cgit_cache_root; | 132 | extern char *cgit_cache_root; |
133 | extern char *cgit_repo_group; | 133 | extern char *cgit_repo_group; |
134 | 134 | ||
135 | extern int cgit_nocache; | 135 | extern int cgit_nocache; |
136 | extern int cgit_snapshots; | 136 | extern int cgit_snapshots; |
137 | extern int cgit_enable_index_links; | 137 | extern int cgit_enable_index_links; |
138 | extern int cgit_enable_log_filecount; | 138 | extern int cgit_enable_log_filecount; |
139 | extern int cgit_enable_log_linecount; | 139 | extern int cgit_enable_log_linecount; |
140 | extern int cgit_max_lock_attempts; | 140 | extern int cgit_max_lock_attempts; |
141 | extern int cgit_cache_root_ttl; | 141 | extern int cgit_cache_root_ttl; |
142 | extern int cgit_cache_repo_ttl; | 142 | extern int cgit_cache_repo_ttl; |
143 | extern int cgit_cache_dynamic_ttl; | 143 | extern int cgit_cache_dynamic_ttl; |
144 | extern int cgit_cache_static_ttl; | 144 | extern int cgit_cache_static_ttl; |
145 | extern int cgit_cache_max_create_time; | 145 | extern int cgit_cache_max_create_time; |
146 | extern int cgit_summary_log; | 146 | extern int cgit_summary_log; |
147 | extern int cgit_summary_tags; | 147 | extern int cgit_summary_tags; |
148 | extern int cgit_summary_branches; | 148 | extern int cgit_summary_branches; |
149 | 149 | ||
150 | extern int cgit_max_msg_len; | 150 | extern int cgit_max_msg_len; |
151 | extern int cgit_max_repodesc_len; | 151 | extern int cgit_max_repodesc_len; |
152 | extern int cgit_max_commit_count; | 152 | extern int cgit_max_commit_count; |
153 | 153 | ||
154 | extern int cgit_query_has_symref; | 154 | extern int cgit_query_has_symref; |
155 | extern int cgit_query_has_sha1; | 155 | extern int cgit_query_has_sha1; |
156 | 156 | ||
157 | extern char *cgit_querystring; | 157 | extern char *cgit_querystring; |
158 | extern char *cgit_query_repo; | 158 | extern char *cgit_query_repo; |
159 | extern char *cgit_query_page; | 159 | extern char *cgit_query_page; |
160 | extern char *cgit_query_search; | 160 | extern char *cgit_query_search; |
161 | extern char *cgit_query_grep; | ||
161 | extern char *cgit_query_head; | 162 | extern char *cgit_query_head; |
162 | extern char *cgit_query_sha1; | 163 | extern char *cgit_query_sha1; |
163 | extern char *cgit_query_sha2; | 164 | extern char *cgit_query_sha2; |
164 | extern char *cgit_query_path; | 165 | extern char *cgit_query_path; |
165 | extern char *cgit_query_name; | 166 | extern char *cgit_query_name; |
166 | extern int cgit_query_ofs; | 167 | extern int cgit_query_ofs; |
167 | 168 | ||
168 | extern int htmlfd; | 169 | extern int htmlfd; |
169 | 170 | ||
170 | extern int cgit_get_cmd_index(const char *cmd); | 171 | extern int cgit_get_cmd_index(const char *cmd); |
171 | extern struct repoinfo *cgit_get_repoinfo(const char *url); | 172 | extern struct repoinfo *cgit_get_repoinfo(const char *url); |
172 | extern void cgit_global_config_cb(const char *name, const char *value); | 173 | extern void cgit_global_config_cb(const char *name, const char *value); |
173 | extern void cgit_repo_config_cb(const char *name, const char *value); | 174 | extern void cgit_repo_config_cb(const char *name, const char *value); |
174 | extern void cgit_querystring_cb(const char *name, const char *value); | 175 | extern void cgit_querystring_cb(const char *name, const char *value); |
175 | 176 | ||
176 | extern int chk_zero(int result, char *msg); | 177 | extern int chk_zero(int result, char *msg); |
177 | extern int chk_positive(int result, char *msg); | 178 | extern int chk_positive(int result, char *msg); |
178 | extern int chk_non_negative(int result, char *msg); | 179 | extern int chk_non_negative(int result, char *msg); |
179 | 180 | ||
180 | extern int hextoint(char c); | 181 | extern int hextoint(char c); |
181 | extern char *trim_end(const char *str, char c); | 182 | extern char *trim_end(const char *str, char c); |
182 | 183 | ||
183 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); | 184 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); |
184 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, | 185 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, |
185 | int flags, void *cb_data); | 186 | int flags, void *cb_data); |
186 | 187 | ||
187 | extern void *cgit_free_commitinfo(struct commitinfo *info); | 188 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
188 | 189 | ||
189 | extern int cgit_diff_files(const unsigned char *old_sha1, | 190 | extern int cgit_diff_files(const unsigned char *old_sha1, |
190 | const unsigned char *new_sha1, | 191 | const unsigned char *new_sha1, |
191 | linediff_fn fn); | 192 | linediff_fn fn); |
192 | 193 | ||
193 | extern void cgit_diff_tree(const unsigned char *old_sha1, | 194 | extern void cgit_diff_tree(const unsigned char *old_sha1, |
194 | const unsigned char *new_sha1, | 195 | const unsigned char *new_sha1, |
195 | filepair_fn fn, const char *prefix); | 196 | filepair_fn fn, const char *prefix); |
196 | 197 | ||
197 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); | 198 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); |
198 | 199 | ||
199 | extern char *fmt(const char *format,...); | 200 | extern char *fmt(const char *format,...); |
200 | 201 | ||
201 | extern void html(const char *txt); | 202 | extern void html(const char *txt); |
202 | extern void htmlf(const char *format,...); | 203 | extern void htmlf(const char *format,...); |
203 | extern void html_txt(char *txt); | 204 | extern void html_txt(char *txt); |
204 | extern void html_ntxt(int len, char *txt); | 205 | extern void html_ntxt(int len, char *txt); |
205 | extern void html_attr(char *txt); | 206 | extern void html_attr(char *txt); |
206 | extern void html_hidden(char *name, char *value); | 207 | extern void html_hidden(char *name, char *value); |
207 | extern void html_option(char *value, char *text, char *selected_value); | 208 | extern void html_option(char *value, char *text, char *selected_value); |
208 | extern void html_link_open(char *url, char *title, char *class); | 209 | extern void html_link_open(char *url, char *title, char *class); |
@@ -215,63 +216,64 @@ extern int cgit_parse_query(char *txt, configfn fn); | |||
215 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); | 216 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
216 | extern struct taginfo *cgit_parse_tag(struct tag *tag); | 217 | extern struct taginfo *cgit_parse_tag(struct tag *tag); |
217 | extern void cgit_parse_url(const char *url); | 218 | extern void cgit_parse_url(const char *url); |
218 | 219 | ||
219 | extern char *cache_safe_filename(const char *unsafe); | 220 | extern char *cache_safe_filename(const char *unsafe); |
220 | extern int cache_lock(struct cacheitem *item); | 221 | extern int cache_lock(struct cacheitem *item); |
221 | extern int cache_unlock(struct cacheitem *item); | 222 | extern int cache_unlock(struct cacheitem *item); |
222 | extern int cache_cancel_lock(struct cacheitem *item); | 223 | extern int cache_cancel_lock(struct cacheitem *item); |
223 | extern int cache_exist(struct cacheitem *item); | 224 | extern int cache_exist(struct cacheitem *item); |
224 | extern int cache_expired(struct cacheitem *item); | 225 | extern int cache_expired(struct cacheitem *item); |
225 | 226 | ||
226 | extern char *cgit_repourl(const char *reponame); | 227 | extern char *cgit_repourl(const char *reponame); |
227 | extern char *cgit_fileurl(const char *reponame, const char *pagename, | 228 | extern char *cgit_fileurl(const char *reponame, const char *pagename, |
228 | const char *filename, const char *query); | 229 | const char *filename, const char *query); |
229 | extern char *cgit_pageurl(const char *reponame, const char *pagename, | 230 | extern char *cgit_pageurl(const char *reponame, const char *pagename, |
230 | const char *query); | 231 | const char *query); |
231 | 232 | ||
232 | extern const char *cgit_repobasename(const char *reponame); | 233 | extern const char *cgit_repobasename(const char *reponame); |
233 | 234 | ||
234 | extern void cgit_tree_link(char *name, char *title, char *class, char *head, | 235 | extern void cgit_tree_link(char *name, char *title, char *class, char *head, |
235 | char *rev, char *path); | 236 | char *rev, char *path); |
236 | extern void cgit_log_link(char *name, char *title, char *class, char *head, | 237 | extern void cgit_log_link(char *name, char *title, char *class, char *head, |
237 | char *rev, char *path, int ofs); | 238 | char *rev, char *path, int ofs); |
238 | extern void cgit_commit_link(char *name, char *title, char *class, char *head, | 239 | extern void cgit_commit_link(char *name, char *title, char *class, char *head, |
239 | char *rev); | 240 | char *rev); |
240 | extern void cgit_refs_link(char *name, char *title, char *class, char *head, | 241 | extern void cgit_refs_link(char *name, char *title, char *class, char *head, |
241 | char *rev, char *path); | 242 | char *rev, char *path); |
242 | extern void cgit_snapshot_link(char *name, char *title, char *class, | 243 | extern void cgit_snapshot_link(char *name, char *title, char *class, |
243 | char *head, char *rev, char *archivename); | 244 | char *head, char *rev, char *archivename); |
244 | extern void cgit_diff_link(char *name, char *title, char *class, char *head, | 245 | extern void cgit_diff_link(char *name, char *title, char *class, char *head, |
245 | char *new_rev, char *old_rev, char *path); | 246 | char *new_rev, char *old_rev, char *path); |
246 | 247 | ||
247 | extern void cgit_object_link(struct object *obj); | 248 | extern void cgit_object_link(struct object *obj); |
248 | 249 | ||
249 | extern void cgit_print_error(char *msg); | 250 | extern void cgit_print_error(char *msg); |
250 | extern void cgit_print_date(time_t secs, char *format); | 251 | extern void cgit_print_date(time_t secs, char *format); |
251 | extern void cgit_print_age(time_t t, time_t max_relative, char *format); | 252 | extern void cgit_print_age(time_t t, time_t max_relative, char *format); |
252 | extern void cgit_print_docstart(char *title, struct cacheitem *item); | 253 | extern void cgit_print_docstart(char *title, struct cacheitem *item); |
253 | extern void cgit_print_docend(); | 254 | extern void cgit_print_docend(); |
254 | extern void cgit_print_pageheader(char *title, int show_search); | 255 | extern void cgit_print_pageheader(char *title, int show_search); |
255 | extern void cgit_print_snapshot_start(const char *mimetype, | 256 | extern void cgit_print_snapshot_start(const char *mimetype, |
256 | const char *filename, | 257 | const char *filename, |
257 | struct cacheitem *item); | 258 | struct cacheitem *item); |
258 | extern void cgit_print_branches(int maxcount); | 259 | extern void cgit_print_branches(int maxcount); |
259 | extern void cgit_print_tags(int maxcount); | 260 | extern void cgit_print_tags(int maxcount); |
260 | 261 | ||
261 | extern void cgit_print_repolist(struct cacheitem *item); | 262 | extern void cgit_print_repolist(struct cacheitem *item); |
262 | extern void cgit_print_summary(); | 263 | extern void cgit_print_summary(); |
263 | extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, int pager); | 264 | extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, |
265 | char *pattern, char *path, int pager); | ||
264 | extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); | 266 | extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); |
265 | extern void cgit_print_tree(const char *rev, char *path); | 267 | extern void cgit_print_tree(const char *rev, char *path); |
266 | extern void cgit_print_commit(char *hex); | 268 | extern void cgit_print_commit(char *hex); |
267 | extern void cgit_print_refs(); | 269 | extern void cgit_print_refs(); |
268 | extern void cgit_print_tag(char *revname); | 270 | extern void cgit_print_tag(char *revname); |
269 | extern void cgit_print_diff(const char *new_hex, const char *old_hex, const char *prefix); | 271 | extern void cgit_print_diff(const char *new_hex, const char *old_hex, const char *prefix); |
270 | extern void cgit_print_snapshot(struct cacheitem *item, const char *head, | 272 | extern void cgit_print_snapshot(struct cacheitem *item, const char *head, |
271 | const char *hex, const char *prefix, | 273 | const char *hex, const char *prefix, |
272 | const char *filename, int snapshot); | 274 | const char *filename, int snapshot); |
273 | extern void cgit_print_snapshot_links(const char *repo, const char *head, | 275 | extern void cgit_print_snapshot_links(const char *repo, const char *head, |
274 | const char *hex, int snapshots); | 276 | const char *hex, int snapshots); |
275 | extern int cgit_parse_snapshots_mask(const char *str); | 277 | extern int cgit_parse_snapshots_mask(const char *str); |
276 | 278 | ||
277 | #endif /* CGIT_H */ | 279 | #endif /* CGIT_H */ |
@@ -9,96 +9,97 @@ | |||
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 = CGIT_CACHE_ROOT; | 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 | int cgit_summary_tags = 0; | 41 | int cgit_summary_tags = 0; |
42 | int cgit_summary_branches = 0; | 42 | int cgit_summary_branches = 0; |
43 | int cgit_renamelimit = -1; | 43 | int cgit_renamelimit = -1; |
44 | 44 | ||
45 | int cgit_max_msg_len = 60; | 45 | int cgit_max_msg_len = 60; |
46 | int cgit_max_repodesc_len = 60; | 46 | int cgit_max_repodesc_len = 60; |
47 | int cgit_max_commit_count = 50; | 47 | int cgit_max_commit_count = 50; |
48 | 48 | ||
49 | int cgit_query_has_symref = 0; | 49 | int cgit_query_has_symref = 0; |
50 | int cgit_query_has_sha1 = 0; | 50 | int cgit_query_has_sha1 = 0; |
51 | 51 | ||
52 | char *cgit_querystring = NULL; | 52 | char *cgit_querystring = NULL; |
53 | char *cgit_query_repo = NULL; | 53 | char *cgit_query_repo = NULL; |
54 | char *cgit_query_page = NULL; | 54 | char *cgit_query_page = NULL; |
55 | char *cgit_query_head = NULL; | 55 | char *cgit_query_head = NULL; |
56 | char *cgit_query_search = NULL; | 56 | char *cgit_query_search = NULL; |
57 | char *cgit_query_grep = NULL; | ||
57 | char *cgit_query_sha1 = NULL; | 58 | char *cgit_query_sha1 = NULL; |
58 | char *cgit_query_sha2 = NULL; | 59 | char *cgit_query_sha2 = NULL; |
59 | char *cgit_query_path = NULL; | 60 | char *cgit_query_path = NULL; |
60 | char *cgit_query_name = NULL; | 61 | char *cgit_query_name = NULL; |
61 | int cgit_query_ofs = 0; | 62 | int cgit_query_ofs = 0; |
62 | 63 | ||
63 | int htmlfd = 0; | 64 | int htmlfd = 0; |
64 | 65 | ||
65 | 66 | ||
66 | int cgit_get_cmd_index(const char *cmd) | 67 | int cgit_get_cmd_index(const char *cmd) |
67 | { | 68 | { |
68 | static char *cmds[] = {"log", "commit", "diff", "tree", "blob", | 69 | static char *cmds[] = {"log", "commit", "diff", "tree", "blob", |
69 | "snapshot", "tag", "refs", NULL}; | 70 | "snapshot", "tag", "refs", NULL}; |
70 | int i; | 71 | int i; |
71 | 72 | ||
72 | for(i = 0; cmds[i]; i++) | 73 | for(i = 0; cmds[i]; i++) |
73 | if (!strcmp(cmd, cmds[i])) | 74 | if (!strcmp(cmd, cmds[i])) |
74 | return i + 1; | 75 | return i + 1; |
75 | return 0; | 76 | return 0; |
76 | } | 77 | } |
77 | 78 | ||
78 | int chk_zero(int result, char *msg) | 79 | int chk_zero(int result, char *msg) |
79 | { | 80 | { |
80 | if (result != 0) | 81 | if (result != 0) |
81 | die("%s: %s", msg, strerror(errno)); | 82 | die("%s: %s", msg, strerror(errno)); |
82 | return result; | 83 | return result; |
83 | } | 84 | } |
84 | 85 | ||
85 | int chk_positive(int result, char *msg) | 86 | int chk_positive(int result, char *msg) |
86 | { | 87 | { |
87 | if (result <= 0) | 88 | if (result <= 0) |
88 | die("%s: %s", msg, strerror(errno)); | 89 | die("%s: %s", msg, strerror(errno)); |
89 | return result; | 90 | return result; |
90 | } | 91 | } |
91 | 92 | ||
92 | int chk_non_negative(int result, char *msg) | 93 | int chk_non_negative(int result, char *msg) |
93 | { | 94 | { |
94 | if (result < 0) | 95 | if (result < 0) |
95 | die("%s: %s",msg, strerror(errno)); | 96 | die("%s: %s",msg, strerror(errno)); |
96 | return result; | 97 | return result; |
97 | } | 98 | } |
98 | 99 | ||
99 | struct repoinfo *add_repo(const char *url) | 100 | struct repoinfo *add_repo(const char *url) |
100 | { | 101 | { |
101 | struct repoinfo *ret; | 102 | struct repoinfo *ret; |
102 | 103 | ||
103 | if (++cgit_repolist.count > cgit_repolist.length) { | 104 | if (++cgit_repolist.count > cgit_repolist.length) { |
104 | if (cgit_repolist.length == 0) | 105 | if (cgit_repolist.length == 0) |
@@ -187,96 +188,98 @@ void cgit_global_config_cb(const char *name, const char *value) | |||
187 | cgit_summary_branches = atoi(value); | 188 | cgit_summary_branches = atoi(value); |
188 | else if (!strcmp(name, "summary-tags")) | 189 | else if (!strcmp(name, "summary-tags")) |
189 | cgit_summary_tags = atoi(value); | 190 | cgit_summary_tags = atoi(value); |
190 | else if (!strcmp(name, "agefile")) | 191 | else if (!strcmp(name, "agefile")) |
191 | cgit_agefile = xstrdup(value); | 192 | cgit_agefile = xstrdup(value); |
192 | else if (!strcmp(name, "renamelimit")) | 193 | else if (!strcmp(name, "renamelimit")) |
193 | cgit_renamelimit = atoi(value); | 194 | cgit_renamelimit = atoi(value); |
194 | else if (!strcmp(name, "repo.group")) | 195 | else if (!strcmp(name, "repo.group")) |
195 | cgit_repo_group = xstrdup(value); | 196 | cgit_repo_group = xstrdup(value); |
196 | else if (!strcmp(name, "repo.url")) | 197 | else if (!strcmp(name, "repo.url")) |
197 | cgit_repo = add_repo(value); | 198 | cgit_repo = add_repo(value); |
198 | else if (!strcmp(name, "repo.name")) | 199 | else if (!strcmp(name, "repo.name")) |
199 | cgit_repo->name = xstrdup(value); | 200 | cgit_repo->name = xstrdup(value); |
200 | else if (cgit_repo && !strcmp(name, "repo.path")) | 201 | else if (cgit_repo && !strcmp(name, "repo.path")) |
201 | cgit_repo->path = trim_end(value, '/'); | 202 | cgit_repo->path = trim_end(value, '/'); |
202 | else if (cgit_repo && !strcmp(name, "repo.desc")) | 203 | else if (cgit_repo && !strcmp(name, "repo.desc")) |
203 | cgit_repo->desc = xstrdup(value); | 204 | cgit_repo->desc = xstrdup(value); |
204 | else if (cgit_repo && !strcmp(name, "repo.owner")) | 205 | else if (cgit_repo && !strcmp(name, "repo.owner")) |
205 | cgit_repo->owner = xstrdup(value); | 206 | cgit_repo->owner = xstrdup(value); |
206 | else if (cgit_repo && !strcmp(name, "repo.defbranch")) | 207 | else if (cgit_repo && !strcmp(name, "repo.defbranch")) |
207 | cgit_repo->defbranch = xstrdup(value); | 208 | cgit_repo->defbranch = xstrdup(value); |
208 | else if (cgit_repo && !strcmp(name, "repo.snapshots")) | 209 | else if (cgit_repo && !strcmp(name, "repo.snapshots")) |
209 | cgit_repo->snapshots = cgit_snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ | 210 | cgit_repo->snapshots = cgit_snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ |
210 | else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) | 211 | else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) |
211 | cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value); | 212 | cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value); |
212 | else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) | 213 | else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) |
213 | cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value); | 214 | cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value); |
214 | else if (cgit_repo && !strcmp(name, "repo.module-link")) | 215 | else if (cgit_repo && !strcmp(name, "repo.module-link")) |
215 | cgit_repo->module_link= xstrdup(value); | 216 | cgit_repo->module_link= xstrdup(value); |
216 | else if (cgit_repo && !strcmp(name, "repo.readme") && value != NULL) { | 217 | else if (cgit_repo && !strcmp(name, "repo.readme") && value != NULL) { |
217 | if (*value == '/') | 218 | if (*value == '/') |
218 | cgit_repo->readme = xstrdup(value); | 219 | cgit_repo->readme = xstrdup(value); |
219 | else | 220 | else |
220 | cgit_repo->readme = xstrdup(fmt("%s/%s", cgit_repo->path, value)); | 221 | cgit_repo->readme = xstrdup(fmt("%s/%s", cgit_repo->path, value)); |
221 | } else if (!strcmp(name, "include")) | 222 | } else if (!strcmp(name, "include")) |
222 | cgit_read_config(value, cgit_global_config_cb); | 223 | cgit_read_config(value, cgit_global_config_cb); |
223 | } | 224 | } |
224 | 225 | ||
225 | void cgit_querystring_cb(const char *name, const char *value) | 226 | void cgit_querystring_cb(const char *name, const char *value) |
226 | { | 227 | { |
227 | if (!strcmp(name,"r")) { | 228 | if (!strcmp(name,"r")) { |
228 | cgit_query_repo = xstrdup(value); | 229 | cgit_query_repo = xstrdup(value); |
229 | cgit_repo = cgit_get_repoinfo(value); | 230 | cgit_repo = cgit_get_repoinfo(value); |
230 | } else if (!strcmp(name, "p")) { | 231 | } else if (!strcmp(name, "p")) { |
231 | cgit_query_page = xstrdup(value); | 232 | cgit_query_page = xstrdup(value); |
232 | cgit_cmd = cgit_get_cmd_index(value); | 233 | cgit_cmd = cgit_get_cmd_index(value); |
233 | } else if (!strcmp(name, "url")) { | 234 | } else if (!strcmp(name, "url")) { |
234 | cgit_parse_url(value); | 235 | cgit_parse_url(value); |
236 | } else if (!strcmp(name, "qt")) { | ||
237 | cgit_query_grep = xstrdup(value); | ||
235 | } else if (!strcmp(name, "q")) { | 238 | } else if (!strcmp(name, "q")) { |
236 | cgit_query_search = xstrdup(value); | 239 | cgit_query_search = xstrdup(value); |
237 | } else if (!strcmp(name, "h")) { | 240 | } else if (!strcmp(name, "h")) { |
238 | cgit_query_head = xstrdup(value); | 241 | cgit_query_head = xstrdup(value); |
239 | cgit_query_has_symref = 1; | 242 | cgit_query_has_symref = 1; |
240 | } else if (!strcmp(name, "id")) { | 243 | } else if (!strcmp(name, "id")) { |
241 | cgit_query_sha1 = xstrdup(value); | 244 | cgit_query_sha1 = xstrdup(value); |
242 | cgit_query_has_sha1 = 1; | 245 | cgit_query_has_sha1 = 1; |
243 | } else if (!strcmp(name, "id2")) { | 246 | } else if (!strcmp(name, "id2")) { |
244 | cgit_query_sha2 = xstrdup(value); | 247 | cgit_query_sha2 = xstrdup(value); |
245 | cgit_query_has_sha1 = 1; | 248 | cgit_query_has_sha1 = 1; |
246 | } else if (!strcmp(name, "ofs")) { | 249 | } else if (!strcmp(name, "ofs")) { |
247 | cgit_query_ofs = atoi(value); | 250 | cgit_query_ofs = atoi(value); |
248 | } else if (!strcmp(name, "path")) { | 251 | } else if (!strcmp(name, "path")) { |
249 | cgit_query_path = trim_end(value, '/'); | 252 | cgit_query_path = trim_end(value, '/'); |
250 | } else if (!strcmp(name, "name")) { | 253 | } else if (!strcmp(name, "name")) { |
251 | cgit_query_name = xstrdup(value); | 254 | cgit_query_name = xstrdup(value); |
252 | } | 255 | } |
253 | } | 256 | } |
254 | 257 | ||
255 | void *cgit_free_commitinfo(struct commitinfo *info) | 258 | void *cgit_free_commitinfo(struct commitinfo *info) |
256 | { | 259 | { |
257 | free(info->author); | 260 | free(info->author); |
258 | free(info->author_email); | 261 | free(info->author_email); |
259 | free(info->committer); | 262 | free(info->committer); |
260 | free(info->committer_email); | 263 | free(info->committer_email); |
261 | free(info->subject); | 264 | free(info->subject); |
262 | free(info); | 265 | free(info); |
263 | return NULL; | 266 | return NULL; |
264 | } | 267 | } |
265 | 268 | ||
266 | int hextoint(char c) | 269 | int hextoint(char c) |
267 | { | 270 | { |
268 | if (c >= 'a' && c <= 'f') | 271 | if (c >= 'a' && c <= 'f') |
269 | return 10 + c - 'a'; | 272 | return 10 + c - 'a'; |
270 | else if (c >= 'A' && c <= 'F') | 273 | else if (c >= 'A' && c <= 'F') |
271 | return 10 + c - 'A'; | 274 | return 10 + c - 'A'; |
272 | else if (c >= '0' && c <= '9') | 275 | else if (c >= '0' && c <= '9') |
273 | return c - '0'; | 276 | return c - '0'; |
274 | else | 277 | else |
275 | return -1; | 278 | return -1; |
276 | } | 279 | } |
277 | 280 | ||
278 | char *trim_end(const char *str, char c) | 281 | char *trim_end(const char *str, char c) |
279 | { | 282 | { |
280 | int len; | 283 | int len; |
281 | char *s, *t; | 284 | char *s, *t; |
282 | 285 | ||
@@ -6,109 +6,112 @@ | |||
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 | int files, lines; | 11 | int files, lines; |
12 | 12 | ||
13 | void count_lines(char *line, int size) | 13 | void count_lines(char *line, int size) |
14 | { | 14 | { |
15 | if (size>0 && (line[0] == '+' || line[0] == '-')) | 15 | if (size>0 && (line[0] == '+' || line[0] == '-')) |
16 | lines++; | 16 | lines++; |
17 | } | 17 | } |
18 | 18 | ||
19 | void inspect_files(struct diff_filepair *pair) | 19 | void inspect_files(struct diff_filepair *pair) |
20 | { | 20 | { |
21 | files++; | 21 | files++; |
22 | if (cgit_repo->enable_log_linecount) | 22 | if (cgit_repo->enable_log_linecount) |
23 | cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines); | 23 | cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines); |
24 | } | 24 | } |
25 | 25 | ||
26 | void print_commit(struct commit *commit) | 26 | void print_commit(struct commit *commit) |
27 | { | 27 | { |
28 | struct commitinfo *info; | 28 | struct commitinfo *info; |
29 | 29 | ||
30 | info = cgit_parse_commit(commit); | 30 | info = cgit_parse_commit(commit); |
31 | html("<tr><td>"); | 31 | html("<tr><td>"); |
32 | cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); | 32 | cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); |
33 | html("</td><td>"); | 33 | html("</td><td>"); |
34 | cgit_commit_link(info->subject, NULL, NULL, cgit_query_head, | 34 | cgit_commit_link(info->subject, NULL, NULL, cgit_query_head, |
35 | sha1_to_hex(commit->object.sha1)); | 35 | sha1_to_hex(commit->object.sha1)); |
36 | if (cgit_repo->enable_log_filecount) { | 36 | if (cgit_repo->enable_log_filecount) { |
37 | files = 0; | 37 | files = 0; |
38 | lines = 0; | 38 | lines = 0; |
39 | cgit_diff_commit(commit, inspect_files); | 39 | cgit_diff_commit(commit, inspect_files); |
40 | html("</td><td class='right'>"); | 40 | html("</td><td class='right'>"); |
41 | htmlf("%d", files); | 41 | htmlf("%d", files); |
42 | if (cgit_repo->enable_log_linecount) { | 42 | if (cgit_repo->enable_log_linecount) { |
43 | html("</td><td class='right'>"); | 43 | html("</td><td class='right'>"); |
44 | htmlf("%d", lines); | 44 | htmlf("%d", lines); |
45 | } | 45 | } |
46 | } | 46 | } |
47 | html("</td><td>"); | 47 | html("</td><td>"); |
48 | html_txt(info->author); | 48 | html_txt(info->author); |
49 | html("</td></tr>\n"); | 49 | html("</td></tr>\n"); |
50 | cgit_free_commitinfo(info); | 50 | cgit_free_commitinfo(info); |
51 | } | 51 | } |
52 | 52 | ||
53 | 53 | ||
54 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, int pager) | 54 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, char *path, int pager) |
55 | { | 55 | { |
56 | struct rev_info rev; | 56 | struct rev_info rev; |
57 | struct commit *commit; | 57 | struct commit *commit; |
58 | const char *argv[] = {NULL, tip, NULL, NULL, NULL}; | 58 | const char *argv[] = {NULL, tip, NULL, NULL, NULL}; |
59 | int argc = 2; | 59 | int argc = 2; |
60 | int i; | 60 | int i; |
61 | 61 | ||
62 | if (!tip) | 62 | if (!tip) |
63 | argv[1] = cgit_query_head; | 63 | argv[1] = cgit_query_head; |
64 | 64 | ||
65 | if (grep) | 65 | if (grep && pattern && (!strcmp(grep, "grep") || |
66 | argv[argc++] = fmt("--grep=%s", grep); | 66 | !strcmp(grep, "author") || |
67 | !strcmp(grep, "committer"))) | ||
68 | argv[argc++] = fmt("--%s=%s", grep, pattern); | ||
69 | |||
67 | if (path) { | 70 | if (path) { |
68 | argv[argc++] = "--"; | 71 | argv[argc++] = "--"; |
69 | argv[argc++] = path; | 72 | argv[argc++] = path; |
70 | } | 73 | } |
71 | init_revisions(&rev, NULL); | 74 | init_revisions(&rev, NULL); |
72 | rev.abbrev = DEFAULT_ABBREV; | 75 | rev.abbrev = DEFAULT_ABBREV; |
73 | rev.commit_format = CMIT_FMT_DEFAULT; | 76 | rev.commit_format = CMIT_FMT_DEFAULT; |
74 | rev.verbose_header = 1; | 77 | rev.verbose_header = 1; |
75 | rev.show_root_diff = 0; | 78 | rev.show_root_diff = 0; |
76 | setup_revisions(argc, argv, &rev, NULL); | 79 | setup_revisions(argc, argv, &rev, NULL); |
77 | if (rev.grep_filter) { | 80 | if (rev.grep_filter) { |
78 | rev.grep_filter->regflags |= REG_ICASE; | 81 | rev.grep_filter->regflags |= REG_ICASE; |
79 | compile_grep_patterns(rev.grep_filter); | 82 | compile_grep_patterns(rev.grep_filter); |
80 | } | 83 | } |
81 | prepare_revision_walk(&rev); | 84 | prepare_revision_walk(&rev); |
82 | 85 | ||
83 | html("<table class='list nowrap'>"); | 86 | html("<table class='list nowrap'>"); |
84 | html("<tr class='nohover'><th class='left'>Age</th>" | 87 | html("<tr class='nohover'><th class='left'>Age</th>" |
85 | "<th class='left'>Message</th>"); | 88 | "<th class='left'>Message</th>"); |
86 | 89 | ||
87 | if (cgit_repo->enable_log_filecount) { | 90 | if (cgit_repo->enable_log_filecount) { |
88 | html("<th class='left'>Files</th>"); | 91 | html("<th class='left'>Files</th>"); |
89 | if (cgit_repo->enable_log_linecount) | 92 | if (cgit_repo->enable_log_linecount) |
90 | html("<th class='left'>Lines</th>"); | 93 | html("<th class='left'>Lines</th>"); |
91 | } | 94 | } |
92 | html("<th class='left'>Author</th></tr>\n"); | 95 | html("<th class='left'>Author</th></tr>\n"); |
93 | 96 | ||
94 | if (ofs<0) | 97 | if (ofs<0) |
95 | ofs = 0; | 98 | ofs = 0; |
96 | 99 | ||
97 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { | 100 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { |
98 | free(commit->buffer); | 101 | free(commit->buffer); |
99 | commit->buffer = NULL; | 102 | commit->buffer = NULL; |
100 | free_commit_list(commit->parents); | 103 | free_commit_list(commit->parents); |
101 | commit->parents = NULL; | 104 | commit->parents = NULL; |
102 | } | 105 | } |
103 | 106 | ||
104 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { | 107 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { |
105 | print_commit(commit); | 108 | print_commit(commit); |
106 | free(commit->buffer); | 109 | free(commit->buffer); |
107 | commit->buffer = NULL; | 110 | commit->buffer = NULL; |
108 | free_commit_list(commit->parents); | 111 | free_commit_list(commit->parents); |
109 | commit->parents = NULL; | 112 | commit->parents = NULL; |
110 | } | 113 | } |
111 | html("</table>\n"); | 114 | html("</table>\n"); |
112 | 115 | ||
113 | if (pager) { | 116 | if (pager) { |
114 | html("<div class='pager'>"); | 117 | html("<div class='pager'>"); |
diff --git a/ui-shared.c b/ui-shared.c index e4bb98f..45105dc 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -372,68 +372,73 @@ void cgit_print_pageheader(char *title, int show_search) | |||
372 | html_txt(cgit_root_title); | 372 | html_txt(cgit_root_title); |
373 | html("</a></td><td id='logo'>"); | 373 | html("</a></td><td id='logo'>"); |
374 | html("<a href='"); | 374 | html("<a href='"); |
375 | html_attr(cgit_logo_link); | 375 | html_attr(cgit_logo_link); |
376 | htmlf("'><img src='%s' alt='logo'/></a>", cgit_logo); | 376 | htmlf("'><img src='%s' alt='logo'/></a>", cgit_logo); |
377 | html("</td></tr>"); | 377 | html("</td></tr>"); |
378 | html("<tr><td id='crumb'>"); | 378 | html("<tr><td id='crumb'>"); |
379 | if (cgit_query_repo) { | 379 | if (cgit_query_repo) { |
380 | html_txt(cgit_repo->name); | 380 | html_txt(cgit_repo->name); |
381 | html(" ("); | 381 | html(" ("); |
382 | html_txt(cgit_query_head); | 382 | html_txt(cgit_query_head); |
383 | html(") : "); | 383 | html(") : "); |
384 | reporevlink(NULL, "summary", NULL, NULL, cgit_query_head, | 384 | reporevlink(NULL, "summary", NULL, NULL, cgit_query_head, |
385 | NULL, NULL); | 385 | NULL, NULL); |
386 | html(" "); | 386 | html(" "); |
387 | cgit_log_link("log", NULL, NULL, cgit_query_head, | 387 | cgit_log_link("log", NULL, NULL, cgit_query_head, |
388 | cgit_query_sha1, cgit_query_path, 0); | 388 | cgit_query_sha1, cgit_query_path, 0); |
389 | html(" "); | 389 | html(" "); |
390 | cgit_tree_link("tree", NULL, NULL, cgit_query_head, | 390 | cgit_tree_link("tree", NULL, NULL, cgit_query_head, |
391 | cgit_query_sha1, NULL); | 391 | cgit_query_sha1, NULL); |
392 | html(" "); | 392 | html(" "); |
393 | cgit_commit_link("commit", NULL, NULL, cgit_query_head, | 393 | cgit_commit_link("commit", NULL, NULL, cgit_query_head, |
394 | cgit_query_sha1); | 394 | cgit_query_sha1); |
395 | html(" "); | 395 | html(" "); |
396 | cgit_diff_link("diff", NULL, NULL, cgit_query_head, | 396 | cgit_diff_link("diff", NULL, NULL, cgit_query_head, |
397 | cgit_query_sha1, cgit_query_sha2, | 397 | cgit_query_sha1, cgit_query_sha2, |
398 | cgit_query_path); | 398 | cgit_query_path); |
399 | } else { | 399 | } else { |
400 | html_txt("Index of repositories"); | 400 | html_txt("Index of repositories"); |
401 | } | 401 | } |
402 | html("</td>"); | 402 | html("</td>"); |
403 | html("<td id='search'>"); | 403 | html("<td id='search'>"); |
404 | if (show_search) { | 404 | if (show_search) { |
405 | html("<form method='get' action='"); | 405 | html("<form method='get' action='"); |
406 | html_attr(cgit_currurl()); | 406 | html_attr(cgit_currurl()); |
407 | html("'>"); | 407 | html("'>"); |
408 | if (!cgit_virtual_root) { | 408 | if (!cgit_virtual_root) { |
409 | if (cgit_query_repo) | 409 | if (cgit_query_repo) |
410 | html_hidden("r", cgit_query_repo); | 410 | html_hidden("r", cgit_query_repo); |
411 | if (cgit_query_page) | 411 | if (cgit_query_page) |
412 | html_hidden("p", cgit_query_page); | 412 | html_hidden("p", cgit_query_page); |
413 | } | 413 | } |
414 | if (cgit_query_head) | 414 | if (cgit_query_head) |
415 | html_hidden("h", cgit_query_head); | 415 | html_hidden("h", cgit_query_head); |
416 | if (cgit_query_sha1) | 416 | if (cgit_query_sha1) |
417 | html_hidden("id", cgit_query_sha1); | 417 | html_hidden("id", cgit_query_sha1); |
418 | if (cgit_query_sha2) | 418 | if (cgit_query_sha2) |
419 | html_hidden("id2", cgit_query_sha2); | 419 | html_hidden("id2", cgit_query_sha2); |
420 | html("<input type='text' name='q' value='"); | 420 | html("<select name='qt'>"); |
421 | html_option("grep", "log msg", cgit_query_grep); | ||
422 | html_option("author", "author", cgit_query_grep); | ||
423 | html_option("committer", "committer", cgit_query_grep); | ||
424 | html("</select>"); | ||
425 | html("<input class='txt' type='text' name='q' value='"); | ||
421 | html_attr(cgit_query_search); | 426 | html_attr(cgit_query_search); |
422 | html("'/></form>"); | 427 | html("'/><input class='btn' type='submit' value='...'/></form>"); |
423 | } | 428 | } |
424 | html("</td></tr>"); | 429 | html("</td></tr>"); |
425 | html("<tr><td id='content' colspan='2'>"); | 430 | html("<tr><td id='content' colspan='2'>"); |
426 | } | 431 | } |
427 | 432 | ||
428 | void cgit_print_snapshot_start(const char *mimetype, const char *filename, | 433 | void cgit_print_snapshot_start(const char *mimetype, const char *filename, |
429 | struct cacheitem *item) | 434 | struct cacheitem *item) |
430 | { | 435 | { |
431 | htmlf("Content-Type: %s\n", mimetype); | 436 | htmlf("Content-Type: %s\n", mimetype); |
432 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); | 437 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); |
433 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); | 438 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); |
434 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + | 439 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + |
435 | ttl_seconds(item->ttl))); | 440 | ttl_seconds(item->ttl))); |
436 | html("\n"); | 441 | html("\n"); |
437 | } | 442 | } |
438 | 443 | ||
439 | /* vim:set sw=8: */ | 444 | /* vim:set sw=8: */ |
diff --git a/ui-summary.c b/ui-summary.c index 178e959..04a466a 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -191,57 +191,57 @@ void cgit_print_branches(int maxcount) | |||
191 | print_refs_link("heads"); | 191 | print_refs_link("heads"); |
192 | } | 192 | } |
193 | 193 | ||
194 | void cgit_print_tags(int maxcount) | 194 | void cgit_print_tags(int maxcount) |
195 | { | 195 | { |
196 | struct reflist list; | 196 | struct reflist list; |
197 | int i; | 197 | int i; |
198 | 198 | ||
199 | header = 0; | 199 | header = 0; |
200 | list.refs = NULL; | 200 | list.refs = NULL; |
201 | list.alloc = list.count = 0; | 201 | list.alloc = list.count = 0; |
202 | for_each_tag_ref(cgit_refs_cb, &list); | 202 | for_each_tag_ref(cgit_refs_cb, &list); |
203 | if (list.count == 0) | 203 | if (list.count == 0) |
204 | return; | 204 | return; |
205 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age); | 205 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age); |
206 | if (!maxcount) | 206 | if (!maxcount) |
207 | maxcount = list.count; | 207 | maxcount = list.count; |
208 | else if (maxcount > list.count) | 208 | else if (maxcount > list.count) |
209 | maxcount = list.count; | 209 | maxcount = list.count; |
210 | print_tag_header(); | 210 | print_tag_header(); |
211 | for(i=0; i<maxcount; i++) | 211 | for(i=0; i<maxcount; i++) |
212 | print_tag(list.refs[i]); | 212 | print_tag(list.refs[i]); |
213 | 213 | ||
214 | if (maxcount < list.count) | 214 | if (maxcount < list.count) |
215 | print_refs_link("tags"); | 215 | print_refs_link("tags"); |
216 | } | 216 | } |
217 | 217 | ||
218 | static void cgit_print_archives() | 218 | static void cgit_print_archives() |
219 | { | 219 | { |
220 | header = 0; | 220 | header = 0; |
221 | for_each_ref(cgit_print_archive_cb, NULL); | 221 | for_each_ref(cgit_print_archive_cb, NULL); |
222 | if (header) | 222 | if (header) |
223 | html("</table>"); | 223 | html("</table>"); |
224 | } | 224 | } |
225 | 225 | ||
226 | void cgit_print_summary() | 226 | void cgit_print_summary() |
227 | { | 227 | { |
228 | html("<div id='summary'>"); | 228 | html("<div id='summary'>"); |
229 | cgit_print_archives(); | 229 | cgit_print_archives(); |
230 | html("<h2>"); | 230 | html("<h2>"); |
231 | html_txt(cgit_repo->name); | 231 | html_txt(cgit_repo->name); |
232 | html(" - "); | 232 | html(" - "); |
233 | html_txt(cgit_repo->desc); | 233 | html_txt(cgit_repo->desc); |
234 | html("</h2>"); | 234 | html("</h2>"); |
235 | if (cgit_repo->readme) | 235 | if (cgit_repo->readme) |
236 | html_include(cgit_repo->readme); | 236 | html_include(cgit_repo->readme); |
237 | html("</div>"); | 237 | html("</div>"); |
238 | if (cgit_summary_log > 0) | 238 | if (cgit_summary_log > 0) |
239 | cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, NULL, 0); | 239 | cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, NULL, NULL, 0); |
240 | html("<table class='list nowrap'>"); | 240 | html("<table class='list nowrap'>"); |
241 | if (cgit_summary_log > 0) | 241 | if (cgit_summary_log > 0) |
242 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | 242 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); |
243 | cgit_print_branches(cgit_summary_branches); | 243 | cgit_print_branches(cgit_summary_branches); |
244 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | 244 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); |
245 | cgit_print_tags(cgit_summary_tags); | 245 | cgit_print_tags(cgit_summary_tags); |
246 | html("</table>"); | 246 | html("</table>"); |
247 | } | 247 | } |