wtf
Whitespace Total Fixer
wtf: one script to stop whitespace polluting your commits
Whitespace Total Fixer finds and fixes inconsistent whitespace and line endings before they clutter a Git, Mercurial, or Subversion commit. It is a single dependency-free Python script.
The origin story
The author starts the README by admitting he once spent far too long wrangling commits full of whitespace problems generated by text editors on several platforms. That frustration became a script called Whitespace Total Fixer, or wtf. It catches and repairs inconsistent whitespace and line endings so they do not clog up version control, and it is described as better than a shell one-liner and more flexible and detailed than git stripspace.
A script with no baggage
wtf.py is a single Python script with no dependencies beyond the standard library, and it is expected to run on either Python 2.7 or 3.x. Each type of whitespace issue usually gets three command line options, so you can fix it, report it, or ignore it.
The checks it runs
Line endings are matched so that lf and crlf never mix, with the default being to match everything to the first line's ending, or you can force a specific marker. It flags spaces followed by tabs at the start of a line, and can convert leading tabs to a set number of spaces or leading spaces to tabs. Mixed tab and space cases are left alone unless a separate flag asks for them to be changed.
Fitting into git
The docs cover running wtf automatically through a Git pre-commit hook. The careful version only changes the commit and leaves the working tree alone, skips files Git marks as binary or non-text, and plays nicely with git add --patch. The simple version runs wtf with the input option and also cleans up the working tree, at the cost of not playing nicely with the staged patch flow.
Reading the output
Without the quiet flag, wtf summarizes every file where it found or fixed something, and the verbose flag extends that to issue-free files. The sample output shows lines about chopped trailing spaces, blank lines at the end of file, a missing final newline, and changed line endings. Exit codes come in three: zero for no issues, ten for fixed issues, and twenty for unfixed ones, unless exit codes are disabled.
Editorial conclusion
The author wrote it after a long day of untangling cross-platform whitespace noise. Now there is a hook for it, a careful version that only touches commits, and a simple version that cleans the working tree too.
Community notes