Sertion / vscode-gitblame

Visual Studio Code Extension - See Git Blame info in status bar.
https://marketplace.visualstudio.com/items/waderyan.gitblame
MIT License
72 stars 31 forks source link

Blame info persistent over file change and file close #115

Open wenfangdu opened 2 years ago

wenfangdu commented 2 years ago

Sometimes, after doing a git rebase, the git blame info is outdated, reopening the editor won't help, had to reopen the VSCode window to read the latest commit data, is there a way to force Git Blame to use the latest commit data?

If there's no way, could you please add an option to do that?

Sertion commented 2 years ago

Hey Wenfang Du! Thank you for the bug report.

This is very weird. I have two checks in place that should help prevent this exact behavior. Can you describe your setup a bit more?

Operating system: Windows/Linux/OSX/BSD
WSL/WSL2: Yes/No
Remote SSH folder: Yes/No
Remote folder with sync program: Yes/No
vscode version:
output from `git rev-list --all --count`: 
wenfangdu commented 2 years ago

@Sertion

Operating system: Windows 10 WSL/WSL2: No Remote SSH folder: No Remote folder with sync program: No VSCode version: v1.57.1 Output from git rev-list --all --count: 221

I was mainly doing interactive rebasing to squash and amend commits.

wenfangdu commented 2 years ago

@Sertion I'm curious does Git Blame reobtain the commit info right after a commit? Because I just tested, even after a simple commit (e.g. edit one line), the git-blame info isn't refreshed in place, reopen the editor won't refresh either.

Sertion commented 2 years ago

It is very weird that reopening does not refresh the cache as there is code specifically written for that case. I use fs.watch for detecting if a file changes.

Sadly this is sort of the best available.

There is nothing in place for detecting commits right now. I don't know how easy it would be to add.

Yottster commented 2 years ago

Would an fs.watch on whatever file .git/HEAD points to work?

Sertion commented 2 years ago

Would an fs.watch on whatever file .git/HEAD points to work?

Could work. The thing to look out for in that case is that a "workspace" can have multiple folders and they can have multiple .git-folders.

Sertion commented 2 years ago

I might have found a fix for the issues discussed here. It would be very valuable for me if @wenfangdu could test the changes before I release them and see if they solve the issues you have experienced.

gitblame-8.2.0-prerelease-1.zip

wenfangdu commented 2 years ago

@Sertion I'm curious does Git Blame reobtain the commit info right after a commit? Because I just tested, even after a simple commit (e.g. edit one line), the git-blame info isn't refreshed in place, reopen the editor won't refresh either.

Strange, can't reproduce it now, even with v8.1.0. I'll report if I encounter it again.

wenfangdu commented 2 years ago

@Sertion Sadly, the pre-release didn't fix this issue, this time I was using VSCode v1.59.1.