Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Say when a log search matches nothing
| -rw-r--r-- | source/ui-log.c | 5 | |
| -rwxr-xr-x | tests/t0103-log.sh | 10 |
2 files changed, 15 insertions, 0 deletions
diff --git a/source/ui-log.c b/source/ui-log.c index 5b3a88a..052d586 100644 --- a/source/ui-log.c +++ b/source/ui-log.c @@ -597,6 +597,11 @@ void cgit_print_log(const char *tip, int ofs, int cnt, const char *grep, const c release_commit_memory(the_repository->parsed_objects, commit); commit->parents = NULL; } + // A search that matched nothing would leave the table a header alone. + if (!i && !ofs && grep && pattern && *pattern) { + htmlf("<tr class='nohover'><td colspan='%d'>", columns + filler); + html("No commits match the search</td></tr>\n"); + } if (pager) { print_pager(&rev, path, ofs, cnt); cgit_print_layout_end(); diff --git a/tests/t0103-log.sh b/tests/t0103-log.sh index 9796394..444db8f 100755 --- a/tests/t0103-log.sh +++ b/tests/t0103-log.sh @@ -45,6 +45,16 @@ test_expect_success 'no links with space in path' '! grep "href=./with space/" t test_expect_success 'no links with space in arg' '! grep "q=commit 1" tmp' test_expect_success 'commit 2 is not visible' '! grep "commit 2" tmp' +# A search that matches nothing says so in a row of its own, rather than +# leaving the table a header with nothing under it. +test_expect_success 'a search matching nothing says so' ' + cgit_url "foo/log&qt=grep&q=no+such+commit" >tmp && + grep "^Status: 200" tmp && + grep "<tr class=.nohover.><td colspan=.5.>No commits match the search</td></tr>" tmp && + cgit_url "foo/log&qt=grep&q=commit+1" >tmp && + ! grep "No commits match" tmp +' + # Following a file diffs each commit for the name the file had there, so the # root commit that created it has to be diffed too, and paging has to go on # asking about the name the visitor followed rather than the older one. |
