@@ -614,19 +614,23 @@ public void CanHandleTwoStatusEntryChangesWithTheSamePath()
614
614
615
615
Commit commit = repo . ObjectDatabase . CreateCommit ( Constants . Signature , Constants . Signature , "A symlink" , tree , Enumerable . Empty < Commit > ( ) , false ) ;
616
616
repo . Refs . UpdateTarget ( "HEAD" , commit . Id . Sha ) ;
617
+
618
+ // Sets the index to the just created commit
617
619
repo . Reset ( ResetMode . Mixed ) ;
618
620
619
621
string parentPath = Path . Combine ( repo . Info . WorkingDirectory , "include/Nu" ) ;
620
622
621
623
Touch ( parentPath , "Nu.h" , "awesome content\n " ) ;
622
624
623
625
RepositoryStatus status = repo . RetrieveStatus (
624
- new StatusOptions { DetectRenamesInIndex = true , DetectRenamesInWorkDir = true } ) ;
626
+ new StatusOptions { DetectRenamesInIndex = true , DetectRenamesInWorkDir = true } ) ;
625
627
626
628
Assert . Equal ( 2 , status . Count ( ) ) ;
627
629
628
630
var expected = Path . Combine ( "include" , "Nu" , "Nu.h" ) ;
629
631
632
+ // Two different code paths here because both HEAD and the Index contains a symlink
633
+ // But we can't trust a Windows filesystem to correctly handle this kind of filemode
630
634
if ( IsRunningOnUnix ( ) )
631
635
{
632
636
Assert . Equal ( expected , status . RenamedInWorkDir . Single ( ) . FilePath ) ;
@@ -638,6 +642,16 @@ public void CanHandleTwoStatusEntryChangesWithTheSamePath()
638
642
Assert . Equal ( Path . Combine ( "objc" , "Nu.h" ) , status . Missing . Single ( ) . FilePath ) ;
639
643
}
640
644
645
+ // Replace the symlink in the index with a plain file
646
+ repo . Stage ( parentPath ) ;
647
+
648
+ status = repo . RetrieveStatus (
649
+ new StatusOptions { DetectRenamesInIndex = true , DetectRenamesInWorkDir = true } ) ;
650
+
651
+ Assert . Equal ( 2 , status . Count ( ) ) ;
652
+
653
+ Assert . Equal ( expected , status . Staged . Single ( ) . FilePath ) ;
654
+ Assert . Equal ( Path . Combine ( "objc" , "Nu.h" ) , status . Missing . Single ( ) . FilePath ) ;
641
655
}
642
656
}
643
657
}
0 commit comments