diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-07-21 13:54:41 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-07-21 13:54:41 +0100 |
commit | 67684b3a9a7205cef15f5978b5adc4df632f5af5 (patch) | |
tree | 630a28d313047bf6440b0c349047c6c8de0cb298 /src/git.cpp | |
parent | Add a test symlink (diff) | |
download | netfs-gitfs-67684b3a9a7205cef15f5978b5adc4df632f5af5.tar.bz2 netfs-gitfs-67684b3a9a7205cef15f5978b5adc4df632f5af5.tar.xz netfs-gitfs-67684b3a9a7205cef15f5978b5adc4df632f5af5.zip |
Basically all the core functionality
Diffstat (limited to 'src/git.cpp')
-rw-r--r-- | src/git.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/git.cpp b/src/git.cpp index 084e6ca..850b8b3 100644 --- a/src/git.cpp +++ b/src/git.cpp @@ -1,6 +1,8 @@ #include "git.h" #include <execinfo.h> #include <exceptions.h> +#include <types.h> +#include <sys/stat.h> namespace GitFS { namespace Git { @@ -14,6 +16,45 @@ namespace GitFS { #endif throw Error { err, e->klass, e->message }; } + + [[noreturn]] void ErrorToSystemError(const Error & e) + { + if (e.err == GIT_ENOTFOUND) { + throw NetFS::SystemError(ENOENT); + } + throw NetFS::SystemError(EIO); + } + + } +} + +namespace NetFS { + Attr & operator<<(Attr & a, const git_tree_entry & e) + { + a.mode = git_tree_entry_filemode(&e); + if (S_ISDIR(a.mode)) { + a.mode |= S_IXUSR | S_IXGRP | S_IXOTH | S_IRUSR | S_IRGRP | S_IROTH; + } + else if (S_ISLNK(a.mode)) { + a.mode |= S_IRUSR | S_IRGRP | S_IROTH; + } + else { + a.mode ^= S_IWUSR; + } + return a; + } + + 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) + { + a.blockSize = 1; + a.blocks = a.size = git_blob_rawsize(&b); + return a; } } |