diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-05-08 12:06:18 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-05-08 12:06:18 +0200 |
commit | 1cd347ec8970388f83745c9a530ea2bcd705c6d9 (patch) | |
tree | dc8dff2497fc3a4724aecff5a909f33b344347d2 /repository.go | |
parent | 36d14454b32eca89ac43d2934c50f3a1ae2e1d20 (diff) | |
parent | 4cd57d7c5d2f05724c042d5bb8e83faf96638156 (diff) | |
download | go-git-1cd347ec8970388f83745c9a530ea2bcd705c6d9.tar.gz |
Merge pull request #47 from TripleDogDare/fix-repository-pulldefaultv3.0.3
Fix PullDefault to not cause panics.
Diffstat (limited to 'repository.go')
-rw-r--r-- | repository.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/repository.go b/repository.go index f4aa26d..87810a6 100644 --- a/repository.go +++ b/repository.go @@ -67,6 +67,10 @@ func (r *Repository) Pull(remoteName, branch string) (err error) { return err } + if branch == "" { + branch = remote.DefaultBranch() + } + ref, err := remote.Ref(branch) if err != nil { return err @@ -93,12 +97,7 @@ func (r *Repository) Pull(remoteName, branch string) (err error) { // PullDefault like Pull but retrieve the default branch from the default remote func (r *Repository) PullDefault() (err error) { - remote, ok := r.Remotes[DefaultRemoteName] - if !ok { - return fmt.Errorf("unable to find default remote %q", DefaultRemoteName) - } - - return r.Pull(DefaultRemoteName, remote.DefaultBranch()) + return r.Pull(DefaultRemoteName, "") } // Commit return the commit with the given hash |