summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukasz Piatkowski <lukaspiatkowski@gmail.com>2022-10-20 10:33:47 +0200
committerLukasz Piatkowski <lukaspiatkowski@gmail.com>2022-11-12 07:24:14 +0100
commit4fa858619149f14a71cbe9e76f30de84e7a3042a (patch)
tree15cadcba329a6bccd85788a71be10318b06069de
parent3a295f34df0f5a2fda54607e8a3447b835ced65f (diff)
Update go-git to handle negative refspecs
-rw-r--r--go.mod2
-rw-r--r--go.sum4
-rw-r--r--vendor/github.com/jesseduffield/go-git/v5/config/refspec.go27
-rw-r--r--vendor/modules.txt2
4 files changed, 30 insertions, 5 deletions
diff --git a/go.mod b/go.mod
index c485f8d1a..b05241506 100644
--- a/go.mod
+++ b/go.mod
@@ -17,7 +17,7 @@ require (
github.com/imdario/mergo v0.3.11
github.com/integrii/flaggy v1.4.0
github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68
- github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4
+ github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d
github.com/jesseduffield/gocui v0.3.1-0.20221016041636-16c24668f71c
github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10
github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5
diff --git a/go.sum b/go.sum
index 834defa9f..b55ed4aa6 100644
--- a/go.sum
+++ b/go.sum
@@ -70,8 +70,8 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOl
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68 h1:EQP2Tv8TIcC6Y4RI+1ZbJDOHfGJ570tPeYVCqo7/tws=
github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68/go.mod h1:+LLj9/WUPAP8LqCchs7P+7X0R98HiFujVFANdNaxhGk=
-github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4 h1:GOQrmaE8i+KEdB8NzAegKYd4tPn/inM0I1uo0NXFerg=
-github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4/go.mod h1:nGNEErzf+NRznT+N2SWqmHnDnF9aLgANB1CUNEan09o=
+github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d h1:bO+OmbreIv91rCe8NmscRwhFSqkDJtzWCPV4Y+SQuXE=
+github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d/go.mod h1:nGNEErzf+NRznT+N2SWqmHnDnF9aLgANB1CUNEan09o=
github.com/jesseduffield/gocui v0.3.1-0.20221016041636-16c24668f71c h1:ttqCvM86hyp4V3DtRPxLo9imD1s+n6ry/zshPx0tt98=
github.com/jesseduffield/gocui v0.3.1-0.20221016041636-16c24668f71c/go.mod h1:znJuCDnF2Ph40YZSlBwdX/4GEofnIoWLGdT4mK5zRAU=
github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10 h1:jmpr7KpX2+2GRiE91zTgfq49QvgiqB0nbmlwZ8UnOx0=
diff --git a/vendor/github.com/jesseduffield/go-git/v5/config/refspec.go b/vendor/github.com/jesseduffield/go-git/v5/config/refspec.go
index 3b0cb77e6..9af7abde5 100644
--- a/vendor/github.com/jesseduffield/go-git/v5/config/refspec.go
+++ b/vendor/github.com/jesseduffield/go-git/v5/config/refspec.go
@@ -11,11 +11,13 @@ const (
refSpecWildcard = "*"
refSpecForce = "+"
refSpecSeparator = ":"
+ refSpecNegative = "^"
)
var (
ErrRefSpecMalformedSeparator = errors.New("malformed refspec, separators are wrong")
ErrRefSpecMalformedWildcard = errors.New("malformed refspec, mismatched number of wildcards")
+ ErrRefSpecMalformedNegative = errors.New("malformed negative refspec, one ^ and no separators allowed")
)
// RefSpec is a mapping from local branches to remote references.
@@ -31,6 +33,24 @@ type RefSpec string
// Validate validates the RefSpec
func (s RefSpec) Validate() error {
spec := string(s)
+
+ if strings.Index(spec, refSpecNegative) == 0 {
+ // This is a negative refspec
+ if strings.Count(spec, refSpecNegative) != 1 {
+ return ErrRefSpecMalformedNegative
+ }
+
+ if strings.Count(spec, refSpecSeparator) != 0 {
+ return ErrRefSpecMalformedNegative
+ }
+
+ if strings.Count(spec, refSpecWildcard) > 1 {
+ return ErrRefSpecMalformedWildcard
+ }
+
+ return nil
+ }
+
if strings.Count(spec, refSpecSeparator) != 1 {
return ErrRefSpecMalformedSeparator
}
@@ -64,12 +84,17 @@ func (s RefSpec) IsExactSHA1() bool {
return plumbing.IsHash(s.Src())
}
+// IsNegative returns if the refspec is a negative one
+func (s RefSpec) IsNegative() bool {
+ return s[0] == refSpecNegative[0]
+}
+
// Src return the src side.
func (s RefSpec) Src() string {
spec := string(s)
var start int
- if s.IsForceUpdate() {
+ if s.IsForceUpdate() || s.IsNegative() {
start = 1
} else {
start = 0
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 1aa9becc1..94ee1ccc4 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -128,7 +128,7 @@ github.com/jbenet/go-context/io
github.com/jesseduffield/generics/maps
github.com/jesseduffield/generics/set
github.com/jesseduffield/generics/slices
-# github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4
+# github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d
## explicit; go 1.13
github.com/jesseduffield/go-git/v5
github.com/jesseduffield/go-git/v5/config