aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2013-09-10 15:28:29 -0400
committerRuss Cox <rsc@golang.org>2013-09-10 15:28:29 -0400
commitb99fdb2a11ae58834a2c0c646f54d0a587dd269c (patch)
tree0699c65ca7a7a3c5d8af9db93e6e1d409c1eecda /src/cmd
parent6034406eae500a10ed9bb4085559935cda275ec0 (diff)
downloadgo-b99fdb2a11ae58834a2c0c646f54d0a587dd269c.tar.xz
cmd/go: report correct directory for 'no version control'
The scan starts at the directory we care about and works backward to the GOPATH root. The error should say the original directory name, not the name of the GOPATH root. Fixes #6175. R=golang-dev, minux.ma CC=golang-dev https://golang.org/cl/13366050
Diffstat (limited to 'src/cmd')
-rwxr-xr-xsrc/cmd/go/test.bash12
-rw-r--r--src/cmd/go/vcs.go3
2 files changed, 14 insertions, 1 deletions
diff --git a/src/cmd/go/test.bash b/src/cmd/go/test.bash
index 52d2f08337..17358279c8 100755
--- a/src/cmd/go/test.bash
+++ b/src/cmd/go/test.bash
@@ -139,6 +139,18 @@ if ! ./testgo test ./testdata/testimport/*.go; then
ok=false
fi
+TEST version control error message includes correct directory
+export GOPATH=$(pwd)/testdata/shadow/root1
+if ./testgo get -u foo 2>testdata/err; then
+ echo "go get -u foo succeeded unexpectedly"
+ ok=false
+elif ! grep testdata/shadow/root1/src/foo testdata/err >/dev/null; then
+ echo "go get -u error does not mention shadow/root1/src/foo:"
+ cat testdata/err
+ ok=false
+fi
+unset GOPATH
+
# Test that without $GOBIN set, binaries get installed
# into the GOPATH bin directory.
TEST install into GOPATH
diff --git a/src/cmd/go/vcs.go b/src/cmd/go/vcs.go
index 58040e3d41..655549009f 100644
--- a/src/cmd/go/vcs.go
+++ b/src/cmd/go/vcs.go
@@ -321,6 +321,7 @@ func vcsForDir(p *Package) (vcs *vcsCmd, root string, err error) {
return nil, "", fmt.Errorf("directory %q is outside source root %q", dir, srcRoot)
}
+ origDir := dir
for len(dir) > len(srcRoot) {
for _, vcs := range vcsList {
if fi, err := os.Stat(filepath.Join(dir, "."+vcs.cmd)); err == nil && fi.IsDir() {
@@ -337,7 +338,7 @@ func vcsForDir(p *Package) (vcs *vcsCmd, root string, err error) {
dir = ndir
}
- return nil, "", fmt.Errorf("directory %q is not using a known version control system", dir)
+ return nil, "", fmt.Errorf("directory %q is not using a known version control system", origDir)
}
// repoRoot represents a version control system, a repo, and a root of