diff options
Diffstat (limited to 'src/repo.cpp')
-rw-r--r-- | src/repo.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/repo.cpp b/src/repo.cpp index 6bf442f..db21e61 100644 --- a/src/repo.cpp +++ b/src/repo.cpp @@ -120,16 +120,31 @@ GitFS::Repo::getattr(ReqEnv, const ::std::string path, const ::Ice::Current &) throw NetFS::SystemError(EINVAL); } - NetFS::Attr attr {}; + update(); if (path == "/") { + NetFS::Attr attr = getattr(nullptr, nullptr); attr.mode = S_IFDIR | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; + return attr; } - else { - update(); - auto entry = Git::treeEntryByPath(tree, path); + return getattr(Git::treeEntryByPath(tree, path).get()); +} + +NetFS::Attr +GitFS::Repo::getattr(const git_tree_entry * entry) const +{ + if (S_ISREG(git_tree_entry_filemode(entry))) { + return getattr(entry, Git::blobLookup(repo, *git_tree_entry_id(entry)).get()); + } + return getattr(entry, nullptr); +} + +NetFS::Attr +GitFS::Repo::getattr(const git_tree_entry * entry, const git_blob * blob) const +{ + NetFS::Attr attr {}; + if (entry) { attr << *entry; - if (S_ISREG(git_tree_entry_filemode(entry.get()))) { - auto blob = Git::blobLookup(repo, *git_tree_entry_id(entry.get())); + if (blob) { attr << *blob; } } |