-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpatch_wrapper.cpp
More file actions
43 lines (38 loc) · 893 Bytes
/
patch_wrapper.cpp
File metadata and controls
43 lines (38 loc) · 893 Bytes
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
#include "../wrapper/patch_wrapper.hpp"
#include "../utils/git_exception.hpp"
patch_wrapper::patch_wrapper(git_patch* patch)
: base_type(patch)
{
}
patch_wrapper::~patch_wrapper()
{
git_patch_free(p_resource);
p_resource = nullptr;
}
git_buf patch_wrapper::to_buf()
{
git_buf buf = GIT_BUF_INIT;
throw_if_error(git_patch_to_buf(&buf, *this));
return buf;
}
patch_wrapper patch_wrapper::patch_from_files(
const std::string& path1,
const std::string& file1_str,
const std::string& path2,
const std::string& file2_str,
git_diff_options* diffopts
)
{
git_patch* patch;
throw_if_error(git_patch_from_buffers(
&patch,
file1_str.c_str(),
file1_str.length(),
path1.c_str(),
file2_str.c_str(),
file2_str.length(),
path2.c_str(),
diffopts
));
return patch_wrapper(patch);
}