Show git branch in version output. fixes #1953
Also make sure strings in _version.py are correctly escaped.

Signed-off-by: Daira Hopwood <david-sarah@jacaranda.org>