]> Cypherpunks repositories - gostls13.git/commit
cmd/go: remove base.ShortPathConservative
authorMichael Matloob <matloob@golang.org>
Wed, 20 Nov 2024 18:39:14 +0000 (13:39 -0500)
committerMichael Matloob <matloob@golang.org>
Wed, 20 Nov 2024 20:58:09 +0000 (20:58 +0000)
commit2e07ff35436bc9adc67885f17cdd9042118d0ffd
tree634310f78f6650095caec222b87105fad2407e62
parent5242bfa26afdd3541b9a70a16431ceb616f5510d
cmd/go: remove base.ShortPathConservative

This CL first removes the base.ShortPathConservative function. It had
two classes of uses. The first was in opening files where the paths end
up in error messages. In all those cases, the non-shortened paths are
used to open the files, and ShortPath is only used for the error
messages. The second is in base.RelPaths. RelPaths will now call
ShortPath for each of the paths passed in instead of calling
RelConservative and then doing the same check as ShortPath to see if the
path is shorter.

To avoid the possibility of incorrect relative paths ending up in error
messages (that might have command lines suggested for users to run), and
to avoid the possibility of incorrect relative paths appearing in the
output of base.RelPaths, base.ShortPaths always does an os.SameFile
check to make sure that the relative path its providing is actually
correct. Since this makes ShortPath slower than just manipulating paths
(because we need to stat the files), we need to be continue to enforce
that ShortPath is only called for error messages (with the exception of
base.RelPaths and its callers).

This is a simpler way of solving the problem that base.ShortPaths
intended to solve.

For #68383

Change-Id: I474f464f51a9acb2250069dea3054b55d95a4ab4
Reviewed-on: https://go-review.googlesource.com/c/go/+/630276
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
src/cmd/go/internal/base/path.go
src/cmd/go/internal/modload/init.go
src/cmd/go/internal/modload/load.go
src/cmd/go/internal/modload/modfile.go
src/cmd/go/internal/workcmd/use.go