aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/internal/dotgit/dotgit.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-12-15 13:45:52 +0100
committerGitHub <noreply@github.com>2016-12-15 13:45:52 +0100
commit249c4137f4f34992c9bb6a60954e30a27994add7 (patch)
tree1188a410d368c619548d74798c474e04469eabae /storage/filesystem/internal/dotgit/dotgit.go
parentf01fd176ff61a3f37d096939690aa103de054ecc (diff)
downloadgo-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.go23
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) {