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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#ifndef GENTOOBROWSE_API_SERVICE_MAINTENANCE_GIT_H
#define GENTOOBROWSE_API_SERVICE_MAINTENANCE_GIT_H
#include <memory>
#include <git2.h>
#include <ostream>
namespace Gentoo {
namespace Utils {
namespace Git {
void throwError(void * const func, int err);
template<typename ... P, typename ... A>
void
gitSafe(int (*func)(P...), A ... p)
{
if (int _giterror = func(p...) < 0) {
throwError((void * const)func, _giterror);
}
}
template<typename T>
using GitTPtr = std::unique_ptr<T, void(*)(T*)>;
template<typename R, typename ... P, typename ... A>
GitTPtr<R>
gitSafeGet(int(*get)(R**, P...), void(*release)(R*), A ... p)
{
R * r = nullptr;
gitSafe(get, &r, p...);
return GitTPtr<R>(r, release);
}
template<typename R, typename ... P, typename ... A>
R
gitSafeGet(int(*get)(R*, P...), A ... p)
{
R r;
gitSafe(get, &r, p...);
return r;
}
std::string operator*(const git_oid &);
using GitAnnotatedCommitPtr = GitTPtr<git_annotated_commit>;
GitAnnotatedCommitPtr
gitFetch(git_repository * repo, git_remote * remote, const char * branch);
git_oid
gitFastForward(git_repository * repo, const git_annotated_commit * fetch_head);
void
updateRepository(const std::string & path, const std::string & upstream, const std::string & branch);
}
}
}
namespace std {
std::ostream & operator<<(std::ostream &, const git_oid &);
}
#endif
|