@@ -67,6 +67,7 @@ pub struct Status {
6767 diff : DiffComponent ,
6868 git_diff : AsyncDiff ,
6969 has_remotes : bool ,
70+ git_state : RepoState ,
7071 git_status_workdir : AsyncStatus ,
7172 git_status_stage : AsyncStatus ,
7273 git_branch_state : Option < BranchCompare > ,
@@ -162,6 +163,7 @@ impl Status {
162163 queue : queue. clone ( ) ,
163164 visible : true ,
164165 has_remotes : false ,
166+ git_state : RepoState :: Clean ,
165167 focus : Focus :: WorkDir ,
166168 diff_target : DiffTarget :: WorkingDir ,
167169 index_wd : ChangesComponent :: new (
@@ -296,38 +298,34 @@ impl Status {
296298 f : & mut tui:: Frame < B > ,
297299 r : tui:: layout:: Rect ,
298300 ) {
299- if let Ok ( state) = sync:: repo_state ( & self . repo . borrow ( ) ) {
300- if state != RepoState :: Clean {
301- let txt = Self :: repo_state_text (
302- & self . repo . borrow ( ) ,
303- & state,
304- ) ;
305-
306- let w = Paragraph :: new ( txt)
307- . block (
308- Block :: default ( )
309- . border_type ( BorderType :: Plain )
310- . borders ( Borders :: all ( ) )
311- . border_style (
312- Style :: default ( ) . fg ( Color :: Yellow ) ,
313- )
314- . title ( format ! ( "Pending {:?}" , state) ) ,
315- )
316- . style ( Style :: default ( ) . fg ( Color :: Red ) )
317- . alignment ( Alignment :: Left ) ;
301+ if self . git_state != RepoState :: Clean {
302+ let txt = Self :: repo_state_text (
303+ & self . repo . borrow ( ) ,
304+ & self . git_state ,
305+ ) ;
318306
319- f. render_widget ( w, r) ;
320- }
307+ let w = Paragraph :: new ( txt)
308+ . block (
309+ Block :: default ( )
310+ . border_type ( BorderType :: Plain )
311+ . borders ( Borders :: all ( ) )
312+ . border_style (
313+ Style :: default ( ) . fg ( Color :: Yellow ) ,
314+ )
315+ . title ( format ! (
316+ "Pending {:?}" ,
317+ self . git_state
318+ ) ) ,
319+ )
320+ . style ( Style :: default ( ) . fg ( Color :: Red ) )
321+ . alignment ( Alignment :: Left ) ;
322+
323+ f. render_widget ( w, r) ;
321324 }
322325 }
323326
324327 fn repo_state_unclean ( & self ) -> bool {
325- if let Ok ( state) = sync:: repo_state ( & self . repo . borrow ( ) ) {
326- if state != RepoState :: Clean {
327- return true ;
328- }
329- }
330- false
328+ self . git_state != RepoState :: Clean
331329 }
332330
333331 fn can_focus_diff ( & self ) -> bool {
@@ -410,6 +408,9 @@ impl Status {
410408 config,
411409 ) ) ?;
412410
411+ self . git_state = sync:: repo_state ( & self . repo . borrow ( ) )
412+ . unwrap_or ( RepoState :: Clean ) ;
413+
413414 self . branch_compare ( ) ;
414415 }
415416
@@ -457,6 +458,7 @@ impl Status {
457458 self . index_wd . set_items ( & workdir_status. items ) ?;
458459
459460 self . update_diff ( ) ?;
461+ self . check_remotes ( ) ;
460462
461463 if self . git_action_executed {
462464 self . git_action_executed = false ;
@@ -613,21 +615,15 @@ impl Status {
613615 }
614616
615617 fn can_abort_merge ( & self ) -> bool {
616- sync:: repo_state ( & self . repo . borrow ( ) )
617- . unwrap_or ( RepoState :: Clean )
618- == RepoState :: Merge
618+ self . git_state == RepoState :: Merge
619619 }
620620
621621 fn pending_rebase ( & self ) -> bool {
622- sync:: repo_state ( & self . repo . borrow ( ) )
623- . unwrap_or ( RepoState :: Clean )
624- == RepoState :: Rebase
622+ self . git_state == RepoState :: Rebase
625623 }
626624
627625 fn pending_revert ( & self ) -> bool {
628- sync:: repo_state ( & self . repo . borrow ( ) )
629- . unwrap_or ( RepoState :: Clean )
630- == RepoState :: Revert
626+ self . git_state == RepoState :: Revert
631627 }
632628
633629 pub fn revert_pending_state ( & self ) {
0 commit comments