Earlier this year, we found a bug in an internally written network service: a server was not listening on the correct port. We eventually traced this back to a single line of Python code, which considers white space at a beginning of a line significant, as being misindented.
The misidentation got through code review. How?
In a unified diff, a plus or minus sign at the start of a line shows additions and subtractions of new code and text, while unchanged lines are prefixed with a space. For a developer who is blind and using a screen reader this can become a problem. You can generally request a screen reader to announce the number of spaces on the left side of a line, which is required for a language with significant whitespace like Python. However, if these spaces come after a + or - sign, the screen reader doesn’t know that they should be announced.
Therefore, we have created diffspeak. This small script annotates lines with changes of indentation, which allows efficient perusal by a user of a screen reader.
To use, simply pipe your diff or git diff output through diffspeak:
git diff HEAD^ | diffspeak
Find diffspeak at prgmrcom/diffspeak on GitHub
We welcome suggestions and pull requests.