aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-07-14 01:22:53 -0400
committerRuss Cox <rsc@golang.org>2015-07-15 04:36:49 +0000
commit8df0bcc1fb9a4da7f2fafa959fe9c101f99866ef (patch)
treedaa79ed6ab82ae5d41a0573e6fb8340b521ad7e4
parent3c9f60c99a1212e6dd1233fea930d45ce9c32198 (diff)
downloadgo-8df0bcc1fb9a4da7f2fafa959fe9c101f99866ef.tar.gz
go-8df0bcc1fb9a4da7f2fafa959fe9c101f99866ef.zip
cmd/go: disable password prompt when running git
This fix only works on Git 2.3.0 and later. There appears to be no portable way to fix the earlier versions. We already run git with stdin closed, but on Unix git calls getpass, which opens /dev/tty itself. We could do package syscall-specific things to get /dev/tty invalidated during the exec, but I'd really rather not. And on Windows, Git opens "CONIN$" and "CONOUT$" itself, and I have no idea how to invalidate those. Fix the problem for newish Git versions and wait for people to update. Best we can do. Fixes #9341. Change-Id: I576579b106764029853e0f74d411e19108deecf5 Reviewed-on: https://go-review.googlesource.com/12175 Reviewed-by: Rob Pike <r@golang.org>
-rw-r--r--src/cmd/go/get.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cmd/go/get.go b/src/cmd/go/get.go
index 12fe77a382..0e81d7c1c3 100644
--- a/src/cmd/go/get.go
+++ b/src/cmd/go/get.go
@@ -77,6 +77,12 @@ func runGet(cmd *Command, args []string) {
fatalf("go get: cannot use -f flag without -u")
}
+ // Disable any prompting for passwords by Git.
+ // Only has an effect for 2.3.0 or later, but avoiding
+ // the prompt in earlier versions is just too hard.
+ // See golang.org/issue/9341.
+ os.Setenv("GIT_TERMINAL_PROMPT", "0")
+
// Phase 1. Download/update.
var stk importStack
for _, arg := range downloadPaths(args) {