-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathrevwalker.cpp
More file actions
70 lines (60 loc) · 1.63 KB
/
Copy pathrevwalker.cpp
File metadata and controls
70 lines (60 loc) · 1.63 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
#include "git2cpp/revwalker.h"
#include "git2cpp/error.h"
#include "git2cpp/repo.h"
#include <git2/revwalk.h>
namespace git
{
namespace revwalker
{
namespace sorting
{
const type none(GIT_SORT_NONE);
const type topological(GIT_SORT_TOPOLOGICAL);
const type time(GIT_SORT_TIME);
const type reverse(GIT_SORT_REVERSE);
}
}
void RevWalker::Destroy::operator()(git_revwalk* walker) const
{
git_revwalk_free(walker);
}
void RevWalker::sort(revwalker::sorting::type s)
{
git_revwalk_sorting(walker_.get(), s.value());
}
void RevWalker::simplify_first_parent()
{
git_revwalk_simplify_first_parent(walker_.get());
}
void RevWalker::push_head() const
{
if (git_revwalk_push_head(walker_.get()))
throw invalid_head_error();
}
void RevWalker::hide(git_oid const & obj) const
{
if (git_revwalk_hide(walker_.get(), &obj))
throw non_commit_object_error(obj);
}
void RevWalker::push(git_oid const & obj) const
{
if (git_revwalk_push(walker_.get(), &obj))
throw non_commit_object_error(obj);
}
Commit RevWalker::next() const
{
git_oid oid;
if (git_revwalk_next(&oid, walker_.get()) == 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_.get()) == 0);
if (valid)
git_oid_fmt(id_buffer, &oid);
return valid;
}
}