@@ -53,34 +53,32 @@ public Models.Stash SelectedStash
5353 if ( value == null )
5454 {
5555 Changes = null ;
56+ _untracked . Clear ( ) ;
5657 }
5758 else
5859 {
5960 Task . Run ( ( ) =>
6061 {
61- var changes = null as List < Models . Change > ;
62-
63- if ( Native . OS . GitVersion >= Models . GitVersions . STASH_SHOW_WITH_UNTRACKED )
64- {
65- changes = new Commands . QueryStashChanges ( _repo . FullPath , value . Name ) . Result ( ) ;
66- }
67- else
62+ var changes = new Commands . CompareRevisions ( _repo . FullPath , $ "{ value . SHA } ^", value . SHA ) . Result ( ) ;
63+ var untracked = new List < Models . Change > ( ) ;
64+
65+ if ( value . Parents . Count == 3 )
6866 {
69- changes = new Commands . CompareRevisions ( _repo . FullPath , $ "{ value . SHA } ^", value . SHA ) . Result ( ) ;
70- if ( value . Parents . Count == 3 )
71- {
72- var untracked = new Commands . CompareRevisions ( _repo . FullPath , Models . Commit . EmptyTreeSHA1 , value . Parents [ 2 ] ) . Result ( ) ;
73- var needSort = changes . Count > 0 ;
74-
75- foreach ( var c in untracked )
76- changes . Add ( c ) ;
77-
78- if ( needSort )
79- changes . Sort ( ( l , r ) => string . Compare ( l . Path , r . Path , StringComparison . Ordinal ) ) ;
80- }
67+ untracked = new Commands . CompareRevisions ( _repo . FullPath , Models . Commit . EmptyTreeSHA1 , value . Parents [ 2 ] ) . Result ( ) ;
68+ var needSort = changes . Count > 0 && untracked . Count > 0 ;
69+
70+ foreach ( var c in untracked )
71+ changes . Add ( c ) ;
72+
73+ if ( needSort )
74+ changes . Sort ( ( l , r ) => string . Compare ( l . Path , r . Path , StringComparison . Ordinal ) ) ;
8175 }
8276
83- Dispatcher . UIThread . Invoke ( ( ) => Changes = changes ) ;
77+ Dispatcher . UIThread . Invoke ( ( ) =>
78+ {
79+ _untracked = untracked ;
80+ Changes = changes ;
81+ } ) ;
8482 } ) ;
8583 }
8684 }
@@ -106,7 +104,7 @@ public Models.Change SelectedChange
106104 {
107105 if ( value == null )
108106 DiffContext = null ;
109- else if ( value . Index == Models . ChangeState . Added && _selectedStash . Parents . Count == 3 )
107+ else if ( _untracked . Contains ( value ) )
110108 DiffContext = new DiffContext ( _repo . FullPath , new Models . DiffOption ( Models . Commit . EmptyTreeSHA1 , _selectedStash . Parents [ 2 ] , value ) , _diffContext ) ;
111109 else
112110 DiffContext = new DiffContext ( _repo . FullPath , new Models . DiffOption ( _selectedStash . Parents [ 0 ] , _selectedStash . SHA , value ) , _diffContext ) ;
@@ -129,6 +127,7 @@ public void Dispose()
129127 {
130128 _stashes ? . Clear ( ) ;
131129 _changes ? . Clear ( ) ;
130+ _untracked . Clear ( ) ;
132131
133132 _repo = null ;
134133 _selectedStash = null ;
@@ -309,6 +308,7 @@ private void RefreshVisible()
309308 private string _searchFilter = string . Empty ;
310309 private Models . Stash _selectedStash = null ;
311310 private List < Models . Change > _changes = null ;
311+ private List < Models . Change > _untracked = [ ] ;
312312 private Models . Change _selectedChange = null ;
313313 private DiffContext _diffContext = null ;
314314 }
0 commit comments