Skip to content

Commit

Permalink
Fix refresh-mode periodic not updating branch labels
Browse files Browse the repository at this point in the history
This is a regression from #991. Bring back and improve correction from #591.

Fixes #1270
  • Loading branch information
koutcher committed Oct 21, 2023
1 parent 447881b commit 7545d7b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,13 +771,18 @@ 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);

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);
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/watch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 7545d7b

Please sign in to comment.