f23ea48c913d6f907f499e0315c4658632d20d29

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

fix(ssh): pass GIT_PROTOCOL from ssh session down to binary

Fixes: 4daebdd422a6 (sec: do not append session envs to git run (#544))

Diff

 1diff --git a/pkg/ssh/cmd/git.go b/pkg/ssh/cmd/git.go
 2index d8584e451417184bca4eee6daef85844692c9dc5..7265c9a762dd57ec62348b2da960d1ef7cca3651 100644
 3--- a/pkg/ssh/cmd/git.go
 4+++ b/pkg/ssh/cmd/git.go
 5@@ -3,6 +3,7 @@ package cmd
 6 import (
 7 	"errors"
 8 	"path/filepath"
 9+	"strings"
10 	"time"
11 
12 	"github.com/charmbracelet/log"
13@@ -204,6 +205,16 @@ func gitRunE(cmd *cobra.Command, args []string) error {
14 
15 	envs = append(envs, cfg.Environ()...)
16 
17+	// Add GIT_PROTOCOL from session.
18+	if sess := sshutils.SessionFromContext(ctx); sess != nil {
19+		for _, env := range sess.Environ() {
20+			if strings.HasPrefix(env, "GIT_PROTOCOL=") {
21+				envs = append(envs, env)
22+				break
23+			}
24+		}
25+	}
26+
27 	repoPath := filepath.Join(reposDir, repoDir)
28 	service := git.Service(cmd.Name())
29 	stdin := cmd.InOrStdin()