Git: Add some null protections

Change-Id: Ia28c70690c6f79499fb8075935ec123b763bcc01
Reviewed-by: Jarek Kobus <jaroslaw.kobus@digia.com>