Avoid exception when git variables aren't set.
(cherry picked from commit dcc9035d65ab0b257c26bb65d8998793f4ae1f09)