Improve performance (#505) by only running auto-alt (and auto-perms)
when HEAD has changed after calling a git command, e.g. after committing
or pulling new changes.
Also use this new information to remove stale symlinks when an alt file
has been removed.
The new test system is written with py.test. These tests are more
comprehensive, run faster by an order of magnitude, and are far more
maintainable. The tests themselves conform to PEP8.