我正在尝试使用 libgit2 克隆 git 存储库,但以下代码即使取自示例,也会引发错误。
int do_clone(git_repository *repo, string url, string path) {
progress_data pd = {{0}};
git_repository *cloned_repo = NULL;
git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT;
git_checkout_opts checkout_opts = GIT_CHECKOUT_OPTS_INIT;
int error;
(void) repo;
checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE_CREATE;
checkout_opts.progress_cb = checkout_progress;
checkout_opts.progress_payload = &pd;
clone_opts.checkout_opts = checkout_opts;
clone_opts.fetch_progress_cb = &fetch_progress;
clone_opts.fetch_progress_payload = &pd;
error = git_clone(&cloned_repo, url.c_str(), path.c_str(), &clone_opts);
printf("\n");
if (error != 0) {
const git_error *err = giterr_last();
if (err) printf("ERROR %s\n", err->message);
else printf("ERROR %d: no detailed info\n", error);
} else if (cloned_repo) git_repository_free(cloned_repo);
return error;
}
以下是错误:
ERROR HTTP 解析器错误:无效的常量字符串
任何帮助方向?