aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--options.go1
-rw-r--r--repository.go2
-rw-r--r--repository_test.go13
3 files changed, 13 insertions, 3 deletions
diff --git a/options.go b/options.go
index 00d9b97..c68bf2b 100644
--- a/options.go
+++ b/options.go
@@ -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) {