summaryrefslogtreecommitdiff
path: root/src/git.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/git.cpp')
-rw-r--r--src/git.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/git.cpp b/src/git.cpp
new file mode 100644
index 0000000..084e6ca
--- /dev/null
+++ b/src/git.cpp
@@ -0,0 +1,30 @@
+#include "git.h"
+#include <execinfo.h>
+#include <exceptions.h>
+
+namespace GitFS {
+ namespace Git {
+ void
+ throwError(int err)
+ {
+#if LIBGIT2_VER_MINOR >= 28
+ const git_error * e = git_error_last();
+#else
+ const git_error * e = giterr_last();
+#endif
+ throw Error { err, e->klass, e->message };
+ }
+ }
+}
+
+namespace std {
+ std::ostream &
+ operator<<(std::ostream & s, const git_oid & oid)
+ {
+ char str[GIT_OID_HEXSZ + 1];
+ git_oid_tostr(str, sizeof(str), &oid);
+ s.write(str, GIT_OID_HEXSZ);
+ return s;
+ }
+}
+