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
@@ -85,25 +85,25 @@ static void cgit_print_repo_page(struct cacheitem *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: |
@@ -135,33 +135,50 @@ td#crumb a:hover { | |||
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 | } |
@@ -149,24 +149,25 @@ 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); |
@@ -251,25 +252,26 @@ 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); |
@@ -45,24 +45,25 @@ int cgit_renamelimit = -1; | |||
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", |
@@ -223,24 +224,26 @@ void cgit_global_config_cb(const char *name, const char *value) | |||
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")) { |
@@ -42,37 +42,40 @@ void print_commit(struct commit *commit) | |||
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; |
diff --git a/ui-shared.c b/ui-shared.c index e4bb98f..45105dc 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -408,27 +408,32 @@ void cgit_print_pageheader(char *title, int show_search) | |||
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 + |
diff --git a/ui-summary.c b/ui-summary.c index 178e959..04a466a 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -227,21 +227,21 @@ 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 | } |