git-blame.vim
git-blame.vim copied to clipboard
Added symlink support
If there is a symlink pointing to a file in the same directory, vim uses it as the filename.
@Kadiryanik what does this actually do...?
If we create a symlink in the same directory, the blame was trying to read that symlink file changes.
You can try it as below.
- Create the testfile in a git repo.
- Put some lines in it.
- Create a symlink to that file in the same dir.
- Commit all changes.
- Open symlink to edit in vim.
- Try to get blame result (except first line) with this plugin.
- You will get the error: [Unhandled error: fatal: file symlink-to-testfile has only 1 line]
If you apply this patch and check the step 5 & 6, you will get exact blame result. This patch aims to get exact file name from symlink and run git blame on it.
Please let me know if this is still not clear.
Ah. So you're following history through the symlink. And you probably want realpath (readlink itself might return a link). There is no need for basename as git can resolve full paths to repo-relative paths.
I've merged your commit (and the popup PR) into my fork, https://github.com/kstr0k/git-blame.vim/ (it seems the original repo here might not be getting updates at this point).
For reference, vim has %:p:h expansion (no need for dirname) and git has -C dir (no need for separate cd ...; git ...).
There was also a $(basename) applied to the line number, which seemed superfluous, but maybe I'm missing some neovim thing.