vim-fugitive icon indicating copy to clipboard operation
vim-fugitive copied to clipboard

[Question] Is there any way to manage Git dir?

Open KSR-Yasuda opened this issue 1 year ago • 1 comments

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_dir as the repo A, while it should be the repo B the file actually belongs to.
  • 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 and git submodule add-ed to the repo A. Then, git submodule absorbgitdirs-ed to move the .git dir of the submodule repo B into the .git dir of the parent repo A.
    • Then, I got the .git file of repo B gitdir: ../.../../d/.../actual/repoA/.git/modules/repoB; and the config setting of repo B core.worktree as ../.../../c/.../symlink/repoA/repoB or such.
    • The both points to the different path in the literal sense, fugitive works bad.
      • Gdiff does 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, ...), the tree path and the file path url are obtained in literally-different paths each other.

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?

KSR-Yasuda avatar Oct 23 '24 00:10 KSR-Yasuda

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

tpope avatar Nov 19 '24 22:11 tpope