docs: make blame.ignoreRevsFile discoverable and automatic - #2275
Open
dlovell wants to merge 3 commits into
Open
docs: make blame.ignoreRevsFile discoverable and automatic#2275dlovell wants to merge 3 commits into
dlovell wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #2275 +/- ##
==========================================
- Coverage 83.35% 83.34% -0.01%
==========================================
Files 165 165
Lines 21534 21534
==========================================
- Hits 17949 17947 -2
- Misses 3585 3587 +2
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
`.git-blame-ignore-revs` has no effect until a clone sets blame.ignoreRevsFile, and git deliberately never accepts that setting from the repository itself. Document the one-liner next to the existing pre-commit setup step, say so in the file's own header, and add a post-checkout hook so `pre-commit install` sets it going forward. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0111Kwvgt9muBtxQtfr9YdJv
dlovell
force-pushed
the
docs-blame-ignore-revs
branch
from
September 2, 2026 13:57
2c485c2 to
33cd483
Compare
dlovell
marked this pull request as ready for review
September 2, 2026 13:59
`git config <name> <value>` is the single-value form: it exits 5 with "cannot overwrite multiple values with a single value" when a clone's local config already holds more than one blame.ignoreRevsFile entry, which git supports. The post-checkout hook then failed on every checkout with no way to recover, since each retry hit the same error. --replace-all collapses the list instead. Also correct the header's claim that `pre-commit install` sets the config (only the next checkout does), record that enabling it makes `git blame` fatal at revs predating this file with no per-command override, and tell existing clones to re-run `pre-commit install` to pick up the new hook type. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S4KruUywAZTsH2Gb56Guyk
…revs file The header comment had grown into a second copy of the setup instructions and the caveat, in a file that is mostly machine-read. Keep CONTRIBUTING.md as the one place that explains it -- a new "git blame and bulk reformats" subsection next to the setup step it belongs to -- and cut the header to three lines that say what the file is and where to read the rest. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S4KruUywAZTsH2Gb56Guyk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The repo has a
.git-blame-ignore-revsfile, but it does nothing in a fresh clone. Git deliberately refuses to readblame.ignoreRevsFilefrom repository-tracked config (that would let a repo change local git behavior), so every contributor has to set it by hand — and nothing in the repo says so. GitHub's web blame reads the file automatically, so the local/web mismatch is easy to miss.Changes
CONTRIBUTING.md— document the one-liner (git config --replace-all blame.ignoreRevsFile .git-blame-ignore-revs) right after the existingpre-commit installstep, and a "git blame and bulk reformats" subsection covering how the hook sets it, that existing clones must re-runpre-commit installto pick up the new hook type, and the caveat below. This is the one place any of it is written down..git-blame-ignore-revs— a three-line header saying what the file is and pointing at that subsection, rather than restating it in a file that is mostly machine-read..pre-commit-config.yaml— apost-checkouthook that sets the config, plusdefault_install_hook_types: [pre-commit, post-checkout]sopre-commit installwires both. Contributors who follow the setup steps get it without running the extra command.--replace-allrather than plaingit config <name> <value>: the single-value form hard-fails (exit 5,cannot overwrite multiple values with a single value) when a clone's local config already holds more than oneblame.ignoreRevsFileentry, which git explicitly supports. The hook would then printFailedon every checkout with no way to recover, since each retry hits the same error.--replace-allcollapses the list to the one correct value.Verification
In a fresh clone of this branch (pre-commit 4.6.0, git 2.55):
blame.ignoreRevsFilestarts unset.pre-commit installreportsinstalled at .git/hooks/pre-commitandinstalled at .git/hooks/post-checkout.configure blame.ignoreRevsFile...Passed, after whichgit config --get blame.ignoreRevsFilereturns.git-blame-ignore-revs.blame.ignoreRevsFilevalues, the hook still passes and leaves exactly one value. (With the single-value form it exited 5 and failed on every subsequent checkout.)post-checkouthook (e.g. git-lfs) is preserved — pre-commit migrates it via its.legacymechanism.Caveats
git blamefails at revs predating this file. Once the config is set,git blameon any file exits 128 withfatal: could not open object name list: .git-blame-ignore-revswhenever the working tree is at a rev older than14a30475(2024-05-17) — bisecting into early history, or checking out a tag up tov0.1.2.post. There is no per-command override:blame.ignoreRevsFileis multi-valued, so-c blame.ignoreRevsFile=and--ignore-revs-file=""/=/dev/nullall append rather than replace, and blame still tries to open the configured path. The workaround isgit config --unset-all blame.ignoreRevsFilefor the duration; the next checkout restores it. This is documented inCONTRIBUTING.md.01b9b5aa, the ruff import-order pass) no longer owns any lines in any file. This PR is about the mechanism being in place and correct for the next bulk reformat, not about fixing blame output right now.Notes
default_install_hook_typeschanges whatpre-commit installinstalls, so existing clones need to re-runpre-commit installonce to pick up the post-checkout hook. New clones get it from the documented setup flow.stages: [post-checkout]only, so it never runs ongit commitandpre-commit.ciis unaffected (it doesn't run post-checkout hooks). It does run on file checkouts, though:git checkout -- <file>measured 0.153s with the hook vs 0.004s without, andgit restore <file>prints aconfigure blame.ignoreRevsFile...Passedline each time.docs-blame-ignore-revsrather thandocs/blame-ignore-revs: origin already has a branch literally nameddocs, which blocks anydocs/*ref.