aboutsummaryrefslogtreecommitdiffstats
path: root/repository.go
diff options
context:
space:
mode:
authorJavi Fontan <jfontan@gmail.com>2018-08-30 15:29:51 +0200
committerJavi Fontan <jfontan@gmail.com>2018-08-30 15:29:51 +0200
commit1e1a7d0623459807d6f1e871492147f971f7540c (patch)
tree8e5b96b84c31c173ceeac106f2b54deead19c1b7 /repository.go
parent5cc316baa64287c7e56cb7372a5046c30fd955c1 (diff)
downloadgo-git-1e1a7d0623459807d6f1e871492147f971f7540c.tar.gz
git: add Static option to PlainOpen
Also adds Static configuration to Storage and DotGit. This option means that the git repository is not expected to be modified while open and enables some optimizations. Each time a file is accessed the storer tries to open an object file for the requested hash. When this is done for a lot of objects it is expensive. With Static option a list of object files is generated the first time an object is accessed and used to check if exists instead of using system calls. A similar optimization is done for packfiles. Signed-off-by: Javi Fontan <jfontan@gmail.com>
Diffstat (limited to 'repository.go')
-rw-r--r--repository.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/repository.go b/repository.go
index 818cfb3..d99d6eb 100644
--- a/repository.go
+++ b/repository.go
@@ -235,9 +235,8 @@ func PlainOpen(path string) (*Repository, error) {
return PlainOpenWithOptions(path, &PlainOpenOptions{})
}
-// PlainOpen opens a git repository from the given path. It detects if the
-// repository is bare or a normal one. If the path doesn't contain a valid
-// repository ErrRepositoryNotExists is returned
+// PlainOpenWithOptions opens a git repository from the given path with specific
+// options. See PlainOpen for more info.
func PlainOpenWithOptions(path string, o *PlainOpenOptions) (*Repository, error) {
dot, wt, err := dotGitToOSFilesystems(path, o.DetectDotGit)
if err != nil {
@@ -252,7 +251,11 @@ func PlainOpenWithOptions(path string, o *PlainOpenOptions) (*Repository, error)
return nil, err
}
- s, err := filesystem.NewStorage(dot)
+ so := filesystem.StorageOptions{
+ Static: o.Static,
+ }
+
+ s, err := filesystem.NewStorageWithOptions(dot, so)
if err != nil {
return nil, err
}