From 87a7c37ecb4ddb2116cb4e853a61781d0de37ddb Mon Sep 17 00:00:00 2001
From: Gusted <williamzijl7@hotmail.com>
Date: Wed, 3 Aug 2022 00:34:50 +0200
Subject: [PATCH] Use `strings.Cut` for GIT_PROTOCOL value (#20638)

- As per https://github.com/go-gitea/gitea/pull/20616#discussion_r935612542
---
 modules/ssh/ssh.go | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/modules/ssh/ssh.go b/modules/ssh/ssh.go
index 5cc011e581..6b601c008f 100644
--- a/modules/ssh/ssh.go
+++ b/modules/ssh/ssh.go
@@ -78,8 +78,7 @@ func sessionHandler(session ssh.Session) {
 	gitProtocol := ""
 	for _, env := range session.Environ() {
 		if strings.HasPrefix(env, "GIT_PROTOCOL=") {
-			// The value would be version=2, so using normal split doesn't work here.
-			gitProtocol = strings.SplitN(env, "=", 2)[1]
+			_, gitProtocol, _ = strings.Cut(env, "=")
 			break
 		}
 	}