diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-12-15 13:45:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-15 13:45:52 +0100 |
commit | 249c4137f4f34992c9bb6a60954e30a27994add7 (patch) | |
tree | 1188a410d368c619548d74798c474e04469eabae /storage/filesystem/internal/dotgit/dotgit.go | |
parent | f01fd176ff61a3f37d096939690aa103de054ecc (diff) | |
download | go-git-249c4137f4f34992c9bb6a60954e30a27994add7.tar.gz |
storage: shallow storage (#180)
* storage: shallow storage
* changes
* changes
Diffstat (limited to 'storage/filesystem/internal/dotgit/dotgit.go')
-rw-r--r-- | storage/filesystem/internal/dotgit/dotgit.go | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/storage/filesystem/internal/dotgit/dotgit.go b/storage/filesystem/internal/dotgit/dotgit.go index 3a6227e..3405908 100644 --- a/storage/filesystem/internal/dotgit/dotgit.go +++ b/storage/filesystem/internal/dotgit/dotgit.go @@ -17,6 +17,7 @@ const ( suffix = ".git" packedRefsPath = "packed-refs" configPath = "config" + shallowPath = "shallow" objectsPath = "objects" packPath = "pack" @@ -60,15 +61,35 @@ func New(fs fs.Filesystem) *DotGit { return &DotGit{fs: fs} } +// ConfigWriter returns a file pointer for write to the config file func (d *DotGit) ConfigWriter() (fs.File, error) { return d.fs.Create(configPath) } -// Config returns the path of the config file +// Config returns a file pointer for read to the config file func (d *DotGit) Config() (fs.File, error) { return d.fs.Open(configPath) } +// ShallowWriter returns a file pointer for write to the shallow file +func (d *DotGit) ShallowWriter() (fs.File, error) { + return d.fs.Create(shallowPath) +} + +// Shallow returns a file pointer for read to the shallow file +func (d *DotGit) Shallow() (fs.File, error) { + f, err := d.fs.Open(shallowPath) + if err != nil { + if os.IsNotExist(err) { + return nil, nil + } + + return nil, err + } + + return f, nil +} + // NewObjectPack return a writer for a new packfile, it saves the packfile to // disk and also generates and save the index for the given packfile. func (d *DotGit) NewObjectPack() (*PackWriter, error) { |