From 7545d7ba240c0a85c4fcdf9d297c384aa7badf21 Mon Sep 17 00:00:00 2001 From: Thomas Koutcher Date: Wed, 1 Mar 2023 18:43:26 +0100 Subject: [PATCH] Fix refresh-mode periodic not updating branch labels This is a regression from #991. Bring back and improve correction from #591. Fixes #1270 --- src/display.c | 5 +++++ src/watch.c | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/display.c b/src/display.c index b2fe8b9c2..6e754f5bf 100644 --- a/src/display.c +++ b/src/display.c @@ -771,6 +771,7 @@ get_input(int prompt_position, struct key *key) int delay = -1; if (opt_refresh_mode != REFRESH_MODE_MANUAL) { + bool refs_refreshed = false; if (opt_refresh_mode == REFRESH_MODE_PERIODIC) delay = watch_periodic(opt_refresh_interval); @@ -778,6 +779,10 @@ get_input(int prompt_position, struct key *key) foreach_displayed_view (view, i) { if (view_can_refresh(view) && watch_dirty(&view->watch)) { + if (!refs_refreshed) { + load_refs(true); + refs_refreshed = true; + } refresh_view(view); } } diff --git a/src/watch.c b/src/watch.c index 1365c96ec..103047504 100644 --- a/src/watch.c +++ b/src/watch.c @@ -146,8 +146,14 @@ static enum watch_trigger watch_refs_handler(struct watch_handler *handler, enum watch_event event, enum watch_trigger check) { - if (event == WATCH_EVENT_AFTER_COMMAND) - load_refs(true); + if (event == WATCH_EVENT_AFTER_COMMAND || + check_file_mtime(&handler->last_modified, "%s/refs/heads", repo.git_dir) || + check_file_mtime(&handler->last_modified, "%s/refs/tags", repo.git_dir) || + check_file_mtime(&handler->last_modified, "%s/refs/notes", repo.git_dir) || + check_file_mtime(&handler->last_modified, "%s/packed-refs", repo.git_dir)) { + handler->last_modified = time(NULL); + return WATCH_REFS; + } return WATCH_NONE; }