summaryrefslogtreecommitdiff
path: root/src/git.cpp
blob: 084e6ca1ca2ca1b1ffba3f9f4b4a4d3dfbf5f0b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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;
	}
}