Factor-out common error git error handling.