summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2007-10-28 14:23:00 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-10-28 14:23:00 (UTC)
commit68ca032dbe7379f78775fb03ef34a9ad2abc409f (patch) (side-by-side diff)
tree2209ae312eb932bc61b41ae9c774f6cfcc3dd372
parent6ec5f36f279a85f59db2851ab476d9acd0015770 (diff)
downloadcgit-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>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c2
-rw-r--r--cgit.css19
-rw-r--r--cgit.h4
-rw-r--r--shared.c3
-rw-r--r--ui-log.c9
-rw-r--r--ui-shared.c9
-rw-r--r--ui-summary.c2
7 files changed, 39 insertions, 9 deletions
diff --git a/cgit.c b/cgit.c
index cc18ed4..142e416 100644
--- a/cgit.c
+++ b/cgit.c
@@ -91,13 +91,13 @@ static void cgit_print_repo_page(struct cacheitem *item)
cgit_print_pageheader(cgit_query_page, show_search);
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:
cgit_print_tree(cgit_query_sha1, cgit_query_path);
break;
case CMD_COMMIT:
diff --git a/cgit.css b/cgit.css
index b8c3d81..5d47099 100644
--- a/cgit.css
+++ b/cgit.css
@@ -141,21 +141,38 @@ td#search {
td#search form {
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 {
vertical-align: top;
margin-bottom: 1em;
}
table#downloads {
diff --git a/cgit.h b/cgit.h
index 0baa679..dd83f70 100644
--- a/cgit.h
+++ b/cgit.h
@@ -155,12 +155,13 @@ extern int cgit_query_has_symref;
extern int cgit_query_has_sha1;
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;
extern char *cgit_query_path;
extern char *cgit_query_name;
extern int cgit_query_ofs;
@@ -257,13 +258,14 @@ extern void cgit_print_snapshot_start(const char *mimetype,
struct cacheitem *item);
extern void cgit_print_branches(int maxcount);
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);
extern void cgit_print_refs();
extern void cgit_print_tag(char *revname);
extern void cgit_print_diff(const char *new_hex, const char *old_hex, const char *prefix);
diff --git a/shared.c b/shared.c
index 7eb2b0e..4fab1c9 100644
--- a/shared.c
+++ b/shared.c
@@ -51,12 +51,13 @@ int cgit_query_has_sha1 = 0;
char *cgit_querystring = NULL;
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;
char *cgit_query_name = NULL;
int cgit_query_ofs = 0;
@@ -229,12 +230,14 @@ void cgit_querystring_cb(const char *name, const char *value)
cgit_repo = cgit_get_repoinfo(value);
} else if (!strcmp(name, "p")) {
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")) {
cgit_query_head = xstrdup(value);
cgit_query_has_symref = 1;
} else if (!strcmp(name, "id")) {
diff --git a/ui-log.c b/ui-log.c
index d38e40a..e7f7d6f 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -48,25 +48,28 @@ void print_commit(struct commit *commit)
html_txt(info->author);
html("</td></tr>\n");
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;
const char *argv[] = {NULL, tip, NULL, NULL, NULL};
int argc = 2;
int i;
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;
}
init_revisions(&rev, NULL);
rev.abbrev = DEFAULT_ABBREV;
diff --git a/ui-shared.c b/ui-shared.c
index e4bb98f..45105dc 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -414,15 +414,20 @@ void cgit_print_pageheader(char *title, int show_search)
if (cgit_query_head)
html_hidden("h", cgit_query_head);
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'>");
}
void cgit_print_snapshot_start(const char *mimetype, const char *filename,
diff --git a/ui-summary.c b/ui-summary.c
index 178e959..04a466a 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -233,13 +233,13 @@ void cgit_print_summary()
html_txt(cgit_repo->desc);
html("</h2>");
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'>&nbsp;</td></tr>");
cgit_print_branches(cgit_summary_branches);
html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
cgit_print_tags(cgit_summary_tags);