display "no matches found" if no commit matches a 'tog log' search
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
diff --git a/tog/tog.c b/tog/tog.c
index e4a2991..627443f 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -439,6 +439,7 @@ struct tog_view {
int search_next_done;
#define TOG_SEARCH_HAVE_MORE 1
#define TOG_SEARCH_NO_MORE 2
+#define TOG_SEARCH_HAVE_NONE 3
regex_t regex;
};
@@ -754,8 +755,9 @@ view_input(struct tog_view **new, struct tog_view **dead,
*dead = NULL;
*focus = NULL;
- /* Clear "no more matches" indicator. */
- if (view->search_next_done == TOG_SEARCH_NO_MORE)
+ /* Clear "no matches" indicator. */
+ if (view->search_next_done == TOG_SEARCH_NO_MORE ||
+ view->search_next_done == TOG_SEARCH_HAVE_NONE)
view->search_next_done = TOG_SEARCH_HAVE_MORE;
if (view->searching && !view->search_next_done) {
@@ -1518,7 +1520,9 @@ draw_commits(struct tog_view *view, struct commit_queue_entry **last,
if (asprintf(&ncommits_str, " [%d/%d] %s",
entry ? entry->idx + 1 : 0, commits->ncommits,
view->search_next_done == TOG_SEARCH_NO_MORE ?
- "no more matches" : (refs_str ? refs_str : "")) == -1) {
+ "no more matches" :
+ (view->search_next_done == TOG_SEARCH_HAVE_NONE ?
+ "no matches found" : (refs_str ? refs_str : ""))) == -1) {
err = got_error_from_errno("asprintf");
goto done;
}
@@ -2095,7 +2099,9 @@ search_next_log_view(struct tog_view *view)
if (entry == NULL) {
if (s->thread_args.log_complete ||
view->searching == TOG_SEARCH_BACKWARD) {
- view->search_next_done = TOG_SEARCH_NO_MORE;
+ view->search_next_done =
+ (s->matched_entry == NULL ?
+ TOG_SEARCH_HAVE_NONE : TOG_SEARCH_NO_MORE);
s->search_entry = NULL;
return NULL;
}