-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: go get needs some way to set missing user.email (maybe user.name) information in repos it pulls #16516
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
Comments
Why does the pull fail? Can you please provide the exact output of the command? The Git documentation says that |
(Github went down for a few minutes, I replied to my email notification about your comment after that but I don't know if it will go anywhere or show up here later or what) Sure. It seems to let you clone but not pull updates. I can't really explain (based on the documentation) why it does this, but it does. Perhaps the note about commits is just intended as an example, I don't know. It is easiest to replicate without involving go directly (I'll use this repo). In any case, the error is identical:
|
In this specific case it's not repos I want to look at or contribute to, just ones vscode's golang extension wants to update to provide its IDE functionality. To do this it tries to Presumably anything else trying to use |
Ah ha! This is because I have pull set to rebase by default:
Still, that's a sensible setting for my day to day git use, and I'm not going to turn it off in my global config (like I'm not going to set my e-mail in my global config). If go is going to do pulls for me, perhaps it should turn rebase off for them. |
I'm afraid this feels like somewhere between WAI and a big in Git to me. You have configured Git is such a way that it can't make commits, and then you're asking That said, the bug in Git is that it would treat them differently. Both I'm going to close this issue as WAI as far as Go is concerned. If you think there is some specific behavior Go could have to make this better, please comment, but AFAICT there isn't. |
It may be that it is a bug in Git, though while I can't think of a great reason for it to behave that way I'd suspect it's for some valid reason. Either way, it's absolutely not a "broken configuration". Those two settings are the way that they are for good reason, and in working directly with a git repo it's no problem (in fact it's preferable) to set whichever email I need to set in the local config. It's probably somewhat common to do that with this setting -- I don't want to accidentally commit to a personal or public repo with my work e-mail address and I similarly don't want to commit to work repos with my personal address. So, if it works as intended then it wasn't intended to work very well. I think there are at least four different ways Go could behave to make this better:
If Go is just going to run git commands on my behalf, and (compounding the issue) if things that work with Go are going to run those commands that run the git commands on my behalf, it's just extra annoying due to the additional steps I'm removed from using git directly. I'm not saying none of those options have potential downsides, but I think we could probably find one with more net positives than negatives. It's also obviously not a critical problem and it has (annoying) workarounds, but at the moment it doesn't make using Go very pleasant some of the time, and I think it would be a shame if the consensus was that that's the intent. At the very least I think it would be worth mentioning this in the docs somewhere if we've identified a (valid) git configuration that doesn't work seamlessly with Go's usage of git. |
Bonus 5th way, if it's not possible already, would be to somehow allow relatively easy overriding of the vcs commands as a preference, similar to picking up an optional config template but perhaps more generic. |
Wouldn't it be easier to make a local We already do submodule update (https://github.com/golang/go/blob/master/src/cmd/go/vcs.go#L136). |
It would be easier to do that, but I don't think git will just walk up the directory tree until it finds one (or at least the docs say it doesn't): https://git-scm.com/docs/git-config#FILES With respect to submodules, my point is that like
|
It sounds like your goal is to have different Git configuration in the repositories that
Git is already doing this check, as you pointed out by showing the output of "git pull". I don't think it's worth duplicating this check in
Setting
I don't see why those preferences need to be anywhere other than where they are now,
Ditto, this is already the purpose of |
That's actually a really good idea, I'll see if it works!
My argument that it might be worth it is go keeps those repos pretty deeply nested, likely inconveniently far away from whatever your cwd is or whatever you're trying to actually work on (again, even worse if it's something else running
Agreed, what it does do is let you fast-forward if that's possible, and you can do that without becoming an author or committer. If I only got this failure when fast-forward wasn't possible in package repos, it probably wouldn't have bothered me enough to think about it.
Sure, I understand that. This problem just happens to be with the packages for me. For a repo I'm developing in I'm just using git like normal, and it's unlikely anything would trigger a pull on that except for me doing it manually because I want to pull it. I'm much less aware of what's pulling which package when, where, and why. They're third-party packages, something requires them, I'd prefer they just worked however they need to work. I admit I do not know (being new to go) if there is any distinction made in go between working repos and dependencies that get pulled to act as packages. Either way would probably seem reasonable to me, for different reasons.
Yeah I like that idea the least. They're not special, they're just (packages anyway) far removed from whatever somebody is actually trying to work on when one gets cloned or updated.
This would not be my first choice either, but if you have something that wants to clone or update a bunch of packages, it's annoying to go update a bunch of If go is trying to manage this work behind the scenes on behalf of the user, which it is, I don't think it's a good idea for it to assume that everybody's global git config by itself will allow go to manage clone/pull/whatever operations by itself on a bunch of repositories. I don't think it's a good idea precisely because git is designed to have tiered configurations. The global one is settings that apply to all of your user's repos machine-wide, the local one is for settings that need to be different in different repositories. If go wants to more-or-less-seamlessly manage some git repos, it should let me help it do that somehow. So, I think beyond the scope of this specific problem, it's not great that go doesn't provide some way to say "hey, here's how I want the repositories you With regards to this specific issue, I've also pinged the git mailing list to ask why rebase doesn't avoid this check when it should know it won't make new commits, and/or why it doesn't detect this and fast-forward instead of rebasing in this case since the end-result should be identical AFAIK. If and when they respond, I'll let you guys know what they say in case you're interested. |
They started responding, and they seem to mostly agree that an early ident check could probably (and should probably) be avoided in this specific case, but they are not sure why the line responsible for it exists since it was added along with the whole of the interactive rebase feature. |
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
user.name
set anduser.useConfigOnly = true
, whileuser.email
is purposefully unset.What did you expect to see?
What did you see instead?
go get
pulls from git remotes (e.g. github) fail because their individual repo configs requireuser.email
to be setThe text was updated successfully, but these errors were encountered: