-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrebase_wrapper.cpp
More file actions
82 lines (70 loc) · 1.88 KB
/
rebase_wrapper.cpp
File metadata and controls
82 lines (70 loc) · 1.88 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
78
79
80
81
82
#include "rebase_wrapper.hpp"
#include <iostream>
#include "../utils/git_exception.hpp"
rebase_wrapper::~rebase_wrapper()
{
git_rebase_free(p_resource);
p_resource = nullptr;
}
bool rebase_wrapper::next_operation()
{
int res = git_rebase_next(&p_operation, p_resource);
return res == 0;
}
git_oid rebase_wrapper::current_operation_id() const
{
return p_operation->id;
}
std::size_t rebase_wrapper::current_operation_index() const
{
return git_rebase_operation_current(p_resource);
}
std::size_t rebase_wrapper::operation_entry_count() const
{
return git_rebase_operation_entrycount(p_resource);
}
int rebase_wrapper::commit(const signature_wrapper& author, const signature_wrapper& committer)
{
git_oid new_commit_oid;
int res = git_rebase_commit(
&new_commit_oid,
p_resource,
author,
committer,
nullptr, // message encoding (NULL for default)
nullptr
); // message (NULL to use original)
return res;
}
void rebase_wrapper::finish(const signature_wrapper& committer)
{
throw_if_error(git_rebase_finish(p_resource, committer));
p_resource = nullptr;
}
void rebase_wrapper::abort()
{
throw_if_error(git_rebase_abort(p_resource));
}
rebase_wrapper rebase_wrapper::init(
repository_wrapper& repo,
const annotated_commit_wrapper& branch,
const annotated_commit_wrapper& upstream,
const annotated_commit_wrapper* onto,
const git_rebase_options& opts
)
{
rebase_wrapper wp;
const git_annotated_commit* raw_onto = nullptr;
if (onto)
{
raw_onto = *onto;
}
throw_if_error(git_rebase_init(&(wp.p_resource), repo, branch, upstream, raw_onto, &opts));
return wp;
}
rebase_wrapper rebase_wrapper::open(repository_wrapper& repo, const git_rebase_options& opts)
{
rebase_wrapper wp;
throw_if_error(git_rebase_open(&(wp.p_resource), repo, &opts));
return wp;
}