aboutsummaryrefslogtreecommitdiffstats
path: root/repository.go
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2016-08-29 22:47:13 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-29 22:47:13 +0200
commite4246138cb9ffb819c052ba17a9fbdf915427291 (patch)
treebd938368afe0ffd7c9e1df16256e39e17d8184b5 /repository.go
parentdd4af03ad368cc50dd08912010f5b667bd7569cd (diff)
downloadgo-git-e4246138cb9ffb819c052ba17a9fbdf915427291.tar.gz
storage: Add object type hint parameter to ObjectStorage.Get. (#69)
Some storage backends can optimize object lookup if they get the object type that is expected. So we the signature of the Get method is now Get(Hash, ObjectType). Added generic tests for storage backends.
Diffstat (limited to 'repository.go')
-rw-r--r--repository.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/repository.go b/repository.go
index fc871c7..1a5f4a7 100644
--- a/repository.go
+++ b/repository.go
@@ -226,7 +226,7 @@ func (r *Repository) Pull(o *PullOptions) error {
// Commit return the commit with the given hash
func (r *Repository) Commit(h core.Hash) (*Commit, error) {
- obj, err := r.s.ObjectStorage().Get(h)
+ obj, err := r.s.ObjectStorage().Get(h, core.CommitObject)
if err != nil {
if err == core.ErrObjectNotFound {
return nil, ErrObjectNotFound
@@ -250,7 +250,7 @@ func (r *Repository) Commits() (*CommitIter, error) {
// Tree return the tree with the given hash
func (r *Repository) Tree(h core.Hash) (*Tree, error) {
- obj, err := r.s.ObjectStorage().Get(h)
+ obj, err := r.s.ObjectStorage().Get(h, core.TreeObject)
if err != nil {
if err == core.ErrObjectNotFound {
return nil, ErrObjectNotFound
@@ -264,7 +264,7 @@ func (r *Repository) Tree(h core.Hash) (*Tree, error) {
// Blob returns the blob with the given hash
func (r *Repository) Blob(h core.Hash) (*Blob, error) {
- obj, err := r.s.ObjectStorage().Get(h)
+ obj, err := r.s.ObjectStorage().Get(h, core.BlobObject)
if err != nil {
if err == core.ErrObjectNotFound {
return nil, ErrObjectNotFound
@@ -278,7 +278,7 @@ func (r *Repository) Blob(h core.Hash) (*Blob, error) {
// Tag returns a tag with the given hash.
func (r *Repository) Tag(h core.Hash) (*Tag, error) {
- obj, err := r.s.ObjectStorage().Get(h)
+ obj, err := r.s.ObjectStorage().Get(h, core.TagObject)
if err != nil {
if err == core.ErrObjectNotFound {
return nil, ErrObjectNotFound
@@ -302,8 +302,8 @@ func (r *Repository) Tags() (*TagIter, error) {
}
// Object returns an object with the given hash.
-func (r *Repository) Object(h core.Hash) (Object, error) {
- obj, err := r.s.ObjectStorage().Get(h)
+func (r *Repository) Object(h core.Hash, t core.ObjectType) (Object, error) {
+ obj, err := r.s.ObjectStorage().Get(h, t)
if err != nil {
if err == core.ErrObjectNotFound {
return nil, ErrObjectNotFound