diff options
-rw-r--r-- | options.go | 1 | ||||
-rw-r--r-- | repository.go | 2 | ||||
-rw-r--r-- | repository_test.go | 13 |
3 files changed, 13 insertions, 3 deletions
@@ -737,6 +737,7 @@ type PlainOpenOptions struct { func (o *PlainOpenOptions) Validate() error { return nil } type PlainInitOptions struct { + InitOptions // Determines if the repository will have a worktree (non-bare) or not (bare). Bare bool ObjectFormat formatcfg.ObjectFormat diff --git a/repository.go b/repository.go index e94fc48..013b53f 100644 --- a/repository.go +++ b/repository.go @@ -256,7 +256,7 @@ func PlainInitWithOptions(path string, opts *PlainInitOptions) (*Repository, err s := filesystem.NewStorage(dot, cache.NewObjectLRUDefault()) - r, err := Init(s, wt) + r, err := InitWithOptions(s, wt, opts.InitOptions) if err != nil { return nil, err } diff --git a/repository_test.go b/repository_test.go index bc6b188..3154f1d 100644 --- a/repository_test.go +++ b/repository_test.go @@ -523,14 +523,23 @@ func (s *RepositorySuite) TestPlainInitWithOptions(c *C) { defer clean() r, err := PlainInitWithOptions(dir, &PlainInitOptions{ - Bare: true, + InitOptions: InitOptions{ + DefaultBranch: "refs/heads/foo", + }, + Bare: false, }) c.Assert(err, IsNil) c.Assert(r, NotNil) cfg, err := r.Config() c.Assert(err, IsNil) - c.Assert(cfg.Core.IsBare, Equals, true) + c.Assert(cfg.Core.IsBare, Equals, false) + + createCommit(c, r) + + ref, err := r.Head() + c.Assert(err, IsNil) + c.Assert(ref.Name().String(), Equals, "refs/heads/foo") } func (s *RepositorySuite) TestPlainInitAlreadyExists(c *C) { |