#ifndef GITFS_GIT_H #define GITFS_GIT_H #include #include #include #include #include namespace GitFS::Git { template [[noreturn]] void throwError(int err); template void gitSafe(int (*func)(P...), A... params) { if (int giterror = func(params...)) { throwError(giterror); } } template using TPtr = std::shared_ptr; template auto gitSafeGet(int (*get)(R **, P...), void (*release)(R *), A... params) { R * rtn = nullptr; gitSafe(get, &rtn, params...); return TPtr(rtn, release); } git_oid oidParse(std::string_view str); using RepositoryPtr = TPtr; RepositoryPtr repositoryOpenBare(const std::string & path); using BlobPtr = TPtr; BlobPtr blobLookup(const RepositoryPtr & repo, const git_oid & blob); using CommitPtr = TPtr; CommitPtr commitLookup(const RepositoryPtr & repo, const git_oid & commitId); using TreePtr = TPtr; TreePtr treeLookup(const RepositoryPtr & repo, const git_oid & treeId); using TreeEntryPtr = TPtr; TreeEntryPtr treeEntryByPath(const TreePtr & tree, const std::string & path); using RefPtr = TPtr; RefPtr commitish(const RepositoryPtr & repo, const std::string & name); RefPtr resolve(const RefPtr &); } namespace NetFS { struct Attr; Attr & operator<<(Attr &, const git_tree_entry &); Attr & operator<<(Attr &, const git_commit &); Attr & operator<<(Attr &, const git_blob &); } namespace std { std::ostream & operator<<(std::ostream &, const git_oid &); } #endif