@@ -42,6 +42,40 @@ public void CanCreateBranch(string name)
42
42
}
43
43
}
44
44
45
+ [ Fact ]
46
+ public void CanCreateAnUnbornBranch ( )
47
+ {
48
+ string path = CloneStandardTestRepo ( ) ;
49
+ using ( var repo = new Repository ( path ) )
50
+ {
51
+ // No branch named orphan
52
+ Assert . Null ( repo . Branches [ "orphan" ] ) ;
53
+
54
+ // HEAD doesn't point to an unborn branch
55
+ Assert . False ( repo . Info . IsHeadUnborn ) ;
56
+
57
+ // Let's move the HEAD to this branch to be created
58
+ repo . Refs . UpdateTarget ( "HEAD" , "refs/heads/orphan" ) ;
59
+ Assert . True ( repo . Info . IsHeadUnborn ) ;
60
+
61
+ // The branch still doesn't exist
62
+ Assert . Null ( repo . Branches [ "orphan" ] ) ;
63
+
64
+ // Create a commit against HEAD
65
+ Commit c = repo . Commit ( "New initial root commit" , Constants . Signature , Constants . Signature ) ;
66
+
67
+ // Ensure this commit has no parent
68
+ Assert . Equal ( 0 , c . Parents . Count ( ) ) ;
69
+
70
+ // The branch now exists...
71
+ Branch orphan = repo . Branches [ "orphan" ] ;
72
+ Assert . NotNull ( orphan ) ;
73
+
74
+ // ...and points to that newly created commit
75
+ Assert . Equal ( c , orphan . Tip ) ;
76
+ }
77
+ }
78
+
45
79
[ Fact ]
46
80
public void CanCreateBranchUsingAbbreviatedSha ( )
47
81
{
0 commit comments