aboutsummaryrefslogtreecommitdiffstats
path: root/config/refspec.go
diff options
context:
space:
mode:
authorMike Lundy <mike@fluffypenguin.org>2019-06-03 18:19:09 -0700
committerMike Lundy <mike@fluffypenguin.org>2019-06-04 09:25:06 -0700
commitaf3226f6522d5545c3aa546eb7c99ec131b38302 (patch)
tree7ed1e78a8a702d6b14e8b3713b8aedf8d7300878 /config/refspec.go
parent37b80726760d2e0b17dfa437f3162dd930590ecf (diff)
downloadgo-git-af3226f6522d5545c3aa546eb7c99ec131b38302.tar.gz
fix wildcard handling in RefSpec matching
1) The guard logic here was inverted, resulting in an always-false branch, which meant that the suffix after the wildcard was incorrectly ignored. 2) Wildcards were treated as 1-or-more matches, but git treats them as 0-or-more. This change aligns go-git with git, but represents a bit of a breaking change for go-git. Signed-off-by: Mike Lundy <mike@fluffypenguin.org>
Diffstat (limited to 'config/refspec.go')
-rw-r--r--config/refspec.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/config/refspec.go b/config/refspec.go
index 391705c..7f486c9 100644
--- a/config/refspec.go
+++ b/config/refspec.go
@@ -99,11 +99,11 @@ func (s RefSpec) matchGlob(n plumbing.ReferenceName) bool {
var prefix, suffix string
prefix = src[0:wildcard]
- if len(src) < wildcard {
- suffix = src[wildcard+1 : len(suffix)]
+ if len(src) > wildcard+1 {
+ suffix = src[wildcard+1:]
}
- return len(name) > len(prefix)+len(suffix) &&
+ return len(name) >= len(prefix)+len(suffix) &&
strings.HasPrefix(name, prefix) &&
strings.HasSuffix(name, suffix)
}