Skip to content

Commit

Permalink
Fix refresh for untracked files
Browse files Browse the repository at this point in the history
  • Loading branch information
koutcher committed Apr 9, 2019
1 parent 2ab183d commit df70884
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,15 @@ status_run(struct view *view, const char *argv[], char status, enum line_type ty
watch_apply(&view->watch, WATCH_INDEX_STAGED_NO);
else if (type == LINE_STAT_UNSTAGED)
watch_apply(&view->watch, WATCH_INDEX_UNSTAGED_NO);
else if (type == LINE_STAT_UNTRACKED)
watch_apply(&view->watch, WATCH_INDEX_UNTRACKED_NO);
} else {
if (type == LINE_STAT_STAGED)
watch_apply(&view->watch, WATCH_INDEX_STAGED_YES);
else if (type == LINE_STAT_UNSTAGED)
watch_apply(&view->watch, WATCH_INDEX_UNSTAGED_YES);
else if (type == LINE_STAT_UNTRACKED)
watch_apply(&view->watch, WATCH_INDEX_UNTRACKED_YES);
}

io_done(&io);
Expand Down
9 changes: 8 additions & 1 deletion src/watch.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ watch_index_handler(struct watch_handler *handler, enum watch_event event, enum

if (!check_file_mtime(&handler->last_modified, "%s/index", repo.git_dir) ||
event == WATCH_EVENT_SWITCH_VIEW ||
!index_diff(&diff, false, false))
!index_diff(&diff, opt_show_untracked, false))
return WATCH_NONE;

if (check & WATCH_INDEX_STAGED) {
Expand All @@ -129,6 +129,13 @@ watch_index_handler(struct watch_handler *handler, enum watch_event event, enum
changed |= WATCH_INDEX_UNSTAGED_NO;
}

if (check & WATCH_INDEX_UNTRACKED) {
if (diff.untracked)
changed |= WATCH_INDEX_UNTRACKED_YES;
else
changed |= WATCH_INDEX_UNTRACKED_NO;
}

if (changed)
handler->last_modified = time(NULL);

Expand Down

0 comments on commit df70884

Please sign in to comment.