Closed kaihowl closed 4 months ago
I just noticed this issue myself, and I can enlighten the issue, but I cannot offer to fix the issue in a PR unfortunately.
So, the issue is that when the maintainer of vim-gitgutter changed the default remote from master
to main
, this has a knock-on effect to every existing clone of the repo. In your .git
directory there is a file that records the remote's default branch, .git/refs/remotes/origin/HEAD
. TMK, there is no command that maintains this file automatically. (If any command were to do this, I would expect it to be fetch
; But, it does not. :shrug:) However, there is the command, git remote set-head origin -a
, which will automatically update the refs/remotes/origin/HEAD
file.
TBH, after the initial clone, I can't really think of any reason for this file to exist. Aside from the fact that it allows one to run a command like git checkout origin/HEAD
, but that has very little utility since it will leave you in a detached-head state. :shrug: :shrug: Anyway.
If someone wants to fix this issue, then I would suggest looking into s:git_validate or s:git_origin_branch as possible locations to add this validation. i.e. Collect origin_branch
, check if origin_branch
exists, if so fine, but if not, then run the command, git remote set-head origin -a
.
Quick Edit: I would identify this issue as a Bug
and, since it's an interaction issue with git, that it affects OS: All
and all versions of Vim.
Thanks for the report. Although it's not clear how vim-plug can really fix the situation, it should at least not throw an error.
I believe #1269 will fix the problem, but I'm not sure how I can test it. Any idea?
When vim-gitgutter changed the remote, default branch from
master
tomain
a while ago, my calls to:PlugClean
started to fail withThe error occurs here.
Running
git status
in the vim-gitgutter's worktree showsThe result from the
system
call on the vim-plug quoted line above is:The underlying issue triggering this behavior is the outdated symbolic ref
refs/remotes/origin/HEAD
. This does not get updated on a git fetch. Agit remote set-head origin -a
can do the trick. But this does involve another network call to query the remote.I run
PlugClean!
daily as part of this setup script.https://github.com/kaihowl/dotfiles/blob/a01f529f8b6a938cf33369df457bb0faec999e65/nvim/config--nvim--init.vim.symlink#L100-L167