Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go get should use `git ls-remote --get-url` to get remote git URLs, rather than `git config remote.origin.url` #28794

Closed
nickgrim opened this issue Nov 14, 2018 · 1 comment

Comments

@nickgrim
Copy link

@nickgrim nickgrim commented Nov 14, 2018

What version of Go are you using (go version)?

$ go version
go version go1.10.4 linux/amd64
$ git version
git version 2.17.1

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/nick/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/nick/src/go"
GORACE=""
GOROOT="/usr/lib/go-1.10"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.10/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build547520958=/tmp/go-build -gno-record-gcc-switches"

What did you do / expect-to-see / see-instead?

In my ~/.gitconfig I have the following lines:

[url "git@github.com:"]
        insteadOf = github:

This allows me to do e.g.

$ git clone github:nickgrim/xmas-pi

Running go get -u in the subsequent directory gives me:

$ go get -u
package github.com/nickgrim/xmas-pi: unable to parse output of git config remote.origin.url

…which is fair, since:

$ git config remote.origin.url
github:nickgrim/xmas-pi

…is not a real URL. However, there's a git command which seems to take care of doing any insteadOf substitutions, giving a "real" URL:

$ git ls-remote --get-url
git@github.com:nickgrim/xmas-pi

ls-remote seems to work better in the face of a single remote that is not called origin:

$ git remote rename origin gh
$ go get -u
package github.com/nickgrim/xmas-pi: remote origin not found
$ git ls-remote --get-url
git@github.com:nickgrim/xmas-pi

And it also seems (after a tiny amount of testing) to still do The Right Thing in the face of multiple remotes:

$ git remote add other https://example.com/
$ git remote -v
origin  git@github.com:nickgrim/xmas-pi (fetch)
origin  git@github.com:nickgrim/xmas-pi (push)
other   https://example.com/ (fetch)
other   https://example.com/ (push)
$ git ls-remote --get-url
git@github.com:nickgrim/xmas-pi

It seems like whichever part of the toolchain is currently doing a git config remote.origin.url should instead be running git ls-remote --get-url.

I have not investigated any knock-on effects with respect to other uses of insteadOf, e.g. the workarounds mentioned in #26134 or #27088.

@nickgrim

This comment has been minimized.

Copy link
Author

@nickgrim nickgrim commented Nov 14, 2018

Ugh. Just tried go get -u in the same working-copy in go1.11.2 and it works without complaining; my apologies.

@nickgrim nickgrim closed this Nov 14, 2018
@golang golang locked and limited conversation to collaborators Nov 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants
You can’t perform that action at this time.