Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added symlink support #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Kadiryanik
Copy link

If there is a symlink pointing to a file in the same directory, vim uses it as the filename.

@mralusw
Copy link

mralusw commented Jan 28, 2024

@Kadiryanik what does this actually do...?

@Kadiryanik
Copy link
Author

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.

  1. Create the testfile in a git repo.
  2. Put some lines in it.
  3. Create a symlink to that file in the same dir.
  4. Commit all changes.
  5. Open symlink to edit in vim.
  6. Try to get blame result (except first line) with this plugin.
  7. 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.

@mralusw
Copy link

mralusw commented Feb 23, 2024

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.

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.

2 participants