我正在尝试使用树到树的比较来区分我的HEAD远程分支。为了获取远程树,我首先尝试通过传递通过git_tree_lookup
获得的远程对象来使用git_revparse_single
。即使我事先连接并取出遥控器,这也会失败
但是,如果在检查之后,我将对象指针转换为git_commit *
并改为使用git_commit_tree
,它会成功并返回远程树。
为什么一种方式有效,另一种方式无效?
答案 0 :(得分:0)
因为引用上的git_revparse_single
会返回git_commit
,而不是git_tree
。并且您无法将git_commit
投射到git_tree
。
使用git_commit
从git_commit_tree
查找树是正确的。