This pattern is only used in two places within libgit2. Do we really need it abstracted out?