@@ -26,7 +26,10 @@ public void CanCreateBareRepo()
2626 Assert . Equal ( scd . RootedDirectoryPath + Path . DirectorySeparatorChar , repo . Info . Path ) ;
2727 Assert . True ( repo . Info . IsBare ) ;
2828
29- AssertInitializedRepository ( repo ) ;
29+ AssertInitializedRepository ( repo , "refs/heads/master" ) ;
30+
31+ repo . Refs . Add ( "HEAD" , "refs/heads/orphan" , true ) ;
32+ AssertInitializedRepository ( repo , "refs/heads/orphan" ) ;
3033 }
3134 }
3235
@@ -57,7 +60,10 @@ public void CanCreateStandardRepo()
5760
5861 AssertIsHidden ( repo . Info . Path ) ;
5962
60- AssertInitializedRepository ( repo ) ;
63+ AssertInitializedRepository ( repo , "refs/heads/master" ) ;
64+
65+ repo . Refs . Add ( "HEAD" , "refs/heads/orphan" , true ) ;
66+ AssertInitializedRepository ( repo , "refs/heads/orphan" ) ;
6167 }
6268 }
6369
@@ -147,15 +153,15 @@ public void CreatingRepoWithBadParamsThrows()
147153 Assert . Throws < ArgumentNullException > ( ( ) => Repository . Init ( null ) ) ;
148154 }
149155
150- private static void AssertInitializedRepository ( Repository repo )
156+ private static void AssertInitializedRepository ( Repository repo , string expectedHeadTargetIdentifier )
151157 {
152158 Assert . NotNull ( repo . Info . Path ) ;
153159 Assert . False ( repo . Info . IsHeadDetached ) ;
154160 Assert . True ( repo . Info . IsHeadOrphaned ) ;
155161
156162 Reference headRef = repo . Refs . Head ;
157163 Assert . NotNull ( headRef ) ;
158- Assert . Equal ( "refs/heads/master" , headRef . TargetIdentifier ) ;
164+ Assert . Equal ( expectedHeadTargetIdentifier , headRef . TargetIdentifier ) ;
159165 Assert . Null ( headRef . ResolveToDirectReference ( ) ) ;
160166
161167 Assert . NotNull ( repo . Head ) ;
@@ -164,9 +170,11 @@ private static void AssertInitializedRepository(Repository repo)
164170 Assert . Null ( repo . Head . Tip ) ;
165171
166172 Assert . Equal ( 0 , repo . Commits . Count ( ) ) ;
173+ Assert . Equal ( 0 , repo . Commits . QueryBy ( new Filter ( ) ) . Count ( ) ) ;
174+ Assert . Equal ( 0 , repo . Commits . QueryBy ( new Filter { Since = repo . Refs . Head } ) . Count ( ) ) ;
167175 Assert . Equal ( 0 , repo . Commits . QueryBy ( new Filter { Since = repo . Head } ) . Count ( ) ) ;
168176 Assert . Equal ( 0 , repo . Commits . QueryBy ( new Filter { Since = "HEAD" } ) . Count ( ) ) ;
169- Assert . Equal ( 0 , repo . Commits . QueryBy ( new Filter { Since = "refs/heads/master" } ) . Count ( ) ) ;
177+ Assert . Throws < LibGit2SharpException > ( ( ) => repo . Commits . QueryBy ( new Filter { Since = expectedHeadTargetIdentifier } ) . Count ( ) ) ;
170178
171179 Assert . Null ( repo . Head [ "subdir/I-do-not-exist" ] ) ;
172180
0 commit comments