@@ -261,7 +261,6 @@ public void SetData(List<Models.Change> changes)
261
261
}
262
262
263
263
_cached = changes ;
264
- _count = _cached . Count ;
265
264
266
265
var lastSelectedUnstaged = new HashSet < string > ( ) ;
267
266
var lastSelectedStaged = new HashSet < string > ( ) ;
@@ -1782,7 +1781,7 @@ private void SetDetail(Models.Change change, bool isUnstaged)
1782
1781
DetailContext = new DiffContext ( _repo . FullPath , new Models . DiffOption ( change , isUnstaged ) , _detailContext as DiffContext ) ;
1783
1782
}
1784
1783
1785
- private void DoCommit ( bool autoStage , bool autoPush , bool allowEmpty = false , bool confirmWithFilter = false )
1784
+ private void DoCommit ( bool autoStage , bool autoPush , CommitCheckPassed checkPassed = CommitCheckPassed . None )
1786
1785
{
1787
1786
if ( string . IsNullOrWhiteSpace ( _commitMessage ) )
1788
1787
return ;
@@ -1793,18 +1792,25 @@ private void DoCommit(bool autoStage, bool autoPush, bool allowEmpty = false, bo
1793
1792
return ;
1794
1793
}
1795
1794
1796
- if ( ! string . IsNullOrEmpty ( _filter ) && _staged . Count > _visibleStaged . Count && ! confirmWithFilter )
1795
+ if ( _repo . CurrentBranch is { IsDetachedHead : true } && checkPassed < CommitCheckPassed . DetachedHead )
1797
1796
{
1798
- var confirmMessage = App . Text ( "WorkingCopy.ConfirmCommitWithFilter" , _staged . Count , _visibleStaged . Count , _staged . Count - _visibleStaged . Count ) ;
1799
- App . ShowWindow ( new ConfirmCommit ( confirmMessage , ( ) => DoCommit ( autoStage , autoPush , allowEmpty , true ) ) , true ) ;
1797
+ var msg = App . Text ( "WorkingCopy.ConfirmCommitWithDetachedHead" ) ;
1798
+ App . ShowWindow ( new ConfirmCommit ( msg , ( ) => DoCommit ( autoStage , autoPush , CommitCheckPassed . DetachedHead ) ) , true ) ;
1800
1799
return ;
1801
1800
}
1802
1801
1803
- if ( ! _useAmend && ! allowEmpty )
1802
+ if ( ! string . IsNullOrEmpty ( _filter ) && _staged . Count > _visibleStaged . Count && checkPassed < CommitCheckPassed . Filter )
1804
1803
{
1805
- if ( ( autoStage && _count == 0 ) || ( ! autoStage && _staged . Count == 0 ) )
1804
+ var msg = App . Text ( "WorkingCopy.ConfirmCommitWithFilter" , _staged . Count , _visibleStaged . Count , _staged . Count - _visibleStaged . Count ) ;
1805
+ App . ShowWindow ( new ConfirmCommit ( msg , ( ) => DoCommit ( autoStage , autoPush , CommitCheckPassed . Filter ) ) , true ) ;
1806
+ return ;
1807
+ }
1808
+
1809
+ if ( checkPassed < CommitCheckPassed . FileCount && ! _useAmend )
1810
+ {
1811
+ if ( ( ! autoStage && _staged . Count == 0 ) || ( autoStage && _cached . Count == 0 ) )
1806
1812
{
1807
- App . ShowWindow ( new ConfirmEmptyCommit ( _count > 0 , stageAll => DoCommit ( stageAll , autoPush , true , confirmWithFilter ) ) , true ) ;
1813
+ App . ShowWindow ( new ConfirmEmptyCommit ( _cached . Count > 0 , stageAll => DoCommit ( stageAll , autoPush , CommitCheckPassed . FileCount ) ) , true ) ;
1808
1814
return ;
1809
1815
}
1810
1816
}
@@ -1871,6 +1877,14 @@ private bool IsChanged(List<Models.Change> old, List<Models.Change> cur)
1871
1877
return false ;
1872
1878
}
1873
1879
1880
+ private enum CommitCheckPassed
1881
+ {
1882
+ None = 0 ,
1883
+ DetachedHead ,
1884
+ Filter ,
1885
+ FileCount ,
1886
+ }
1887
+
1874
1888
private Repository _repo = null ;
1875
1889
private bool _isLoadingData = false ;
1876
1890
private bool _isStaging = false ;
@@ -1886,7 +1900,6 @@ private bool IsChanged(List<Models.Change> old, List<Models.Change> cur)
1886
1900
private List < Models . Change > _visibleStaged = [ ] ;
1887
1901
private List < Models . Change > _selectedUnstaged = [ ] ;
1888
1902
private List < Models . Change > _selectedStaged = [ ] ;
1889
- private int _count = 0 ;
1890
1903
private object _detailContext = null ;
1891
1904
private string _filter = string . Empty ;
1892
1905
private string _commitMessage = string . Empty ;
0 commit comments