diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2020-08-22 15:26:11 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2020-08-22 15:26:11 +0100 |
commit | f759884235b4594c4f960ea0c587697eef717665 (patch) | |
tree | 92f3b95e99fac6688a6d9cec88b6553cb77f0c60 /src | |
parent | Update to new NetFS interface (diff) | |
download | netfs-gitfs-f759884235b4594c4f960ea0c587697eef717665.tar.bz2 netfs-gitfs-f759884235b4594c4f960ea0c587697eef717665.tar.xz netfs-gitfs-f759884235b4594c4f960ea0c587697eef717665.zip |
Clang-format
Diffstat (limited to 'src')
-rw-r--r-- | src/blob.cpp | 25 | ||||
-rw-r--r-- | src/blob.h | 31 | ||||
-rw-r--r-- | src/dir.cpp | 19 | ||||
-rw-r--r-- | src/dir.h | 25 | ||||
-rw-r--r-- | src/git.cpp | 65 | ||||
-rw-r--r-- | src/git.h | 40 | ||||
-rw-r--r-- | src/main.cpp | 44 | ||||
-rw-r--r-- | src/repo.cpp | 86 | ||||
-rw-r--r-- | src/repo.h | 78 | ||||
-rw-r--r-- | src/repoList.cpp | 20 | ||||
-rw-r--r-- | src/repoList.h | 14 |
11 files changed, 196 insertions, 251 deletions
diff --git a/src/blob.cpp b/src/blob.cpp index 6311b31..4e1b2de 100644 --- a/src/blob.cpp +++ b/src/blob.cpp @@ -1,13 +1,10 @@ -#include <Ice/ObjectAdapter.h> -#include <sys/stat.h> #include "blob.h" #include "repo.h" +#include <Ice/ObjectAdapter.h> +#include <sys/stat.h> GitFS::Blob::Blob(const Repo * const r, std::string && path) : - repo(r), - entry(Git::TreeEntryByPath(repo->tree, path)), - blob(getBlob()), - blobSize(git_blob_rawsize(blob.get())), + repo(r), entry(Git::TreeEntryByPath(repo->tree, path)), blob(getBlob()), blobSize(git_blob_rawsize(blob.get())), blobContent(static_cast<const char *>(git_blob_rawcontent(blob.get()))) { } @@ -28,14 +25,13 @@ GitFS::Blob::getBlob() const } void -GitFS::Blob::close(const ::Ice::Current& current) +GitFS::Blob::close(const ::Ice::Current & current) { current.adapter->remove(current.id); } - NetFS::Attr -GitFS::Blob::fgetattr(ReqEnv, const ::Ice::Current&) +GitFS::Blob::fgetattr(ReqEnv, const ::Ice::Current &) { NetFS::Attr a; a << *blob << *entry << *repo->commit; @@ -44,9 +40,8 @@ GitFS::Blob::fgetattr(ReqEnv, const ::Ice::Current&) return a; } - NetFS::Buffer -GitFS::Blob::read(long long int o, long long int s, const ::Ice::Current&) +GitFS::Blob::read(long long int o, long long int s, const ::Ice::Current &) { const decltype(blobSize) offset(o); const decltype(blobSize) size(s); @@ -57,18 +52,14 @@ GitFS::Blob::read(long long int o, long long int s, const ::Ice::Current&) return NetFS::Buffer(blobContent + offset, blobContent + offset + len); } - void -GitFS::Blob::ftruncate(ReqEnv, long long int, const ::Ice::Current&) +GitFS::Blob::ftruncate(ReqEnv, long long int, const ::Ice::Current &) { throw NetFS::SystemError(EROFS); } - void -GitFS::Blob::write(long long int, long long int, Buffer, const ::Ice::Current&) +GitFS::Blob::write(long long int, long long int, Buffer, const ::Ice::Current &) { throw NetFS::SystemError(EROFS); } - - @@ -1,31 +1,30 @@ #ifndef GITFS_BLOB_H #define GITFS_BLOB_H -#include <file.h> #include "git.h" +#include <file.h> namespace GitFS { using namespace NetFS; class Repo; class Blob : public File { - public: - Blob(const Repo * const r, std::string &&); + public: + Blob(const Repo * const r, std::string &&); - void close(const ::Ice::Current& current) override; - Attr fgetattr(ReqEnv env, const ::Ice::Current& current) override; - Buffer read(long long int offset, long long int size, const ::Ice::Current& current) override; - void ftruncate(ReqEnv env, long long int size, const ::Ice::Current& current) override; - void write(long long int offset, long long int size, Buffer data, const ::Ice::Current& current) override; + void close(const ::Ice::Current & current) override; + Attr fgetattr(ReqEnv env, const ::Ice::Current & current) override; + Buffer read(long long int offset, long long int size, const ::Ice::Current & current) override; + void ftruncate(ReqEnv env, long long int size, const ::Ice::Current & current) override; + void write(long long int offset, long long int size, Buffer data, const ::Ice::Current & current) override; - private: - Git::BlobPtr getBlob() const; - const Repo * const repo; - Git::TreeEntryPtr entry; - Git::BlobPtr blob; - const decltype(git_blob_rawsize({})) blobSize; - const char * const blobContent; + private: + Git::BlobPtr getBlob() const; + const Repo * const repo; + Git::TreeEntryPtr entry; + Git::BlobPtr blob; + const decltype(git_blob_rawsize({})) blobSize; + const char * const blobContent; }; } #endif - diff --git a/src/dir.cpp b/src/dir.cpp index 78ff83a..9e524aa 100644 --- a/src/dir.cpp +++ b/src/dir.cpp @@ -1,12 +1,9 @@ +#include "dir.h" +#include "repo.h" #include <Ice/ObjectAdapter.h> #include <sys/stat.h> -#include "repo.h" -#include "dir.h" -GitFS::Directory::Directory(Repo * const r, std::string && p) : - repo(r), - path(std::move(p)), - subTreeCacheRootId({}) +GitFS::Directory::Directory(Repo * const r, std::string && p) : repo(r), path(std::move(p)), subTreeCacheRootId({}) { getSubtree(); } @@ -32,14 +29,13 @@ GitFS::Directory::getSubtree() const } void -GitFS::Directory::close(const ::Ice::Current& current) +GitFS::Directory::close(const ::Ice::Current & current) { current.adapter->remove(current.id); } - NetFS::NameList -GitFS::Directory::readdir(const ::Ice::Current&) +GitFS::Directory::readdir(const ::Ice::Current &) { const auto subTree = getSubtree(); NetFS::NameList list; @@ -50,9 +46,8 @@ GitFS::Directory::readdir(const ::Ice::Current&) return list; } - NetFS::DirectoryContents -GitFS::Directory::listdir(const ::Ice::Current&) +GitFS::Directory::listdir(const ::Ice::Current &) { const auto subTree = getSubtree(); NetFS::DirectoryContents list; @@ -70,5 +65,3 @@ GitFS::Directory::listdir(const ::Ice::Current&) } return list; } - - @@ -1,29 +1,28 @@ #ifndef GITFS_DIRECTORY_H #define GITFS_DIRECTORY_H -#include <directory.h> #include "git.h" +#include <directory.h> namespace GitFS { using namespace NetFS; class Repo; class Directory : public NetFS::Directory { - public: - Directory(Repo * const r, std::string &&); + public: + Directory(Repo * const r, std::string &&); - void close(const ::Ice::Current& current) override; - NameList readdir(const ::Ice::Current& current) override; - DirectoryContents listdir(const ::Ice::Current& current) override; + void close(const ::Ice::Current & current) override; + NameList readdir(const ::Ice::Current & current) override; + DirectoryContents listdir(const ::Ice::Current & current) override; - private: - Git::TreePtr getSubtree() const; - Repo * const repo; - const std::string path; + private: + Git::TreePtr getSubtree() const; + Repo * const repo; + const std::string path; - mutable Git::TreePtr subTreeCache; - mutable git_oid subTreeCacheRootId; + mutable Git::TreePtr subTreeCache; + mutable git_oid subTreeCacheRootId; }; } #endif - diff --git a/src/git.cpp b/src/git.cpp index f3f437e..1c9da62 100644 --- a/src/git.cpp +++ b/src/git.cpp @@ -1,13 +1,12 @@ #include "git.h" -#include <execinfo.h> #include <exceptions.h> -#include <types.h> +#include <execinfo.h> #include <sys/stat.h> +#include <types.h> namespace GitFS::Git { template<> - [[noreturn]] - void + [[noreturn]] void throwError<NetFS::SystemError>(int err) { if (err == GIT_ENOTFOUND) { @@ -17,63 +16,64 @@ namespace GitFS::Git { } template<> - [[noreturn]] - void + [[noreturn]] void throwError<NetFS::ConfigError>(int) { throw NetFS::ConfigError(); } - git_oid OidParse(const std::string_view & str) + git_oid + OidParse(const std::string_view & str) { git_oid oid; gitSafe<NetFS::ConfigError>(git_oid_fromstrn, &oid, str.data(), str.length()); return oid; } - RepositoryPtr RepositoryOpenBare(const std::string & path) + RepositoryPtr + RepositoryOpenBare(const std::string & path) { - return gitSafeGet<NetFS::ConfigError>( - git_repository_open_bare, git_repository_free, path.c_str()); + return gitSafeGet<NetFS::ConfigError>(git_repository_open_bare, git_repository_free, path.c_str()); } - BlobPtr BlobLookup(const RepositoryPtr & repo, const git_oid & blob) + BlobPtr + BlobLookup(const RepositoryPtr & repo, const git_oid & blob) { - return gitSafeGet<NetFS::SystemError>( - git_blob_lookup, git_blob_free, repo.get(), &blob); + return gitSafeGet<NetFS::SystemError>(git_blob_lookup, git_blob_free, repo.get(), &blob); } - CommitPtr CommitLookup(const RepositoryPtr & repo, const git_oid & commitId) + CommitPtr + CommitLookup(const RepositoryPtr & repo, const git_oid & commitId) { - return gitSafeGet<NetFS::ConfigError>( - git_commit_lookup, git_commit_free, repo.get(), &commitId); + return gitSafeGet<NetFS::ConfigError>(git_commit_lookup, git_commit_free, repo.get(), &commitId); } - TreePtr TreeLookup(const RepositoryPtr & repo, const git_oid & treeId) + TreePtr + TreeLookup(const RepositoryPtr & repo, const git_oid & treeId) { - return gitSafeGet<NetFS::SystemError>( - git_tree_lookup, git_tree_free, repo.get(), &treeId); + return gitSafeGet<NetFS::SystemError>(git_tree_lookup, git_tree_free, repo.get(), &treeId); } - TreeEntryPtr TreeEntryByPath(const TreePtr & tree, const std::string & path) + TreeEntryPtr + TreeEntryByPath(const TreePtr & tree, const std::string & path) { - return gitSafeGet<NetFS::SystemError>( - git_tree_entry_bypath, git_tree_entry_free, tree.get(), path.c_str() + 1); + return gitSafeGet<NetFS::SystemError>(git_tree_entry_bypath, git_tree_entry_free, tree.get(), path.c_str() + 1); } - RefPtr Commitish(const RepositoryPtr & repo, const std::string & name) + RefPtr + Commitish(const RepositoryPtr & repo, const std::string & name) { - return gitSafeGet<NetFS::ConfigError>( - git_reference_dwim, git_reference_free, repo.get(), name.c_str()); + return gitSafeGet<NetFS::ConfigError>(git_reference_dwim, git_reference_free, repo.get(), name.c_str()); } - RefPtr Resolve(const RefPtr & ref) + RefPtr + Resolve(const RefPtr & ref) { - return gitSafeGet<NetFS::ConfigError>( - git_reference_resolve, git_reference_free, ref.get()); + return gitSafeGet<NetFS::ConfigError>(git_reference_resolve, git_reference_free, ref.get()); } } namespace NetFS { - Attr & operator<<(Attr & a, const git_tree_entry & e) + Attr & + operator<<(Attr & a, const git_tree_entry & e) { a.mode = git_tree_entry_filemode(&e); if (S_ISDIR(a.mode)) { @@ -88,13 +88,15 @@ namespace NetFS { return a; } - Attr & operator<<(Attr & a, const git_commit & c) + Attr & + operator<<(Attr & a, const git_commit & c) { a.ctime = a.atime = a.mtime = git_commit_time(&c); return a; } - Attr & operator<<(Attr & a, const git_blob & b) + Attr & + operator<<(Attr & a, const git_blob & b) { a.blockSize = 1; a.blocks = a.size = git_blob_rawsize(&b); @@ -112,4 +114,3 @@ namespace std { return s; } } - @@ -1,38 +1,36 @@ #ifndef GITFS_GIT_H #define GITFS_GIT_H -#include <memory> #include <git2.h> +#include <memory> #include <ostream> namespace GitFS::Git { - template<typename E> - [[noreturn]] void throwError(int err); + template<typename E>[[noreturn]] void throwError(int err); - template<typename E, typename ... P, typename ... A> + template<typename E, typename... P, typename... A> void - gitSafe(int (*func)(P...), A ... p) + gitSafe(int (*func)(P...), A... p) { if (int _giterror = func(p...)) { throwError<E>(_giterror); } } - template<typename T> - using TPtr = std::shared_ptr<T>; + template<typename T> using TPtr = std::shared_ptr<T>; - template<typename E, typename R, typename ... P, typename ... A> + template<typename E, typename R, typename... P, typename... A> auto - gitSafeGet(int(*get)(R**, P...), void(*release)(R*), A ... p) + gitSafeGet(int (*get)(R **, P...), void (*release)(R *), A... p) { R * r = nullptr; gitSafe<E>(get, &r, p...); return TPtr<R>(r, release); } - template<typename E, typename R, typename ... P, typename ... A> + template<typename E, typename R, typename... P, typename... A> auto - gitSafeGet(int(*get)(R**, P...), A ... p) + gitSafeGet(int (*get)(R **, P...), A... p) { R * r = nullptr; gitSafe<E>(get, &r, p...); @@ -41,28 +39,23 @@ namespace GitFS::Git { git_oid OidParse(const std::string_view & str); - using RepositoryPtr = decltype(gitSafeGet<std::exception>( - git_repository_open_bare, git_repository_free, nullptr)); + using RepositoryPtr = decltype(gitSafeGet<std::exception>(git_repository_open_bare, git_repository_free, nullptr)); RepositoryPtr RepositoryOpenBare(const std::string & path); - using BlobPtr = decltype(gitSafeGet<std::exception>( - git_blob_lookup, git_blob_free, nullptr, nullptr)); + using BlobPtr = decltype(gitSafeGet<std::exception>(git_blob_lookup, git_blob_free, nullptr, nullptr)); BlobPtr BlobLookup(const RepositoryPtr & repo, const git_oid & blob); - using CommitPtr = decltype(gitSafeGet<std::exception>( - git_commit_lookup, git_commit_free, nullptr, nullptr)); + using CommitPtr = decltype(gitSafeGet<std::exception>(git_commit_lookup, git_commit_free, nullptr, nullptr)); CommitPtr CommitLookup(const RepositoryPtr & repo, const git_oid & commitId); - using TreePtr = decltype(gitSafeGet<std::exception>( - git_tree_lookup, git_tree_free, nullptr, nullptr)); + using TreePtr = decltype(gitSafeGet<std::exception>(git_tree_lookup, git_tree_free, nullptr, nullptr)); TreePtr TreeLookup(const RepositoryPtr & repo, const git_oid & treeId); - using TreeEntryPtr = decltype(gitSafeGet<std::exception>( - git_tree_entry_bypath, git_tree_entry_free, nullptr, nullptr)); + using TreeEntryPtr + = decltype(gitSafeGet<std::exception>(git_tree_entry_bypath, git_tree_entry_free, nullptr, nullptr)); TreeEntryPtr TreeEntryByPath(const TreePtr & tree, const std::string & path); - using RefPtr = decltype(gitSafeGet<std::exception>( - git_reference_dwim, git_reference_free, nullptr, nullptr)); + using RefPtr = decltype(gitSafeGet<std::exception>(git_reference_dwim, git_reference_free, nullptr, nullptr)); RefPtr Commitish(const RepositoryPtr & repo, const std::string & name); RefPtr Resolve(const RefPtr &); } @@ -79,4 +72,3 @@ namespace std { } #endif - diff --git a/src/main.cpp b/src/main.cpp index c6b1c90..59fa299 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,35 +1,35 @@ -#include <icetrayService.h> -#include <git2.h> +#include "repoList.h" #include <factory.h> +#include <git2.h> #include <icecube.h> -#include "repoList.h" +#include <icetrayService.h> namespace GitFS { class Main : public IceTray::Service { - public: - Main() - { - git_libgit2_init(); - } + public: + Main() + { + git_libgit2_init(); + } - ~Main() override - { - git_libgit2_shutdown(); - } + ~Main() override + { + git_libgit2_shutdown(); + } - Main(const Main &) = delete; - Main(Main &&) = delete; + Main(const Main &) = delete; + Main(Main &&) = delete; - Main & operator=(const Main &) = delete; - Main & operator=(Main &&) = delete; + Main & operator=(const Main &) = delete; + Main & operator=(Main &&) = delete; - void addObjects(const std::string &, const Ice::CommunicatorPtr & ic, const Ice::StringSeq &, const Ice::ObjectAdapterPtr & adp) override - { - IceTray::Cube::addObject<NetFS::Service, RepoList>(adp, "Service", - std::move(ic->getProperties())); - } + void + addObjects(const std::string &, const Ice::CommunicatorPtr & ic, const Ice::StringSeq &, + const Ice::ObjectAdapterPtr & adp) override + { + IceTray::Cube::addObject<NetFS::Service, RepoList>(adp, "Service", std::move(ic->getProperties())); + } }; NAMEDFACTORY("default", Main, IceTray::ServiceFactory); } - diff --git a/src/repo.cpp b/src/repo.cpp index 9bf156a..41e6f7d 100644 --- a/src/repo.cpp +++ b/src/repo.cpp @@ -1,21 +1,18 @@ -#include <Ice/ObjectAdapter.h> -#include <sys/stat.h> #include "repo.h" #include "blob.h" #include "dir.h" +#include <Ice/ObjectAdapter.h> +#include <sys/stat.h> -std::string operator/(const std::string & a, const std::string & b) +std::string +operator/(const std::string & a, const std::string & b) { return a.empty() ? b : a; } GitFS::Repo::Repo(const PropertyReader & properties) : - repo(Git::RepositoryOpenBare(properties("gitdir"))), - commitish(properties("commitish") / "master"), - isBranch(false), - resolvedAt(0), - gid(properties("gid") / "root"), - uid(properties("uid") / "root") + repo(Git::RepositoryOpenBare(properties("gitdir"))), commitish(properties("commitish") / "master"), isBranch(false), + resolvedAt(0), gid(properties("gid") / "root"), uid(properties("uid") / "root") { if (commitish.length() == GIT_OID_HEXSZ) { commit = Git::CommitLookup(repo, Git::OidParse(commitish)); @@ -31,34 +28,31 @@ void GitFS::Repo::update() { if (!commit || (isBranch && ref && resolvedAt < std::time(nullptr) - 30)) { - commit = Git::CommitLookup(repo, - *git_reference_target(Git::Resolve(ref).get())); + commit = Git::CommitLookup(repo, *git_reference_target(Git::Resolve(ref).get())); resolvedAt = std::time(nullptr); } tree = Git::TreeLookup(repo, *git_commit_tree_id(commit.get())); } void -GitFS::Repo::disconnect(const ::Ice::Current& current) +GitFS::Repo::disconnect(const ::Ice::Current & current) { current.adapter->remove(current.id); } - NetFS::DirectoryPrxPtr -GitFS::Repo::opendir(ReqEnv, ::std::string path, const ::Ice::Current& ice) +GitFS::Repo::opendir(ReqEnv, ::std::string path, const ::Ice::Current & ice) { if (path.empty()) { throw NetFS::SystemError(EINVAL); } - return Ice::uncheckedCast<NetFS::DirectoryPrx>(ice.adapter->addWithUUID( - std::make_shared<Directory>(this, std::move(path)))); + return Ice::uncheckedCast<NetFS::DirectoryPrx>( + ice.adapter->addWithUUID(std::make_shared<Directory>(this, std::move(path)))); } - NetFS::VFS -GitFS::Repo::statfs(ReqEnv, ::std::string path, const ::Ice::Current&) +GitFS::Repo::statfs(ReqEnv, ::std::string path, const ::Ice::Current &) { if (path.empty()) { throw NetFS::SystemError(EINVAL); @@ -67,9 +61,8 @@ GitFS::Repo::statfs(ReqEnv, ::std::string path, const ::Ice::Current&) return {}; } - int -GitFS::Repo::access(ReqEnv, ::std::string path, int mode, const ::Ice::Current&) +GitFS::Repo::access(ReqEnv, ::std::string path, int mode, const ::Ice::Current &) { if (mode & W_OK) { return EACCES; @@ -106,9 +99,8 @@ GitFS::Repo::access(ReqEnv, ::std::string path, int mode, const ::Ice::Current&) } } - NetFS::Attr -GitFS::Repo::getattr(ReqEnv, ::std::string path, const ::Ice::Current&) +GitFS::Repo::getattr(ReqEnv, ::std::string path, const ::Ice::Current &) { if (path.empty()) { throw NetFS::SystemError(EINVAL); @@ -133,9 +125,8 @@ GitFS::Repo::getattr(ReqEnv, ::std::string path, const ::Ice::Current&) return a; } - ::std::string -GitFS::Repo::readlink(ReqEnv, ::std::string path, const ::Ice::Current&) +GitFS::Repo::readlink(ReqEnv, ::std::string path, const ::Ice::Current &) { if (path.empty() || path == "/") { throw NetFS::SystemError(EINVAL); @@ -148,12 +139,11 @@ GitFS::Repo::readlink(ReqEnv, ::std::string path, const ::Ice::Current&) } auto blob = Git::BlobLookup(repo, *git_tree_entry_id(e.get())); auto n = static_cast<const ::std::string::value_type *>(git_blob_rawcontent(blob.get())); - return { n, n + git_blob_rawsize(blob.get()) }; + return {n, n + git_blob_rawsize(blob.get())}; } - NetFS::FilePrxPtr -GitFS::Repo::open(ReqEnv, ::std::string path, int, const ::Ice::Current& ice) +GitFS::Repo::open(ReqEnv, ::std::string path, int, const ::Ice::Current & ice) { if (path.empty()) { throw NetFS::SystemError(EINVAL); @@ -163,92 +153,78 @@ GitFS::Repo::open(ReqEnv, ::std::string path, int, const ::Ice::Current& ice) } update(); - return Ice::uncheckedCast<NetFS::FilePrx>(ice.adapter->addWithUUID( - std::make_shared<Blob>(this, std::move(path)))); + return Ice::uncheckedCast<NetFS::FilePrx>(ice.adapter->addWithUUID(std::make_shared<Blob>(this, std::move(path)))); } - NetFS::FilePrxPtr -GitFS::Repo::create(ReqEnv, ::std::string, int, int, const ::Ice::Current&) +GitFS::Repo::create(ReqEnv, ::std::string, int, int, const ::Ice::Current &) { throw NetFS::SystemError(EROFS); } - void -GitFS::Repo::truncate(ReqEnv, ::std::string, long long int, const ::Ice::Current&) +GitFS::Repo::truncate(ReqEnv, ::std::string, long long int, const ::Ice::Current &) { throw NetFS::SystemError(EROFS); } - void -GitFS::Repo::unlink(ReqEnv, ::std::string, const ::Ice::Current&) +GitFS::Repo::unlink(ReqEnv, ::std::string, const ::Ice::Current &) { throw NetFS::SystemError(EROFS); } - void -GitFS::Repo::mkdir(ReqEnv, ::std::string, int, const ::Ice::Current&) +GitFS::Repo::mkdir(ReqEnv, ::std::string, int, const ::Ice::Current &) { throw NetFS::SystemError(EROFS); } - void -GitFS::Repo::rmdir(ReqEnv, ::std::string, const ::Ice::Current&) +GitFS::Repo::rmdir(ReqEnv, ::std::string, const ::Ice::Current &) { throw NetFS::SystemError(EROFS); } - void -GitFS::Repo::mknod(ReqEnv, ::std::string, int, int, const ::Ice::Current&) +GitFS::Repo::mknod(ReqEnv, ::std::string, int, int, const ::Ice::Current &) { throw NetFS::SystemError(EROFS); } - void -GitFS::Repo::symlink(ReqEnv, ::std::string, ::std::string, const ::Ice::Current&) +GitFS::Repo::symlink(ReqEnv, ::std::string, ::std::string, const ::Ice::Current &) { throw NetFS::SystemError(EROFS); } - void -GitFS::Repo::link(ReqEnv, ::std::string, ::std::string, const ::Ice::Current&) +GitFS::Repo::link(ReqEnv, ::std::string, ::std::string, const ::Ice::Current &) { throw NetFS::SystemError(EROFS); } - void -GitFS::Repo::rename(ReqEnv, ::std::string, ::std::string, const Ice::optional<Ice::Int>, const ::Ice::Current&) +GitFS::Repo::rename(ReqEnv, ::std::string, ::std::string, const Ice::optional<Ice::Int>, const ::Ice::Current &) { throw NetFS::SystemError(EROFS); } - void -GitFS::Repo::chmod(ReqEnv, ::std::string, int, const ::Ice::Current&) +GitFS::Repo::chmod(ReqEnv, ::std::string, int, const ::Ice::Current &) { throw NetFS::SystemError(EROFS); } - void -GitFS::Repo::chown(ReqEnv, ::std::string, int, int, const ::Ice::Current&) +GitFS::Repo::chown(ReqEnv, ::std::string, int, int, const ::Ice::Current &) { throw NetFS::SystemError(EROFS); } - void -GitFS::Repo::utimens(ReqEnv, ::std::string, long long int, long long int, long long int, long long int, const ::Ice::Current&) +GitFS::Repo::utimens( + ReqEnv, ::std::string, long long int, long long int, long long int, long long int, const ::Ice::Current &) { throw NetFS::SystemError(EROFS); } - - @@ -1,53 +1,53 @@ #ifndef GITFS_REPO_H #define GITFS_REPO_H +#include "git.h" #include <Ice/Properties.h> #include <volume.h> -#include "git.h" namespace GitFS { using namespace NetFS; using PropertyReader = std::function<std::string(const std::string_view &)>; class Repo : public Volume { - public: - Repo(const PropertyReader &); - - void disconnect(const ::Ice::Current& current) override; - DirectoryPrxPtr opendir(ReqEnv env, ::std::string path, const ::Ice::Current& current) override; - VFS statfs(ReqEnv env, ::std::string path, const ::Ice::Current& current) override; - int access(ReqEnv env, ::std::string path, int mode, const ::Ice::Current& current) override; - Attr getattr(ReqEnv env, ::std::string path, const ::Ice::Current& current) override; - ::std::string readlink(ReqEnv env, ::std::string path, const ::Ice::Current& current) override; - FilePrxPtr open(ReqEnv env, ::std::string path, int flags, const ::Ice::Current& current) override; - FilePrxPtr create(ReqEnv env, ::std::string path, int flags, int mode, const ::Ice::Current& current) override; - void truncate(ReqEnv env, ::std::string path, long long int size, const ::Ice::Current& current) override; - void unlink(ReqEnv env, ::std::string path, const ::Ice::Current& current) override; - void mkdir(ReqEnv env, ::std::string path, int mode, const ::Ice::Current& current) override; - void rmdir(ReqEnv env, ::std::string path, const ::Ice::Current& current) override; - void mknod(ReqEnv env, ::std::string path, int mode, int dev, const ::Ice::Current& current) override; - void symlink(ReqEnv env, ::std::string path1, ::std::string path2, const ::Ice::Current& current) override; - void link(ReqEnv env, ::std::string path1, ::std::string path2, const ::Ice::Current& current) override; - void rename(ReqEnv env, ::std::string from, ::std::string to, const Ice::optional<Ice::Int>, const ::Ice::Current& current) override; - void chmod(ReqEnv env, ::std::string path, int mode, const ::Ice::Current& current) override; - void chown(ReqEnv env, ::std::string path, int uid, int gid, const ::Ice::Current& current) override; - void utimens(ReqEnv env, ::std::string path, long long int atime, long long int atimens, long long int mtime, long long int mtimens, const ::Ice::Current& current) override; - - private: - void update(); - - friend class Directory; - friend class Blob; - const Git::RepositoryPtr repo; - const std::string commitish; - Git::RefPtr ref; - bool isBranch; - std::time_t resolvedAt; - Git::CommitPtr commit; - Git::TreePtr tree; - const std::string gid, uid; + public: + Repo(const PropertyReader &); + + void disconnect(const ::Ice::Current & current) override; + DirectoryPrxPtr opendir(ReqEnv env, ::std::string path, const ::Ice::Current & current) override; + VFS statfs(ReqEnv env, ::std::string path, const ::Ice::Current & current) override; + int access(ReqEnv env, ::std::string path, int mode, const ::Ice::Current & current) override; + Attr getattr(ReqEnv env, ::std::string path, const ::Ice::Current & current) override; + ::std::string readlink(ReqEnv env, ::std::string path, const ::Ice::Current & current) override; + FilePrxPtr open(ReqEnv env, ::std::string path, int flags, const ::Ice::Current & current) override; + FilePrxPtr create(ReqEnv env, ::std::string path, int flags, int mode, const ::Ice::Current & current) override; + void truncate(ReqEnv env, ::std::string path, long long int size, const ::Ice::Current & current) override; + void unlink(ReqEnv env, ::std::string path, const ::Ice::Current & current) override; + void mkdir(ReqEnv env, ::std::string path, int mode, const ::Ice::Current & current) override; + void rmdir(ReqEnv env, ::std::string path, const ::Ice::Current & current) override; + void mknod(ReqEnv env, ::std::string path, int mode, int dev, const ::Ice::Current & current) override; + void symlink(ReqEnv env, ::std::string path1, ::std::string path2, const ::Ice::Current & current) override; + void link(ReqEnv env, ::std::string path1, ::std::string path2, const ::Ice::Current & current) override; + void rename(ReqEnv env, ::std::string from, ::std::string to, const Ice::optional<Ice::Int>, + const ::Ice::Current & current) override; + void chmod(ReqEnv env, ::std::string path, int mode, const ::Ice::Current & current) override; + void chown(ReqEnv env, ::std::string path, int uid, int gid, const ::Ice::Current & current) override; + void utimens(ReqEnv env, ::std::string path, long long int atime, long long int atimens, long long int mtime, + long long int mtimens, const ::Ice::Current & current) override; + + private: + void update(); + + friend class Directory; + friend class Blob; + const Git::RepositoryPtr repo; + const std::string commitish; + Git::RefPtr ref; + bool isBranch; + std::time_t resolvedAt; + Git::CommitPtr commit; + Git::TreePtr tree; + const std::string gid, uid; }; } #endif - - diff --git a/src/repoList.cpp b/src/repoList.cpp index 4eb76af..e3dbb0c 100644 --- a/src/repoList.cpp +++ b/src/repoList.cpp @@ -1,28 +1,24 @@ -#include <Ice/ObjectAdapter.h> -#include <Ice/Properties.h> #include "repoList.h" #include "repo.h" +#include <Ice/ObjectAdapter.h> +#include <Ice/Properties.h> #include <compileTimeFormatter.h> -GitFS::RepoList::RepoList(Ice::PropertiesPtr && p) : - properties(std::move(p)) -{ -} +GitFS::RepoList::RepoList(Ice::PropertiesPtr && p) : properties(std::move(p)) { } AdHocFormatter(RepoPropertyName, "GitFS.%?.%?"); NetFS::VolumePrxPtr -GitFS::RepoList::connect(const ::std::string volume, const ::std::string auth, - const ::Ice::Current & ice) +GitFS::RepoList::connect(const ::std::string volume, const ::std::string auth, const ::Ice::Current & ice) { if (volume.empty()) { throw NetFS::ConfigError(); } const auto propReader = std::bind(&Ice::Properties::getProperty, properties, - std::bind((std::string(*)(const std::string_view &, const std::string_view &)) - (&RepoPropertyName::get), volume, std::placeholders::_1)); + std::bind((std::string(*)(const std::string_view &, const std::string_view &))(&RepoPropertyName::get), + volume, std::placeholders::_1)); if (propReader("gitdir").empty()) { throw NetFS::ConfigError(); @@ -30,7 +26,5 @@ GitFS::RepoList::connect(const ::std::string volume, const ::std::string auth, if (propReader("authkey") != auth) { throw NetFS::AuthError(); } - return Ice::uncheckedCast<NetFS::VolumePrx>( - ice.adapter->addWithUUID(std::make_shared<Repo>(propReader))); + return Ice::uncheckedCast<NetFS::VolumePrx>(ice.adapter->addWithUUID(std::make_shared<Repo>(propReader))); } - diff --git a/src/repoList.h b/src/repoList.h index 0c2ed4b..2e876c2 100644 --- a/src/repoList.h +++ b/src/repoList.h @@ -1,20 +1,20 @@ #ifndef GITFS_REPOLIST_H #define GITFS_REPOLIST_H -#include <service.h> #include <Ice/Properties.h> +#include <service.h> namespace GitFS { class RepoList : public NetFS::Service { - public: - RepoList(Ice::PropertiesPtr &&); + public: + RepoList(Ice::PropertiesPtr &&); - NetFS::VolumePrxPtr connect(const ::std::string volume, const ::std::string auth, const ::Ice::Current& current) override; + NetFS::VolumePrxPtr connect( + const ::std::string volume, const ::std::string auth, const ::Ice::Current & current) override; - private: - const Ice::PropertiesPtr properties; + private: + const Ice::PropertiesPtr properties; }; } #endif - |