Skip to content

Commit 761ac75

Browse files
committed
cmd/go: fix git submodule fetch
Thanks to @toxeus on GitHub for the test case. Fixes #12612. Change-Id: I0c32fbe5044f3552053460a5347c062568093dff Reviewed-on: https://go-review.googlesource.com/17974 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 66fcf56 commit 761ac75

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/cmd/go/vcs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ var vcsGit = &vcsCmd{
122122
name: "Git",
123123
cmd: "git",
124124

125-
createCmd: []string{"clone {repo} {dir}", "--git-dir={dir}/.git submodule update --init --recursive"},
125+
createCmd: []string{"clone {repo} {dir}", "-C {dir} submodule update --init --recursive"},
126126
downloadCmd: []string{"pull --ff-only", "submodule update --init --recursive"},
127127

128128
tagCmd: []tagCmd{

src/cmd/go/vendor_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,18 @@ func TestVendorGetUpdate(t *testing.T) {
187187
tg.run("get", "-u", "github.com/rsc/go-get-issue-11864")
188188
}
189189

190+
func TestGetSubmodules(t *testing.T) {
191+
testenv.MustHaveExternalNetwork(t)
192+
193+
tg := testgo(t)
194+
defer tg.cleanup()
195+
tg.makeTempdir()
196+
tg.setenv("GOPATH", tg.path("."))
197+
tg.setenv("GO15VENDOREXPERIMENT", "1")
198+
tg.run("get", "-d", "github.com/rsc/go-get-issue-12612")
199+
tg.run("get", "-u", "-d", "github.com/rsc/go-get-issue-12612")
200+
}
201+
190202
func TestVendorCache(t *testing.T) {
191203
tg := testgo(t)
192204
defer tg.cleanup()

0 commit comments

Comments
 (0)