Hello,
We have started using git hyper-blame (provided as part of Chrome's Depot Tools) at quip, which supports skipping over commits that are part of mass refactoring:
https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/git-hyper-blame.html.
Would there be interest in supporting a flag to switch to using hyper-blame instead of blame? This would make GitLens even more useful for large teams that have to do a lot of refactors.
Thanks!
@banga @jyavenard Can you provide more details on to how adding hyper-blame support would be useful for GitLens?
Hyper-blame allows to define commits that must ignored. This is particularly useful for commits that were whitespace changes only, such as reformatting or code style change.
For the Mozilla gecko tree we have very recently started to move from the Mozilla coding style to Google's. Plain git blame would make every lines appear to be last modified by the coding style change commit. Making git blame absolutely useless.
@jyavenard Thanks. How do you define those commits? In a config file or something? Would GitLens need to know about that? I'm trying to both understand the benefit and the work involved.
There's a .git-blame-ignore-revs file like so
https://hg.mozilla.org/mozilla-central/file/tip/.git-blame-ignore-revs
Gitlens doesn't need to know about it, only the custom git blame command
@jyavenard Could you provide me the output of a blame vs hyper-blame?
Here is the command GitLens uses for blaming:
git blame --root --incremental -- <file-name-here>
@eamodio unfortunately hyper-blame doesn't support any other arguments than the file name.
There's an example here which illustrates the difference: https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/git-hyper-blame.html.
If you want to try it out, you can follow these steps: https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up.
Another option would be for gitlens to implement git blame in terms of more low-level git operations and take into account .git-blame-ignore-revs in the algorithm.
Since git 2.23 this is supported by default, so no need for hyperblame!
https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-fileltfilegt
Just tried this and it works beautifully, thanks!
@banga Did you set this view the git config setting or did you use the gitlens.advanced.blame.customArguments setting (see here https://github.com/eamodio/vscode-gitlens#advanced-settings-)?
Yeah I added it to customArguments:

Note: It must be entered in gitlens as two separate items, if you enter it as a single line it won't work.
Also, you can set this option by setting the file(s) you want to use as the value to the git configuration blame.ignoreRevsFile.
Since Git now natively supports this and can be used with GitLens I'm going to close this.
I'm googling around trying to learn exactly how to use this new file, .git-blame-ignore-revs. Do we need to to add the "Custom Arguments" gitlens vscode setting?
Yes, see https://github.com/eamodio/vscode-gitlens/issues/413#issuecomment-523640184
Yeah I added it to customArguments:
Thanks for hinting in the right direction, @banga ! 馃殌
For some reason I can't get it to work, though, as ${workspaceRoot} seems to be _undefined_ in my case. How would I correctly let GitLens know about an ignore file that is
a) simply located in the repository's root directory or
b) has an absolute path like C:\dev\client\.git-blame-ignore-revs?
Any help is greatly appreciated! 馃檹馃徎
I figured out that I should just have used _Ctrl_ + _Shift_ + _P_ > _Developer: Reload Window_ to reload the window and force the settings to take effect.
For case a) I simply added the file name without any folder specification:

For case b) the following syntax worked:

I noticed a few issues. I had --ignore-rev-file instead of the PLURAL --ignore-revs-file. Git 2.28.0 was failing with the non plural version. In my package.json I have this preinstall script:
"preinstall": "echo \"Including dev-scripts/.gitconfig\" && git config --local include.path ./.gitconfig",
My repo's .gitconfig file is:
[blame]
ignoreRevsFile = .git-blame-ignore-revs
my .vscode/settings.json file:
{
"gitlens.advanced.blame.customArguments": [
"--ignore-revs-file",
".git-blame-ignore-revs" // I had to remove "$(workspaceRoot}/" prefix in the path, otherwise gitlens was stripping the whole --ignore-revs-file arg.
// if you open the GitLens (git) output pane (with this setting "gitlens.outputLevel": "debug" )
// and then change --ignore-revs-file to something wrong like --ignor-r-fil
// then you will see gitlens pass it through to this command:
// git blame --root --incremental --ignore-revs-file .git-blame-ignore-revs -- .vscode/settings.json
// You should see the git blame command has the --ignore-revs-file added to the `git blame` command
// You probably don't need the .gitconfig setting AND the gitlens vscode custom blame arg, but I'd rather cover my bases
],
}
Other vscode settings people may be interested in:
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// eslint autosave was having very poor performance for devin
// "eslint.autoFixOnSave": true,
// "editor.codeActionsOnSave": {
// "source.fixAll.eslint": true
// },
"editor.tabSize": 2,
"search.exclude": {
// "*.css": true,
"*.svg": true,
"yarn.lock": true,
".yarnrc.yml": true,
".yarnrc": true,
".yarn": true,
".gitignore": true,
".gitattributes": true,
"package-lock.json": true,
".eslintignore": true,
".prettierignore": true,
".stylelintignore": true,
".editorconfig": true,
"public": true,
"public/index.html": false,
},
Despite including the .gitconfig file, I had to also get the vscode setting correct to get gitlens to use the .git-blame-ignore-revs file and ignore certain changes.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Yeah I added it to customArguments:
