@@ -67,6 +67,7 @@ pub struct Status {
67
67
diff : DiffComponent ,
68
68
git_diff : AsyncDiff ,
69
69
has_remotes : bool ,
70
+ git_state : RepoState ,
70
71
git_status_workdir : AsyncStatus ,
71
72
git_status_stage : AsyncStatus ,
72
73
git_branch_state : Option < BranchCompare > ,
@@ -162,6 +163,7 @@ impl Status {
162
163
queue : queue. clone ( ) ,
163
164
visible : true ,
164
165
has_remotes : false ,
166
+ git_state : RepoState :: Clean ,
165
167
focus : Focus :: WorkDir ,
166
168
diff_target : DiffTarget :: WorkingDir ,
167
169
index_wd : ChangesComponent :: new (
@@ -296,38 +298,34 @@ impl Status {
296
298
f : & mut tui:: Frame < B > ,
297
299
r : tui:: layout:: Rect ,
298
300
) {
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
+ ) ;
318
306
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) ;
321
324
}
322
325
}
323
326
324
327
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
331
329
}
332
330
333
331
fn can_focus_diff ( & self ) -> bool {
@@ -410,6 +408,9 @@ impl Status {
410
408
config,
411
409
) ) ?;
412
410
411
+ self . git_state = sync:: repo_state ( & self . repo . borrow ( ) )
412
+ . unwrap_or ( RepoState :: Clean ) ;
413
+
413
414
self . branch_compare ( ) ;
414
415
}
415
416
@@ -457,6 +458,7 @@ impl Status {
457
458
self . index_wd . set_items ( & workdir_status. items ) ?;
458
459
459
460
self . update_diff ( ) ?;
461
+ self . check_remotes ( ) ;
460
462
461
463
if self . git_action_executed {
462
464
self . git_action_executed = false ;
@@ -613,21 +615,15 @@ impl Status {
613
615
}
614
616
615
617
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
619
619
}
620
620
621
621
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
625
623
}
626
624
627
625
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
631
627
}
632
628
633
629
pub fn revert_pending_state ( & self ) {
0 commit comments