来自git_diff指针的Libgit2文件内容

时间:2017-04-14 08:36:52

标签: git libgit2

我在我的项目中使用了libgit2,我希望获得两个提交之间的文件列表及其内容。

// ID of the selected trees from two commits & trees themselves
git_oid pre_tree_id, post_tree_id
git_tree *pre_tree, *post_tree;

// Here I get the trees
git_tree_lookup(&pre_tree, repo, &pre_tree_id);
git_tree_lookup(&post_tree, repo, &post_tree_id);

// Now I get differences between the trees
git_diff_tree_to_tree(&diff, repo, pre_tree, post_tree, NULL);

我得到了git_diff对象,我需要迭代并在两次提交中重新创建文件内容。

我有什么想法可以做到这一点?

0 个答案:

没有答案