git-compat-util: add xstrdup_or_null helper