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

Add a .git-blame-ignore-revs file #4439

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

Conversation

reneme
Copy link
Collaborator

@reneme reneme commented Nov 20, 2024

This cleans up git blame (also tig blame or VSCode's GitLens annotations) by automatically skipping commits that just reformatted code using clang-format. The name of the ignore-file isn't standard, but it seems to be the convention across the community.

Leaving this as a "Draft" for now. I personally just learnt about this feature, and find it super useful (worthy of a new top-level file 😏)

To use this, you'll have to adapt your git config like so:

git config --local blame.ignoreRevsFile src/configs/git-blame-ignore-revs
git config --local blame.markIgnoredLines true

The first config enables the usage of the ignore file by default, the second one marks blame-lines with a '?' if they skipped one or more commits.

@reneme reneme added the infra CI, package management, etc label Nov 20, 2024
@reneme reneme self-assigned this Nov 20, 2024
@reneme reneme force-pushed the chore/hide_clang_format_in_blame branch from a5d6abb to 06da719 Compare November 20, 2024 08:34
@coveralls
Copy link

coveralls commented Nov 20, 2024

Coverage Status

coverage: 91.246% (+0.001%) from 91.245%
when pulling b4ab5d3 on reneme:chore/hide_clang_format_in_blame
into e54502e on randombit:master.

Copy link
Owner

@randombit randombit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useful!

Given that git doesn't understand this by default, I disagree with your assessment re top level directory. Fine for src/configs.

Maybe also worth a mention in the contributing guide.

This cleans up 'git blame' by automatically skipping commits that
just reformatted code using clang-format. The name of the ignore-
file isn't standard, but it seems to be the convention.

To use this, you'll have to adapt your checkout's git config, by
running the following commands from within your local checkout:

git config --local blame.ignoreRevsFile src/configs/git-blame-ignore-revs
git config --local blame.markIgnoredLines true

The first config enables the usage of the ignore file by default,
the second one marks blame-lines with a '?' if they skipped one
or more commits.
@reneme reneme force-pushed the chore/hide_clang_format_in_blame branch from 06da719 to b4ab5d3 Compare November 25, 2024 08:03
@reneme
Copy link
Collaborator Author

reneme commented Nov 25, 2024

Given that git doesn't understand this by default, I disagree with your assessment re top level directory. Fine for src/configs.

In fact, its probably better to not configure this globally after all. It seems that (at least) tig blame is tripped up if other repositories don't provide this file but it is configured globally in ~/.gitconfig. Moved to src/configs and updated the documentation accordingly.

Maybe also worth a mention in the contributing guide.

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infra CI, package management, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants