]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: update x/mod to fix "//indirect" comment editing
authorBryan C. Mills <bcmills@google.com>
Tue, 4 May 2021 19:57:45 +0000 (15:57 -0400)
committerBryan C. Mills <bcmills@google.com>
Tue, 4 May 2021 20:18:55 +0000 (20:18 +0000)
Fixes #45932

Change-Id: I043aecb6224348faf54c1d41fdbc00aa566089c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/316751
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

src/cmd/go.mod
src/cmd/go.sum
src/cmd/go/testdata/script/mod_indirect_nospace.txt [new file with mode: 0644]
src/cmd/vendor/golang.org/x/mod/modfile/rule.go
src/cmd/vendor/golang.org/x/mod/module/module.go
src/cmd/vendor/modules.txt

index 79224db99968c0174dbdae1259417e3f220ee265..ebcfba62e5b60ff54d9df9ee2d0f6c8f2da4a1d6 100644 (file)
@@ -7,7 +7,7 @@ require (
        github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639 // indirect
        golang.org/x/arch v0.0.0-20210502124803-cbf565b21d1e
        golang.org/x/crypto v0.0.0-20210503195802-e9a32991a82e // indirect
-       golang.org/x/mod v0.4.3-0.20210503183026-4435ecfe4815
+       golang.org/x/mod v0.4.3-0.20210504181020-67f1c1edc27a
        golang.org/x/sys v0.0.0-20210423082822-04245dca01da // indirect
        golang.org/x/term v0.0.0-20210503060354-a79de5458b56
        golang.org/x/tools v0.1.1-0.20210503200558-19b1717ea5eb
index 4ae0261d1c0705caa98738ef3c64aa8e1b70fb6e..38cd527efcc4a3f0c4b50ffbb99f846ab5946470 100644 (file)
@@ -11,6 +11,8 @@ golang.org/x/crypto v0.0.0-20210503195802-e9a32991a82e h1:8foAy0aoO5GkqCvAEJ4VC4
 golang.org/x/crypto v0.0.0-20210503195802-e9a32991a82e/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
 golang.org/x/mod v0.4.3-0.20210503183026-4435ecfe4815 h1:9nyskUepGPcX93addfTsdRqsQ7rSWIdQOdWVcsWAYv0=
 golang.org/x/mod v0.4.3-0.20210503183026-4435ecfe4815/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
+golang.org/x/mod v0.4.3-0.20210504181020-67f1c1edc27a h1:wbpC/7Wbo5WFVox32n+KjhRRLmTLq8YW/wRlL2iVAhk=
+golang.org/x/mod v0.4.3-0.20210504181020-67f1c1edc27a/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
 golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c=
 golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
diff --git a/src/cmd/go/testdata/script/mod_indirect_nospace.txt b/src/cmd/go/testdata/script/mod_indirect_nospace.txt
new file mode 100644 (file)
index 0000000..f4fb6a8
--- /dev/null
@@ -0,0 +1,32 @@
+# https://golang.org/issue/45932: "indirect" comments missing spaces
+# should not be corrupted when the comment is removed.
+
+go mod tidy
+cmp go.mod go.mod.direct
+
+-- go.mod --
+module example.net/m
+
+go 1.16
+
+require example.net/x v0.1.0 //indirect
+
+replace example.net/x v0.1.0 => ./x
+-- go.mod.direct --
+module example.net/m
+
+go 1.16
+
+require example.net/x v0.1.0
+
+replace example.net/x v0.1.0 => ./x
+-- m.go --
+package m
+import _ "example.net/x"
+
+-- x/go.mod --
+module example.net/x
+
+go 1.16
+-- x/x.go --
+package x
index 3f603fa60f8a3a891c9ac53b6e7400c08dd0adb9..d8242de28065cc5d4c325070098da0cbba5f07b1 100644 (file)
@@ -505,8 +505,8 @@ func setIndirect(line *Line, indirect bool) {
        }
 
        // Removing comment.
-       f := strings.Fields(line.Suffix[0].Token)
-       if len(f) == 2 {
+       f := strings.TrimSpace(strings.TrimPrefix(line.Suffix[0].Token, string(slashSlash)))
+       if f == "indirect" {
                // Remove whole comment.
                line.Suffix = nil
                return
index cf69ff657a4ca6b1d2f42b4d61301d5d1ca851a2..ba97ac356e9cb34f73f6a756a9f65eedbdca25b0 100644 (file)
@@ -393,7 +393,7 @@ func checkPath(path string, kind pathKind) error {
        if path == "" {
                return fmt.Errorf("empty string")
        }
-       if path[0] == '-' {
+       if path[0] == '-' && kind != filePath {
                return fmt.Errorf("leading dash")
        }
        if strings.Contains(path, "//") {
index e9644883fc77048996746f4749be47548106a2e0..a5dd28b7dc7a6cfe91d75ea08c391e36eeab321d 100644 (file)
@@ -28,7 +28,7 @@ golang.org/x/arch/x86/x86asm
 ## explicit; go 1.17
 golang.org/x/crypto/ed25519
 golang.org/x/crypto/ed25519/internal/edwards25519
-# golang.org/x/mod v0.4.3-0.20210503183026-4435ecfe4815
+# golang.org/x/mod v0.4.3-0.20210504181020-67f1c1edc27a
 ## explicit; go 1.17
 golang.org/x/mod/internal/lazyregexp
 golang.org/x/mod/modfile