History

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.

Lars Hjemli committed 19 years ago

Commit 68ca0321 parent 6ec5f367 files · +39 −9Browse files

Unified · Split

7 files
  1. cgit.c +1 −1
  2. cgit.css +18 −1
  3. cgit.h +3 −1
  4. shared.c +3 −0
  5. ui-log.c +6 −3
  6. ui-shared.c +7 −2
  7. ui-summary.c +1 −1
cgit.c+1−1
@@ -94,7 +94,7 @@ static void cgit_print_repo_page(struct cacheitem *item) · 93 unmodified lines
9494 switch(cgit_cmd) {
9595 case CMD_LOG:
9696 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,
9898 cgit_query_path, 1);
9999 break;
100100 case CMD_TREE:
cgit.css+18−1
@@ -144,15 +144,32 @@ td#search form { · 143 unmodified lines
144144 padding: 0px;
145145 }
146146
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+
147155 td#search input {
148156 font-size: 9pt;
149157 padding: 0px;
150− width: 10em;
158+}
159+
160+td#search input.txt {
161+ width: 8em;
151162 border: solid 1px #333;
152163 color: #333;
153164 background-color: #fff;
154165 }
155166
167+td#search input.btn {
168+ border: solid 1px #333;
169+ color: #333;
170+ background-color: #ccc;
171+}
172+
156173 div#summary {
157174 vertical-align: top;
158175 margin-bottom: 1em;
cgit.h+3−1
@@ -158,6 +158,7 @@ extern char *cgit_querystring; · 157 unmodified lines
158158 extern char *cgit_query_repo;
159159 extern char *cgit_query_page;
160160 extern char *cgit_query_search;
161+extern char *cgit_query_grep;
161162 extern char *cgit_query_head;
162163 extern char *cgit_query_sha1;
163164 extern char *cgit_query_sha2;
@@ -260,7 +261,8 @@ extern void cgit_print_tags(int maxcount); · 96 unmodified lines
260261
261262 extern void cgit_print_repolist(struct cacheitem *item);
262263 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);
264266 extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path);
265267 extern void cgit_print_tree(const char *rev, char *path);
266268 extern void cgit_print_commit(char *hex);
shared.c+3−0
@@ -54,6 +54,7 @@ char *cgit_query_repo = NULL; · 53 unmodified lines
5454 char *cgit_query_page = NULL;
5555 char *cgit_query_head = NULL;
5656 char *cgit_query_search = NULL;
57+char *cgit_query_grep = NULL;
5758 char *cgit_query_sha1 = NULL;
5859 char *cgit_query_sha2 = NULL;
5960 char *cgit_query_path = NULL;
@@ -232,6 +233,8 @@ void cgit_querystring_cb(const char *name, const char *value) · 172 unmodified lines
232233 cgit_cmd = cgit_get_cmd_index(value);
233234 } else if (!strcmp(name, "url")) {
234235 cgit_parse_url(value);
236+ } else if (!strcmp(name, "qt")) {
237+ cgit_query_grep = xstrdup(value);
235238 } else if (!strcmp(name, "q")) {
236239 cgit_query_search = xstrdup(value);
237240 } else if (!strcmp(name, "h")) {
ui-log.c+6−3
@@ -51,7 +51,7 @@ void print_commit(struct commit *commit) · 50 unmodified lines
5151 }
5252
5353
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)
5555 {
5656 struct rev_info rev;
5757 struct commit *commit;
@@ -62,8 +62,11 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, i · 4 unmodified lines
6262 if (!tip)
6363 argv[1] = cgit_query_head;
6464
65− if (grep)
66− argv[argc++] = fmt("--grep=%s", grep);
65+ if (grep && pattern && (!strcmp(grep, "grep") ||
66+ !strcmp(grep, "author") ||
67+ !strcmp(grep, "committer")))
68+ argv[argc++] = fmt("--%s=%s", grep, pattern);
69+
6770 if (path) {
6871 argv[argc++] = "--";
6972 argv[argc++] = path;
ui-shared.c+7−2
@@ -417,9 +417,14 @@ void cgit_print_pageheader(char *title, int show_search) · 416 unmodified lines
417417 html_hidden("id", cgit_query_sha1);
418418 if (cgit_query_sha2)
419419 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='");
421426 html_attr(cgit_query_search);
422− html("'/></form>");
427+ html("'/><input class='btn' type='submit' value='...'/></form>");
423428 }
424429 html("</td></tr>");
425430 html("<tr><td id='content' colspan='2'>");
ui-summary.c+1−1
@@ -236,7 +236,7 @@ void cgit_print_summary() · 235 unmodified lines
236236 html_include(cgit_repo->readme);
237237 html("</div>");
238238 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);
240240 html("<table class='list nowrap'>");
241241 if (cgit_summary_log > 0)
242242 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");