Improve git revision detection

Relates #262