@@ -26,7 +26,10 @@ public void CanCreateBareRepo()
26
26
Assert . Equal ( scd . RootedDirectoryPath + Path . DirectorySeparatorChar , repo . Info . Path ) ;
27
27
Assert . True ( repo . Info . IsBare ) ;
28
28
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" ) ;
30
33
}
31
34
}
32
35
@@ -57,7 +60,10 @@ public void CanCreateStandardRepo()
57
60
58
61
AssertIsHidden ( repo . Info . Path ) ;
59
62
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" ) ;
61
67
}
62
68
}
63
69
@@ -147,15 +153,15 @@ public void CreatingRepoWithBadParamsThrows()
147
153
Assert . Throws < ArgumentNullException > ( ( ) => Repository . Init ( null ) ) ;
148
154
}
149
155
150
- private static void AssertInitializedRepository ( Repository repo )
156
+ private static void AssertInitializedRepository ( Repository repo , string expectedHeadTargetIdentifier )
151
157
{
152
158
Assert . NotNull ( repo . Info . Path ) ;
153
159
Assert . False ( repo . Info . IsHeadDetached ) ;
154
160
Assert . True ( repo . Info . IsHeadOrphaned ) ;
155
161
156
162
Reference headRef = repo . Refs . Head ;
157
163
Assert . NotNull ( headRef ) ;
158
- Assert . Equal ( "refs/heads/master" , headRef . TargetIdentifier ) ;
164
+ Assert . Equal ( expectedHeadTargetIdentifier , headRef . TargetIdentifier ) ;
159
165
Assert . Null ( headRef . ResolveToDirectReference ( ) ) ;
160
166
161
167
Assert . NotNull ( repo . Head ) ;
@@ -164,9 +170,11 @@ private static void AssertInitializedRepository(Repository repo)
164
170
Assert . Null ( repo . Head . Tip ) ;
165
171
166
172
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 ( ) ) ;
167
175
Assert . Equal ( 0 , repo . Commits . QueryBy ( new Filter { Since = repo . Head } ) . Count ( ) ) ;
168
176
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 ( ) ) ;
170
178
171
179
Assert . Null ( repo . Head [ "subdir/I-do-not-exist" ] ) ;
172
180
0 commit comments