【发布时间】:2011-12-12 22:37:35
【问题描述】:
我想用 libgit2 实现git log -1 fullpath/myfile。我对libgit2相当陌生。我在正确的轨道上吗?这是我目前所拥有的:
git_repository_head(&refToHead, repo);
headOID = git_reference_oid(refToHead);
git_commit_lookup(&headCommit, repo, headOID);
headTreeOID = git_commit_tree_oid(headCommit);
git_tree_lookup(&tree, repo, headTreeOID);
git_tree_entry_byname(tree, "repopath/myfile");
不幸的是,git_tree_entry_byname 似乎不适用于 repo 子目录中的文件。有什么想法吗?
谢谢你, 拉尔斯
【问题讨论】: