forked from AndreyG/libgit2cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff_list.cpp
More file actions
78 lines (67 loc) · 2.24 KB
/
Copy pathdiff_list.cpp
File metadata and controls
78 lines (67 loc) · 2.24 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
#include <cassert>
#include "git2cpp/diff_list.h"
#include "git2cpp/tree.h"
namespace git
{
DiffList diff (git_repository * repo
, Tree & a, Tree & b
, git_diff_options const & opts
)
{
git_diff_list * diff_list;
auto op_res = git_diff_tree_to_tree(&diff_list, repo, a.ptr(), b.ptr(), &opts);
assert(op_res == 0);
return DiffList(diff_list);
}
DiffList diff_to_index ( git_repository * repo
, Tree & t
, git_diff_options const & opts
)
{
git_diff_list * diff_list;
auto op_res = git_diff_tree_to_index(&diff_list, repo, t.ptr(), nullptr, &opts);
assert(op_res == 0);
return DiffList(diff_list);
}
DiffList diff_index_to_workdir(git_repository * repo, git_diff_options const & opts)
{
git_diff_list * diff_list;
auto op_res = git_diff_index_to_workdir(&diff_list, repo, nullptr, &opts);
assert(op_res == 0);
return DiffList(diff_list);
}
namespace
{
int apply_callback ( git_diff_delta const * delta
, git_diff_range const * range
, char usage
, const char * line
, size_t line_len
, void * payload )
{
auto cb = reinterpret_cast<DiffList::data_callback_t *>(payload);
return (*cb)(delta, range, usage, line, line_len);
}
}
void DiffList::print_patch(data_callback_t cb) const
{
git_diff_print_patch(diff_list_, &apply_callback, &cb);
}
void DiffList::print_compact(data_callback_t cb) const
{
git_diff_print_compact(diff_list_, &apply_callback, &cb);
}
void DiffList::print_raw(data_callback_t cb) const
{
git_diff_print_raw(diff_list_, &apply_callback, &cb);
}
DiffList& DiffList::merge(DiffList const & other)
{
git_diff_merge(diff_list_, other.diff_list_);
return *this;
}
size_t DiffList::deltas_num() const
{
return git_diff_num_deltas(diff_list_);
}
}