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>
This commit is contained in:
Lars Hjemli 2007-10-28 15:23:00 +01:00
parent 6ec5f36f27
commit 68ca032dbe
7 changed files with 40 additions and 10 deletions

2
cgit.c
View File

@ -94,7 +94,7 @@ static void cgit_print_repo_page(struct cacheitem *item)
switch(cgit_cmd) { switch(cgit_cmd) {
case CMD_LOG: case CMD_LOG:
cgit_print_log(cgit_query_sha1, cgit_query_ofs, 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); cgit_query_path, 1);
break; break;
case CMD_TREE: case CMD_TREE:

View File

@ -144,15 +144,32 @@ td#search form {
padding: 0px; padding: 0px;
} }
td#search input { td#search select {
font-size: 9pt; font-size: 9pt;
padding: 0px; padding: 0px;
width: 10em;
border: solid 1px #333; border: solid 1px #333;
color: #333; color: #333;
background-color: #fff; background-color: #fff;
} }
td#search input {
font-size: 9pt;
padding: 0px;
}
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 { div#summary {
vertical-align: top; vertical-align: top;
margin-bottom: 1em; margin-bottom: 1em;

4
cgit.h
View File

@ -158,6 +158,7 @@ extern char *cgit_querystring;
extern char *cgit_query_repo; extern char *cgit_query_repo;
extern char *cgit_query_page; extern char *cgit_query_page;
extern char *cgit_query_search; extern char *cgit_query_search;
extern char *cgit_query_grep;
extern char *cgit_query_head; extern char *cgit_query_head;
extern char *cgit_query_sha1; extern char *cgit_query_sha1;
extern char *cgit_query_sha2; 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_repolist(struct cacheitem *item);
extern void cgit_print_summary(); 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_blob(struct cacheitem *item, const char *hex, char *path);
extern void cgit_print_tree(const char *rev, char *path); extern void cgit_print_tree(const char *rev, char *path);
extern void cgit_print_commit(char *hex); extern void cgit_print_commit(char *hex);

View File

@ -54,6 +54,7 @@ char *cgit_query_repo = NULL;
char *cgit_query_page = NULL; char *cgit_query_page = NULL;
char *cgit_query_head = NULL; char *cgit_query_head = NULL;
char *cgit_query_search = NULL; char *cgit_query_search = NULL;
char *cgit_query_grep = NULL;
char *cgit_query_sha1 = NULL; char *cgit_query_sha1 = NULL;
char *cgit_query_sha2 = NULL; char *cgit_query_sha2 = NULL;
char *cgit_query_path = NULL; char *cgit_query_path = NULL;
@ -232,6 +233,8 @@ void cgit_querystring_cb(const char *name, const char *value)
cgit_cmd = cgit_get_cmd_index(value); cgit_cmd = cgit_get_cmd_index(value);
} else if (!strcmp(name, "url")) { } else if (!strcmp(name, "url")) {
cgit_parse_url(value); cgit_parse_url(value);
} else if (!strcmp(name, "qt")) {
cgit_query_grep = xstrdup(value);
} else if (!strcmp(name, "q")) { } else if (!strcmp(name, "q")) {
cgit_query_search = xstrdup(value); cgit_query_search = xstrdup(value);
} else if (!strcmp(name, "h")) { } else if (!strcmp(name, "h")) {

View File

@ -51,7 +51,7 @@ void print_commit(struct commit *commit)
} }
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 rev_info rev;
struct commit *commit; struct commit *commit;
@ -62,8 +62,11 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, i
if (!tip) if (!tip)
argv[1] = cgit_query_head; argv[1] = cgit_query_head;
if (grep) if (grep && pattern && (!strcmp(grep, "grep") ||
argv[argc++] = fmt("--grep=%s", grep); !strcmp(grep, "author") ||
!strcmp(grep, "committer")))
argv[argc++] = fmt("--%s=%s", grep, pattern);
if (path) { if (path) {
argv[argc++] = "--"; argv[argc++] = "--";
argv[argc++] = path; argv[argc++] = path;

View File

@ -417,9 +417,14 @@ void cgit_print_pageheader(char *title, int show_search)
html_hidden("id", cgit_query_sha1); html_hidden("id", cgit_query_sha1);
if (cgit_query_sha2) if (cgit_query_sha2)
html_hidden("id2", 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_attr(cgit_query_search);
html("'/></form>"); html("'/><input class='btn' type='submit' value='...'/></form>");
} }
html("</td></tr>"); html("</td></tr>");
html("<tr><td id='content' colspan='2'>"); html("<tr><td id='content' colspan='2'>");

View File

@ -236,7 +236,7 @@ void cgit_print_summary()
html_include(cgit_repo->readme); html_include(cgit_repo->readme);
html("</div>"); html("</div>");
if (cgit_summary_log > 0) 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'>"); html("<table class='list nowrap'>");
if (cgit_summary_log > 0) if (cgit_summary_log > 0)
html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>"); html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");