aboutsummaryrefslogtreecommitdiffstats
path: root/repository.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-12-12 15:57:34 +0100
committerGitHub <noreply@github.com>2016-12-12 15:57:34 +0100
commit2dac5c1d1b6cb7d9a303a7346c3c7a3120d4ad40 (patch)
treef5f87cd723a0343e9744f2324ad1a8f1ff55bf90 /repository.go
parentdf9748cfb51db9c406e3df063badbd8c78ee819d (diff)
downloadgo-git-2dac5c1d1b6cb7d9a303a7346c3c7a3120d4ad40.tar.gz
config: Config, bare flag (#177)
* config.Config: bare flag * changes * changes
Diffstat (limited to 'repository.go')
-rw-r--r--repository.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/repository.go b/repository.go
index 816cd09..ae73885 100644
--- a/repository.go
+++ b/repository.go
@@ -58,6 +58,11 @@ func NewRepository(s Storer) (*Repository, error) {
}, nil
}
+// Config return the repository config
+func (r *Repository) Config() (*config.Config, error) {
+ return r.s.Config()
+}
+
// Remote return a remote if exists
func (r *Repository) Remote(name string) (*Remote, error) {
cfg, err := r.s.Config()
@@ -142,6 +147,12 @@ func (r *Repository) Clone(o *CloneOptions) error {
return err
}
+ // marks the repository as bare in the config, until we have Worktree, all
+ // the repository are bare
+ if err := r.setIsBare(true); err != nil {
+ return err
+ }
+
c := &config.RemoteConfig{
Name: o.RemoteName,
URL: o.URL,
@@ -174,6 +185,16 @@ func (r *Repository) Clone(o *CloneOptions) error {
return r.createReferences(head)
}
+func (r *Repository) setIsBare(isBare bool) error {
+ cfg, err := r.s.Config()
+ if err != nil {
+ return err
+ }
+
+ cfg.Core.IsBare = isBare
+ return r.s.SetConfig(cfg)
+}
+
const refspecSingleBranch = "+refs/heads/%s:refs/remotes/%s/%[1]s"
func (r *Repository) updateRemoteConfig(