threads / discuss / 57808

Issues with git config blame. ignorerevsfile when file not found

Subject: Issues with git config blame. ignorerevsfile when file not found

## tl;dr

One message between Apr 27, 2022 and Apr 27, 2022.

replies: 0people: 1as markdown or json

Maxime Fontaine Bombardier· Apr 27, 2022, 20:03 UTC · lore

Hi, I was looking to reformat full source code and ignore blame on this commit. I was following this article : https://michaelheap.com/git-ignore-rev/ Using this config command : `git config --global blame.ignoreRevsFile .git-blame-ignore-revs` I'm able to see git blame without seeing the formatting commit. BUT when the file is not found on the repo, git blame is broken with this error message: could not open object name list: .git-blame-ignore-revs

On one hand, you don't want to manually write the ignore file every time you want to use `git blame --ignore-rev <sha1>`, but on the other hand, git blame is broken on every other repo that does not include this file... I also use git lens pair with vscode to see blames and the extension is broken if the file does not exist too.

Here are 2 ideas on how I would fix this issue:
- New config "blame.ignoreNotFound" boolean.
  - False by default.
    - Will still see the error when the file is not found.
  - True
    - Will ignore errors about the file not found and remove the
--ignore-rev feature in the current git blame command.
    - I would put this setting to true as default, because I don't
care about error messages. All I care is that git blame shows me the
real author and not the one who launched the formatter, BUT to not
break default behavior, this should be an optional setting.
- New file standard! (which I think is a better option)
  - Beside .gitignore, you can find the file .gitignorerevs (or any
better name). If the file is found in the repo, doing git blame will
use the file by default.
  - That way :
    - It's not a global config that does not apply to specific repo or
break the command when it's not found.
    - It's not a manual argument you need to add each time the command is used.
    - Nor a local config that everyone contributing to this repo needs
to set up to use git blame correctly.
  - And :
    - Any git hosting website like Github/Gitlab/etc. could also use
the file to help dev search for specific changes on the website.
  - IMO: I don't think having a file that ignores some commits will
hurt people's workflow as this is a deliberate change. You know that
this commit is bad for the code history, so you want to ignore those
changes to clean up the history.

Well I hope I gave enough description to make this change happen :) Btw, I'm writing today because I definitely think this is a MUST feature to make git blame truly shine and because I searched online and I couldn't find any proper solution, just that you can't do that yet. https://stackoverflow.com/questions/70435937/git-blame-with-optional-ignorerevsfile

← back to recent threads