I'm not quite sure why the git remote code felt that it was necessary to overwrite the actual error code with -1, but I preserved that behavior in this helper function.