-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex_wrapper.cpp
More file actions
48 lines (40 loc) · 1.01 KB
/
index_wrapper.cpp
File metadata and controls
48 lines (40 loc) · 1.01 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
#include "index_wrapper.hpp"
#include "../utils/common.hpp"
#include "../utils/git_exception.hpp"
#include "../wrapper/repository_wrapper.hpp"
#include <vector>
index_wrapper::~index_wrapper()
{
git_index_free(p_resource);
p_resource=nullptr;
}
index_wrapper index_wrapper::init(repository_wrapper& rw)
{
index_wrapper index;
throw_if_error(git_repository_index(&(index.p_resource), rw));
return index;
}
void index_wrapper::add_entries(std::vector<std::string> patterns)
{
add_impl(std::move(patterns));
}
void index_wrapper::add_all()
{
add_impl({{"."}});
}
void index_wrapper::add_impl(std::vector<std::string> patterns)
{
git_strarray_wrapper array{patterns};
throw_if_error(git_index_add_all(*this, array, 0, NULL, NULL));
// throw_if_error(git_index_write(*this));
}
void index_wrapper::write()
{
throw_if_error(git_index_write(*this));
}
git_oid index_wrapper::write_tree()
{
git_oid tree_id;
throw_if_error(git_index_write_tree(&tree_id, *this));
return tree_id;
}