@@ -1493,28 +1493,41 @@ public void Stage(IEnumerable<string> paths, StageOptions stageOptions)
14931493 diffModifiers |= DiffModifiers . IncludeIgnored ;
14941494 }
14951495
1496- var changes = Diff . Compare < TreeChanges > ( diffModifiers , paths , explicitPathsOptions ) ;
1496+ var changes = Diff . Compare < TreeChanges > ( diffModifiers , paths , explicitPathsOptions ,
1497+ new CompareOptions { Similarity = SimilarityOptions . None } ) ;
14971498
1498- foreach ( var treeEntryChanges in changes )
1499+ var unexpectedTypesOfChanges = changes
1500+ . Where (
1501+ tec => tec . Status != ChangeKind . Added &&
1502+ tec . Status != ChangeKind . Modified &&
1503+ tec . Status != ChangeKind . Unmodified &&
1504+ tec . Status != ChangeKind . Deleted ) . ToList ( ) ;
1505+
1506+ if ( unexpectedTypesOfChanges . Count > 0 )
14991507 {
1500- switch ( treeEntryChanges . Status )
1501- {
1502- case ChangeKind . Unmodified :
1503- continue ;
1508+ throw new InvalidOperationException (
1509+ string . Format ( CultureInfo . InvariantCulture ,
1510+ "Entry '{0}' bears an unexpected ChangeKind '{1}'" ,
1511+ unexpectedTypesOfChanges [ 0 ] . Path , unexpectedTypesOfChanges [ 0 ] . Status ) ) ;
1512+ }
15041513
1505- case ChangeKind . Deleted :
1506- RemoveFromIndex ( treeEntryChanges . Path ) ;
1507- continue ;
1514+ foreach ( TreeEntryChanges treeEntryChanges in changes
1515+ . Where ( tec => tec . Status == ChangeKind . Deleted ) )
1516+ {
1517+ RemoveFromIndex ( treeEntryChanges . Path ) ;
1518+ }
15081519
1520+ foreach ( TreeEntryChanges treeEntryChanges in changes )
1521+ {
1522+ switch ( treeEntryChanges . Status )
1523+ {
15091524 case ChangeKind . Added :
1510- /* Fall through */
15111525 case ChangeKind . Modified :
15121526 AddToIndex ( treeEntryChanges . Path ) ;
1513- continue ;
1527+ break ;
15141528
15151529 default :
1516- throw new InvalidOperationException (
1517- string . Format ( CultureInfo . InvariantCulture , "Entry '{0}' bears an unexpected ChangeKind '{1}'" , treeEntryChanges . Path , treeEntryChanges . Status ) ) ;
1530+ continue ;
15181531 }
15191532 }
15201533
0 commit comments