forked from QuantStack/git2cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex_wrapper.cpp
More file actions
35 lines (29 loc) · 779 Bytes
/
index_wrapper.cpp
File metadata and controls
35 lines (29 loc) · 779 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
#include "index_wrapper.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;
throwIfError(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};
throwIfError(git_index_add_all(*this, array, 0, NULL, NULL));
throwIfError(git_index_write(*this));
}