I have no excuse for my fail :/
Also cleaned up the checks slightly + moved git-specific testing to its own macro (minor changes to shaurens original patch applied)