aboutsummaryrefslogtreecommitdiffstats
path: root/repository.go
diff options
context:
space:
mode:
Diffstat (limited to 'repository.go')
-rw-r--r--repository.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/repository.go b/repository.go
index 0cda947..866f9ff 100644
--- a/repository.go
+++ b/repository.go
@@ -226,6 +226,10 @@ func (r *Repository) Head(remote string) (core.Hash, error) {
return r.localHead()
}
+ return r.remoteHead(remote)
+}
+
+func (r *Repository) remoteHead(remote string) (core.Hash, error) {
rem, ok := r.Remotes[remote]
if !ok {
return core.ZeroHash, fmt.Errorf("unable to find remote %q", remote)
@@ -235,5 +239,11 @@ func (r *Repository) Head(remote string) (core.Hash, error) {
}
func (r *Repository) localHead() (core.Hash, error) {
- return core.ZeroHash, nil
+ storage, ok := r.Storage.(*seekable.ObjectStorage)
+ if !ok {
+ return core.ZeroHash,
+ fmt.Errorf("cannot retrieve local head: no local data found")
+ }
+
+ return storage.Head()
}