我想用libgit2實現git log -1 fullpath/myfile
。我對libgit2相當陌生。我在正確的軌道上嗎?這是我到目前爲止有:「git log -1 fullpath/myfile」with 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
似乎不能在檔案中回購的子目錄工作。任何想法?
謝謝 拉爾斯
謝謝! get_tree_entry_byname現在可用。但是,我無法找到任何線索來獲取關聯答案中的提交。你能給我另一個提示嗎? –