From d873056e03f21724f799824e02a17b2da7fd29af Mon Sep 17 00:00:00 2001 From: Alan Cabrera Date: Wed, 14 Mar 2018 07:58:13 -0700 Subject: Fix RefSpec.Src() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, the Src() function was assuming there are no “+” characters in the refspec src and erroneously used the strings.Index() function to compute the start index of src in the refspec. This change now uses the IsForceUpdate() method to decide how to elide the force update token. Signed-off-by: Alan Cabrera --- config/refspec.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'config/refspec.go') diff --git a/config/refspec.go b/config/refspec.go index af7e732..c9b9d52 100644 --- a/config/refspec.go +++ b/config/refspec.go @@ -62,7 +62,13 @@ func (s RefSpec) IsDelete() bool { // Src return the src side. func (s RefSpec) Src() string { spec := string(s) - start := strings.Index(spec, refSpecForce) + 1 + + var start int + if s.IsForceUpdate() { + start = 1 + } else { + start = 0 + } end := strings.Index(spec, refSpecSeparator) return spec[start:end] -- cgit