vim-fugitive
vim-fugitive copied to clipboard
[Question] Is there any way to manage Git dir?
By some command or variable, could I { reset , force-set , check } Git dir that fugitive script manages?
Accidentally, sometimes it misunderstands Git root dir.
No specific way to reproduce, but, for example, likely to happen in the cases below:
- In a parent repo A as the working dir, open a file in a submodule repo B.
- It may get wrong
b:git_diras the repo A, while it should be the repo B the file actually belongs to.
- It may get wrong
- Manage a repo that is in a symbolic link dir,
and the repo setting is mixed with the symbolic-link path and the actual path.
- Worked in a symbolic link dir
/c/.../symlink/to the actual dir/d/.../actual. - In a parent repo A,
git clone-ed a repo B andgit submodule add-ed to the repo A. Then,git submodule absorbgitdirs-ed to move the.gitdir of the submodule repo B into the.gitdir of the parent repo A. - Then, I got the
.gitfile of repo Bgitdir: ../.../../d/.../actual/repoA/.git/modules/repoB; and the config setting of repo Bcore.worktreeas../.../../c/.../symlink/repoA/repoBor such. - The both points to the different path in the literal sense, fugitive works bad.
Gdiffdoes not work to show the target file itself instead of the file of the head commit, as it gets different git root dir and file path- In
fugitive#Path(url, ...), thetreepath and the file pathurlare obtained in literally-different paths each other.
- In
- Worked in a symbolic link dir
Once it goes wrong, perhaps it memorize the status somewhere, it hard to correct the wrong Git root dir path except restarting Vim.
To cover up such cases, can I manage the Git root dir manually?
There's no support for "covering up" Fugitive's Git dir/work tree detection. If you think there's a bug, the solution is to track it down and fix it. It might have something to do with this line, which might need a call to resolve(): https://github.com/tpope/vim-fugitive/blob/d4877e54cef67f5af4f950935b1ade19ed6b7370/plugin/fugitive.vim#L415