Author: Lars Hjemli <hjemli@gmail.com>
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>
cgit.c | 2 +- cgit.css | 19 ++++++++++++++++++- cgit.h | 4 +++- shared.c | 3 +++ ui-log.c | 9 ++++++--- ui-shared.c | 9 +++++++-- ui-summary.c | 2 +-
diff --git a/cgit.c b/cgit.c index cc18ed4c5e336e900dca080e3f7062fbec916feb..142e4164562c3a9f8f9a8d395598fb458af9b6ae 100644 --- a/cgit.c +++ b/cgit.c @@ -94,7 +94,7 @@ switch(cgit_cmd) { case CMD_LOG: cgit_print_log(cgit_query_sha1, cgit_query_ofs, - cgit_max_commit_count, cgit_query_search, + cgit_max_commit_count, cgit_query_grep, cgit_query_search, cgit_query_path, 1); break; case CMD_TREE: diff --git a/cgit.css b/cgit.css index b8c3d810268e1769182cd040fc21f0969e84af8d..5d47099a66c2c953be9b4272bc64fa4dcdb735a7 100644 --- a/cgit.css +++ b/cgit.css @@ -144,13 +144,30 @@ margin: 0px; padding: 0px; } +td#search select { + font-size: 9pt; + padding: 0px; + border: solid 1px #333; + color: #333; + background-color: #fff; +} + td#search input { font-size: 9pt; padding: 0px; - width: 10em; +} + +td#search input.txt { + width: 8em; border: solid 1px #333; color: #333; background-color: #fff; +} + +td#search input.btn { + border: solid 1px #333; + color: #333; + background-color: #ccc; } div#summary { diff --git a/cgit.h b/cgit.h index 0baa67927bb9d9251e3f57c3add17615a018d243..dd83f70ba111db6f085f0f85b5c48101b4cb6103 100644 --- a/cgit.h +++ b/cgit.h @@ -158,6 +158,7 @@ extern char *cgit_querystring; extern char *cgit_query_repo; extern char *cgit_query_page; extern char *cgit_query_search; +extern char *cgit_query_grep; extern char *cgit_query_head; extern char *cgit_query_sha1; extern char *cgit_query_sha2; @@ -260,7 +261,8 @@ extern void cgit_print_tags(int maxcount); extern void cgit_print_repolist(struct cacheitem *item); extern void cgit_print_summary(); -extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, int pager); +extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, + char *pattern, char *path, int pager); extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); extern void cgit_print_tree(const char *rev, char *path); extern void cgit_print_commit(char *hex); diff --git a/shared.c b/shared.c index 7eb2b0e26d8db080159f6ce3ee9fe9251853c6ce..4fab1c93bef64a847c98b42951ebc8a25b1cf1a2 100644 --- a/shared.c +++ b/shared.c @@ -54,6 +54,7 @@ char *cgit_query_repo = NULL; char *cgit_query_page = NULL; char *cgit_query_head = NULL; char *cgit_query_search = NULL; +char *cgit_query_grep = NULL; char *cgit_query_sha1 = NULL; char *cgit_query_sha2 = NULL; char *cgit_query_path = NULL; @@ -232,6 +233,8 @@ cgit_query_page = xstrdup(value); cgit_cmd = cgit_get_cmd_index(value); } else if (!strcmp(name, "url")) { cgit_parse_url(value); + } else if (!strcmp(name, "qt")) { + cgit_query_grep = xstrdup(value); } else if (!strcmp(name, "q")) { cgit_query_search = xstrdup(value); } else if (!strcmp(name, "h")) { diff --git a/ui-log.c b/ui-log.c index d38e40a17423cd507f63f3e4b0bfa5d77fb9c0f8..e7f7d6f43daf86212951455f307a0d0ddfa89533 100644 --- a/ui-log.c +++ b/ui-log.c @@ -51,7 +51,7 @@ cgit_free_commitinfo(info); } -void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, int pager) +void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, char *path, int pager) { struct rev_info rev; struct commit *commit; @@ -62,8 +62,11 @@ if (!tip) argv[1] = cgit_query_head; - if (grep) - argv[argc++] = fmt("--grep=%s", grep); + if (grep && pattern && (!strcmp(grep, "grep") || + !strcmp(grep, "author") || + !strcmp(grep, "committer"))) + argv[argc++] = fmt("--%s=%s", grep, pattern); + if (path) { argv[argc++] = "--"; argv[argc++] = path; diff --git a/ui-shared.c b/ui-shared.c index e4bb98fdc8b75755ed2841db087f6282b87f721d..45105dc813ec0bad2dbcc770527149dbbf6c8256 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -417,9 +417,14 @@ if (cgit_query_sha1) html_hidden("id", cgit_query_sha1); if (cgit_query_sha2) html_hidden("id2", cgit_query_sha2); - html("<input type='text' name='q' value='"); + html("<select name='qt'>"); + html_option("grep", "log msg", cgit_query_grep); + html_option("author", "author", cgit_query_grep); + html_option("committer", "committer", cgit_query_grep); + html("</select>"); + html("<input class='txt' type='text' name='q' value='"); html_attr(cgit_query_search); - html("'/></form>"); + html("'/><input class='btn' type='submit' value='...'/></form>"); } html("</td></tr>"); html("<tr><td id='content' colspan='2'>"); diff --git a/ui-summary.c b/ui-summary.c index 178e959a9036267971a9cce1649099ed0cd5b782..04a466a319f384b03ff92909e462aa7baaec5b8d 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -236,7 +236,7 @@ if (cgit_repo->readme) html_include(cgit_repo->readme); html("</div>"); if (cgit_summary_log > 0) - cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, NULL, 0); + cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, NULL, NULL, 0); html("<table class='list nowrap'>"); if (cgit_summary_log > 0) html("<tr class='nohover'><td colspan='4'> </td></tr>");