-
Notifications
You must be signed in to change notification settings - Fork 87
Git pre-commit hook: strip trailing whitespace #50
Copy link
Copy link
Open
Labels
AIIssue which can probably be resolved by agentic LLM AI coding, rather than scarce humans.Issue which can probably be resolved by agentic LLM AI coding, rather than scarce humans.BackendOriginal content, Hakyll/Haskell/scripts, Markdown/HTML etc. Usually not CSS/JS. Owner: Gwern.Original content, Hakyll/Haskell/scripts, Markdown/HTML etc. Usually not CSS/JS. Owner: Gwern.enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Metadata
Metadata
Assignees
Labels
AIIssue which can probably be resolved by agentic LLM AI coding, rather than scarce humans.Issue which can probably be resolved by agentic LLM AI coding, rather than scarce humans.BackendOriginal content, Hakyll/Haskell/scripts, Markdown/HTML etc. Usually not CSS/JS. Owner: Gwern.Original content, Hakyll/Haskell/scripts, Markdown/HTML etc. Usually not CSS/JS. Owner: Gwern.enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Haskell source files are usually clean because I have an Emacs save-hook which strips trailing whitespace on Haskell/R/Bash/Python files. This doesn't help on the CSS/JS/PHP because usually someone else (like Said Achmiz or a LLM) is editing them. This leads to noisy diffs (and slightly wasteful token use).
We should add a simple git hook to strip trailing whitespace from all text files in the repo before each commit is saved. (As far as I know, no text files in it depend on trailing whitespace.)
Claude-4.7-opus suggests a
build/git-hooks/pre-commitVC-controlled Bash script enabled bygit config core.hooksPath build/git-hooks, that operates on the git index directly (rather than the working tree). We can further ensure that text files are valid UTF-8 Unix text files without legacy BOMs, which I believe should also be true of all repo text files, and is worth ensuring.Claude's prototype: