aboutsummaryrefslogtreecommitdiffstats
path: root/remote.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-06-21 12:40:21 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2018-06-21 12:40:21 +0200
commitb53ba8dcffd24e25815feff78e8246597e949f21 (patch)
tree377ed463706d8e88732e9bd877af97afbf0f05b0 /remote.go
parent0710c6cb710a0cdab04ab7f61cc62e23cfcacbee (diff)
downloadgo-git-b53ba8dcffd24e25815feff78e8246597e949f21.tar.gz
Remote.Fetch: error on missing remote reference
Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
Diffstat (limited to 'remote.go')
-rw-r--r--remote.go40
1 files changed, 35 insertions, 5 deletions
diff --git a/remote.go b/remote.go
index 60461d6..bf4519c 100644
--- a/remote.go
+++ b/remote.go
@@ -630,14 +630,29 @@ func calculateRefs(
spec = append(spec, refspecTag)
}
+ refs := make(memory.ReferenceStorage)
+ for _, s := range spec {
+ if err := doCalculateRefs(s, remoteRefs, refs); err != nil {
+ return nil, err
+ }
+ }
+
+ return refs, nil
+}
+
+func doCalculateRefs(
+ s config.RefSpec,
+ remoteRefs storer.ReferenceStorer,
+ refs memory.ReferenceStorage,
+) error {
iter, err := remoteRefs.IterReferences()
if err != nil {
- return nil, err
+ return err
}
- refs := make(memory.ReferenceStorage)
- return refs, iter.ForEach(func(ref *plumbing.Reference) error {
- if !config.MatchAny(spec, ref.Name()) {
+ var matched bool
+ err = iter.ForEach(func(ref *plumbing.Reference) error {
+ if !s.Match(ref.Name()) {
return nil
}
@@ -654,8 +669,23 @@ func calculateRefs(
return nil
}
- return refs.SetReference(ref)
+ matched = true
+ if err := refs.SetReference(ref); err != nil {
+ return err
+ }
+
+ if !s.IsWildcard() {
+ return storer.ErrStop
+ }
+
+ return nil
})
+
+ if !matched && !s.IsWildcard() {
+ return fmt.Errorf("couldn't find remote ref %q", s.Src())
+ }
+
+ return err
}
func getWants(localStorer storage.Storer, refs memory.ReferenceStorage) ([]plumbing.Hash, error) {