From e4e49bb81b30ee61e3316b4acf7b3635c36b3ac3 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sun, 1 Nov 2026 17:34:37 -1000 Subject: Say when a log search matches nothing --- source/ui-log.c | 5 +++++ tests/t0103-log.sh | 10 ++++++++++ 2 files changed, 15 insertions(+) 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("", columns + filler); + html("No commits match the search\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 "No commits match the search" 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. -- cgit 2.12.1