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/repo.cpp | |
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/repo.cpp')
-rw-r--r-- | src/repo.cpp | 86 |
1 files changed, 31 insertions, 55 deletions
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); } - - |