forked from AndreyG/libgit2cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrevwalker.cpp
More file actions
94 lines (78 loc) · 2.07 KB
/
Copy pathrevwalker.cpp
File metadata and controls
94 lines (78 loc) · 2.07 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "git2cpp/error.h"
#include "git2cpp/revwalker.h"
#include "git2cpp/repo.h"
namespace git
{
RevWalker::RevWalker(Repository const & repo)
: repo_(repo)
{
if (git_revwalk_new(&walker_, repo.ptr()))
throw revwalk_new_error();
}
RevWalker::~RevWalker()
{
git_revwalk_free(walker_);
}
namespace
{
unsigned int raw(RevWalker::sorting s)
{
return static_cast<unsigned int>(s);
}
}
RevWalker::sorting operator ~ (RevWalker::sorting s)
{
return RevWalker::sorting(~raw(s));
}
RevWalker::sorting operator | (RevWalker::sorting a, RevWalker::sorting b)
{
return RevWalker::sorting(raw(a) | raw(b));
}
RevWalker::sorting operator ^ (RevWalker::sorting a, RevWalker::sorting b)
{
return RevWalker::sorting(raw(a) ^ raw(b));
}
RevWalker::sorting operator & (RevWalker::sorting a, RevWalker::sorting b)
{
return RevWalker::sorting(raw(a) & raw(b));
}
void RevWalker::sort(sorting s)
{
git_revwalk_sorting(walker_, raw(s));
}
void RevWalker::simplify_first_parent()
{
git_revwalk_simplify_first_parent(walker_);
}
void RevWalker::push_head() const
{
if (git_revwalk_push_head(walker_))
throw invalid_head_error();
}
void RevWalker::hide(git_oid const & obj) const
{
if (git_revwalk_hide(walker_, &obj))
throw non_commit_object_error(obj);
}
void RevWalker::push(git_oid const & obj) const
{
if (git_revwalk_push(walker_, &obj))
throw non_commit_object_error(obj);
}
Commit RevWalker::next() const
{
git_oid oid;
if (git_revwalk_next(&oid, walker_) == 0)
return repo_.commit_lookup(oid);
else
return Commit();
}
bool RevWalker::next(char * id_buffer) const
{
git_oid oid;
bool valid = (git_revwalk_next(&oid, walker_) == 0);
if (valid)
git_oid_fmt(id_buffer, &oid);
return valid;
}
}