File tree 2 files changed +24
-1
lines changed 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -814,5 +814,28 @@ public void CanCorrectlyDistinguishAuthorFromCommitter()
814
814
Assert . Equal ( committer , c . Committer ) ;
815
815
}
816
816
}
817
+
818
+ [ Fact ]
819
+ public void CanCommitOnOrphanedBranch ( )
820
+ {
821
+ string newBranchName = "refs/heads/newBranch" ;
822
+ SelfCleaningDirectory scd = BuildSelfCleaningDirectory ( ) ;
823
+
824
+ using ( var repo = Repository . Init ( scd . DirectoryPath ) )
825
+ {
826
+ // Set Head to point to branch other than master
827
+ repo . Refs . UpdateTarget ( "HEAD" , newBranchName ) ;
828
+ Assert . Equal ( newBranchName , repo . Head . CanonicalName ) ;
829
+
830
+ const string relativeFilepath = "test.txt" ;
831
+ string filePath = Path . Combine ( repo . Info . WorkingDirectory , relativeFilepath ) ;
832
+
833
+ File . WriteAllText ( filePath , "test\n " ) ;
834
+ repo . Index . Stage ( relativeFilepath ) ;
835
+
836
+ repo . Commit ( "Initial commit" , DummySignature , DummySignature ) ;
837
+ Assert . Equal ( 1 , repo . Head . Commits . Count ( ) ) ;
838
+ }
839
+ }
817
840
}
818
841
}
Original file line number Diff line number Diff line change @@ -697,7 +697,7 @@ private IEnumerable<Commit> RetrieveParentsOfTheCommitBeingCreated(bool amendPre
697
697
return Head <
5F81
span class=pl-kos>.Tip . Parents ;
698
698
}
699
699
700
- if ( Info . IsEmpty )
700
+ if ( Info . IsHeadOrphaned )
701
701
{
702
702
return Enumerable . Empty < Commit > ( ) ;
703
703
}
You can’t perform that action at this time.
0 commit comments