summaryrefslogtreecommitdiff
path: root/src/repo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/repo.cpp')
-rw-r--r--src/repo.cpp53
1 files changed, 20 insertions, 33 deletions
diff --git a/src/repo.cpp b/src/repo.cpp
index 0db5b23..32fa401 100644
--- a/src/repo.cpp
+++ b/src/repo.cpp
@@ -58,11 +58,8 @@ GitFS::Repo::access(ReqEnv, ::std::string path, int mode, const ::Ice::Current&)
return 0;
}
- catch (const Git::Error & e) {
- if (e.err == GIT_ENOTFOUND) {
- return ENOENT;
- }
- Git::ErrorToSystemError(e);
+ catch (const NetFS::SystemError & e) {
+ return e.syserrno;
}
}
@@ -72,26 +69,21 @@ GitFS::Repo::getattr(ReqEnv, ::std::string path, const ::Ice::Current&)
{
if (path.empty()) throw NetFS::SystemError(EINVAL);
- try {
- NetFS::Attr a {};
- if (path == "/") {
- a.mode = S_IFDIR | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
- }
- else {
- auto entry = Git::TreeEntryByPath(tree, path);
- a << *entry;
- if (S_ISREG(git_tree_entry_filemode(entry.get()))) {
- auto blob = Git::BlobLookup(repo, *git_tree_entry_id(entry.get()));
- a << *blob;
- }
- }
- a << *commit;
- a.gid = a.uid = "root";
- return a;
+ NetFS::Attr a {};
+ if (path == "/") {
+ a.mode = S_IFDIR | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
}
- catch (const Git::Error & e) {
- Git::ErrorToSystemError(e);
+ else {
+ auto entry = Git::TreeEntryByPath(tree, path);
+ a << *entry;
+ if (S_ISREG(git_tree_entry_filemode(entry.get()))) {
+ auto blob = Git::BlobLookup(repo, *git_tree_entry_id(entry.get()));
+ a << *blob;
+ }
}
+ a << *commit;
+ a.gid = a.uid = "root";
+ return a;
}
@@ -100,16 +92,11 @@ GitFS::Repo::readlink(ReqEnv, ::std::string path, const ::Ice::Current&)
{
if (path.empty() || path == "/") throw NetFS::SystemError(EINVAL);
- try {
- auto e = Git::TreeEntryByPath(tree, path);
- if (!S_ISLNK(git_tree_entry_filemode(e.get()))) throw NetFS::SystemError(EINVAL);
- 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()) };
- }
- catch (const Git::Error & e) {
- Git::ErrorToSystemError(e);
- }
+ auto e = Git::TreeEntryByPath(tree, path);
+ if (!S_ISLNK(git_tree_entry_filemode(e.get()))) throw NetFS::SystemError(EINVAL);
+ 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()) };
}