@@ -1119,6 +1119,49 @@ func (s *RepositorySuite) testCloneSingleBranchAndNonHEADReference(c *C, ref str
1119
1119
c .Assert (branch .Hash ().String (), Equals , "e8d3ffab552895c19b9fcf7aa264d277cde33881" )
1120
1120
}
1121
1121
1122
+ func (s * RepositorySuite ) TestCloneSingleBranchHEADMain (c * C ) {
1123
+ r , _ := Init (memory .NewStorage (), nil )
1124
+
1125
+ head , err := r .Head ()
1126
+ c .Assert (err , Equals , plumbing .ErrReferenceNotFound )
1127
+ c .Assert (head , IsNil )
1128
+
1129
+ err = r .clone (context .Background (), & CloneOptions {
1130
+ URL : s .GetLocalRepositoryURL (fixtures .ByTag ("no-master-head" ).One ()),
1131
+ SingleBranch : true ,
1132
+ })
1133
+
1134
+ c .Assert (err , IsNil )
1135
+
1136
+ remotes , err := r .Remotes ()
1137
+ c .Assert (err , IsNil )
1138
+ c .Assert (remotes , HasLen , 1 )
1139
+
1140
+ cfg , err := r .Config ()
1141
+ c .Assert (err , IsNil )
1142
+ c .Assert (cfg .Branches , HasLen , 1 )
1143
+ c .Assert (cfg .Branches ["main" ].Name , Equals , "main" )
1144
+ c .Assert (cfg .Branches ["main" ].Remote , Equals , "origin" )
1145
+ c .Assert (cfg .Branches ["main" ].Merge , Equals , plumbing .ReferenceName ("refs/heads/main" ))
1146
+
1147
+ head , err = r .Reference (plumbing .HEAD , false )
1148
+ c .Assert (err , IsNil )
1149
+ c .Assert (head , NotNil )
1150
+ c .Assert (head .Type (), Equals , plumbing .SymbolicReference )
1151
+ c .Assert (head .Target ().String (), Equals , "refs/heads/main" )
1152
+
1153
+ branch , err := r .Reference (head .Target (), false )
1154
+ c .Assert (err , IsNil )
1155
+ c .Assert (branch , NotNil )
1156
+ c .Assert (branch .Hash ().String (), Equals , "786dafbd351e587da1ae97e5fb9fbdf868b4a28f" )
1157
+
1158
+ branch , err = r .Reference ("refs/remotes/origin/HEAD" , false )
1159
+ c .Assert (err , IsNil )
1160
+ c .Assert (branch , NotNil )
1161
+ c .Assert (branch .Type (), Equals , plumbing .HashReference )
1162
+ c .Assert (branch .Hash ().String (), Equals , "786dafbd351e587da1ae97e5fb9fbdf868b4a28f" )
1163
+ }
1164
+
1122
1165
func (s * RepositorySuite ) TestCloneSingleBranch (c * C ) {
1123
1166
r , _ := Init (memory .NewStorage (), nil )
1124
1167
@@ -1154,12 +1197,6 @@ func (s *RepositorySuite) TestCloneSingleBranch(c *C) {
1154
1197
c .Assert (err , IsNil )
1155
1198
c .Assert (branch , NotNil )
1156
1199
c .Assert (branch .Hash ().String (), Equals , "6ecf0ef2c2dffb796033e5a02219af86ec6584e5" )
1157
-
1158
- branch , err = r .Reference ("refs/remotes/origin/master" , false )
1159
- c .Assert (err , IsNil )
1160
- c .Assert (branch , NotNil )
1161
- c .Assert (branch .Type (), Equals , plumbing .HashReference )
1162
- c .Assert (branch .Hash ().String (), Equals , "6ecf0ef2c2dffb796033e5a02219af86ec6584e5" )
1163
1200
}
1164
1201
1165
1202
func (s * RepositorySuite ) TestCloneSingleTag (c * C ) {
0 commit comments