Skip to content

feat(git): ignore commits listed in .git-blame-ignore-revs - #1585

Merged
orhun merged 4 commits into
orhun:mainfrom
nabsei:feat/ignore-git-blame-ignore-revs
Jul 17, 2026
Merged

orhun merged 4 commits into
orhun:mainfrom
nabsei:feat/ignore-git-blame-ignore-revs

Conversation

@nabsei

@nabsei nabsei commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a use_git_blame_ignore_revs boolean config option (default false) under [git]. When enabled, it excludes:

  • commits whose hash (full or abbreviated) is listed in the repository's .git-blame-ignore-revs file, and
  • commits that only modify that file (e.g. the commit that adds a new hash to it).

Motivation and Context

Closes #1084. Mirrors what git blame --ignore-revs-file already does for blame output — lets large, non-semantic commits (mass reformatting, etc.) stay out of the changelog the same way they're already kept out of blame.

Implementation notes:

  • New Repository::filter_git_blame_ignore_revs method in git-cliff-core/src/repo.rs, called right after repository.commits(...) in git-cliff/src/lib.rs (same spot as the existing limit_commits truncation), gated by the new config flag.
  • Reads .git-blame-ignore-revs from the repo's root_path() at runtime — no-op if the file doesn't exist.
  • Added the field to config/cliff.toml (the embedded default config template) — every other boolean in GitConfig is set explicitly there rather than via #[serde(default)], so I followed that existing convention.
  • Documented in website/docs/configuration/git.md following the same style as the neighboring include_paths/exclude_paths entries.

How Has This Been Tested?

  • Two new unit tests in git-cliff-core/src/repo.rs using the existing create_temp_repo/create_commit_with_files test helpers:
    • filter_git_blame_ignore_revs_removes_listed_and_ignore_file_only_commits: 4 commits (2 normal, 1 listed as ignored, 1 that only adds the ignore file) → asserts exactly the 2 normal ones remain.
    • filter_git_blame_ignore_revs_is_a_no_op_without_the_file: confirms no-op when the file is absent.
  • cargo test --workspace: passes (pre-existing, unrelated failures on this shallow clone come from a handful of repo::test::* tests that hardcode this repo's own tag/commit hashes — confirmed identical failures on a clean checkout before my change).
  • Manual end-to-end: built the release binary, created a throwaway repo with 4 commits (one recorded as ignored, one that only adds .git-blame-ignore-revs), ran git-cliff with the option off vs. on — off shows all 4 commits, on shows only the 2 unrelated ones.
  • cargo +nightly fmt --all -- --check: clean.
  • cargo clippy --tests: no new warnings introduced (one pre-existing unrelated useless_borrows_in_formatting lint elsewhere in repo.rs blocks a full -D warnings run on this environment's clippy version, confirmed present on a clean checkout too).

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (no code change)
  • Refactor (refactoring production code)
  • Other

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly (if applicable).
  • I have formatted the code with rustfmt.
    • cargo +nightly fmt --all
  • I checked the lints with clippy.
    • cargo clippy --tests --verbose (see note above re: a pre-existing unrelated lint blocking -D warnings in this environment)
  • I have added tests to cover my changes.
  • All new and existing tests passed.
    • cargo test

Adds a use_git_blame_ignore_revs config option that, when enabled,
excludes:
- commits whose hash (full or abbreviated) is listed in the
  repository's .git-blame-ignore-revs file, and
- commits that only modify that file.

Mirrors what 'git blame --ignore-revs-file' already does for blame
output, letting large non-semantic commits (e.g. mass reformatting)
stay out of the changelog the same way they stay out of blame.

Closes orhun#1084
@nabsei
nabsei requested a review from orhun as a code owner July 13, 2026 22:51
@welcome

welcome Bot commented Jul 13, 2026

Copy link
Copy Markdown

Thanks for opening this pull request! Please check out our contributing guidelines! ⛰️

Comment thread config/cliff.toml Resolved
Per review feedback: a config flag is unnecessary here since the
behavior is a no-op when .git-blame-ignore-revs doesn't exist, so it
can just be applied unconditionally.
@nabsei

nabsei commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Done — removed the config option, the filtering now always runs unconditionally (it's already a no-op when .git-blame-ignore-revs doesn't exist). Updated the struct, default config, lib.rs wiring, and docs accordingly. Build/tests/fmt/clippy all clean.

@nabsei
nabsei requested a review from orhun July 14, 2026 16:19
Comment thread website/docs/configuration/git.md Resolved
Per review: git.md documents config options, and this isn't one
anymore (it's always-on behavior), so it doesn't belong there.
@nabsei

nabsei commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Moved the mention to tips-and-tricks.md as a new "Ignore commits listed in .git-blame-ignore-revs" section, and removed it from git.md.

@nabsei

nabsei commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Heads up: the Lints check just failed on this PR, but it's unrelated to these changes — it's the same pre-existing useless_borrows_in_formatting clippy lint on branch.name() at repo.rs:621 (a line untouched by this PR, in a different function). My last two commits here are doc-only.

Looks like it's an environment thing: this CI uses the floating stable Rust toolchain (not pinned), and main's own last few runs are also failing (on Test suite, the Codecov step) independent of any PR. Probably worth a look when you get a chance, but leaving it out of scope for this PR.

@nabsei
nabsei requested a review from orhun July 15, 2026 23:06
@nabsei

nabsei commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Hey @orhun, just checking in — since this is approved, is there anything else needed from my side before it can be merged? Happy to make any further changes if so. No rush, just following up.

@orhun orhun left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM, thanks!

Found a better spot for the documentation change afterall :)

@orhun
orhun merged commit 89247f4 into orhun:main Jul 17, 2026
107 of 109 checks passed
@welcome

welcome Bot commented Jul 17, 2026

Copy link
Copy Markdown

Congrats on merging your first pull request! ⛰️

orhun pushed a commit that referenced this pull request Oct 31, 2026
Since 2.14.0 a commit whose only changed file is
`.git-blame-ignore-revs` was dropped from the changelog even when its
hash is not listed in the file: the filter treated the file as a path to
exclude on its own, a side effect of the revision exclusion from #1585
(issue #1643).

The filter now retains solely on the listed hash prefixes — the same
rule `git blame --ignore-revs-file` applies — while a missing file,
comments and abbreviated hashes behave as before. The skipping-commits
docs no longer claim the file's own commits are dropped.

Tests: the listed commit is still excluded, an unlisted ignore-file-only
commit is kept, and abbreviated hashes still match; without the fix the
new assertions fail.
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.

Ignore .git-blame-ignore-revs hashes

2 participants