相当于libgit2中的git merge origin / master

时间:2015-11-26 11:44:37

标签: git libgit2

我使用的是libgit2 C Version 0.20.0库。我已经成功实现了更新oid的git_remote_fetch(),但之后我无法正确调用merge方法。

试图调用int git_merge(git_repository * repo,const git_annotated_commit ** their_heads,size_t his_heads_len,const git_merge_options * merge_opts,const git_checkout_options * checkout_opts);但第二个参数git_annotated_commit应该是常量。我从方法git_annotated_commit_lookup()方法中获取git_annotated_commit **。任何人都可以告诉我如何将git_annotated_commit **转换为const?还有其他方法可以将git_annotated_commit **作为常量吗?

使用Git bash控制台我执行命令 git merge origin / master ,它可以成功更新存储库的内容,任何机构都可以告诉我在libgit2中需要使用哪个命令来执行此操作吗?

1 个答案:

答案 0 :(得分:0)

要将git_annotated_commit **out转换为const git_annotated_commit **their_heads,您应该使用:const_cast,例如:

const git_annotated_commit **their_heads = const_cast<const git_annotated_commit**>(out);