Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mvdan
Copy link
Collaborator

@mvdan mvdan commented Oct 20, 2021

(see commit message)

I had been seeing an issue where running "git commit" with vim as the
editor would almost always get slowed down with:

	Installing govim and gopls

It did not make a lot of sense to me; my version of Go and govim was not
changing between the commits. I was simply editing an unrelated Go
project and committing the changes in between.

Even more weirdly, it seemed like this issue only occurred when I ran
"git commit" inside a checked out git submodule.
It did not happen in a direct git clone.

I added GOVIM_DEBUG_INSTALL to allow myself to debug what was going on.
All the variables looked right, except "commit"; it was pointing to the
commit I was in the process of committing, not govim's HEAD.

It turns out "git commit" was setting environment variables like GIT_DIR,
which were making "git rev-parse HEAD" not use plugindir as the repo.

Call "git rev-parse" with "env -i" to run it with an empty environment.
This should prevent future problems with GIT_ env vars set when vim runs.
It seems safe, as "git rev-parse" is a fairly simple operation.

I leave GOVIM_DEBUG_INSTALL in place, to make future debugging easier.
@mvdan mvdan requested review from leitzler and myitcv October 20, 2021 08:28
@myitcv
Copy link
Member

myitcv commented Oct 20, 2021

@leitzler you ok to have a look at this one please?

@mvdan
Copy link
Collaborator Author

mvdan commented Oct 20, 2021

Not urgent :)

@leitzler
Copy link
Member

👍 will do!

Copy link
Member

@leitzler leitzler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git commit doesn't seem to set GIT_DIR for me (using git version 2.24.3 (Apple Git-128) or git version 2.20.1), maybe it is something in your environment that sets it?

Nice find, we should still handle those cases regardless. LGTM

@leitzler leitzler merged commit bb1695e into govim:main Oct 21, 2021
@mvdan
Copy link
Collaborator Author

mvdan commented Oct 21, 2021

On git v2.33, I see the env vars when doing a git commit inside a checked out submodule, but not in a regularly cloned repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants