Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
来自git_diff指针的Libgit2文件内容_Git_Libgit2 - Fatal编程技术网

来自git_diff指针的Libgit2文件内容

来自git_diff指针的Libgit2文件内容,git,libgit2,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)

我在我的项目中使用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对象,我需要在这两个提交中迭代并重新创建文件内容

你知道我该怎么做吗