Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.

Commit cd84dc1

Browse files
committed
Updated remote API
1 parent 92367f6 commit cd84dc1

File tree

3 files changed

+43
-8
lines changed

3 files changed

+43
-8
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,14 +1252,14 @@ The project is available under the [MIT](https://opensource.org/licenses/MIT) li
12521252
| `git_remote_get_fetch_refspecs` | `remote::fetch_refspec` |
12531253
| `git_remote_get_push_refspecs` | `remote::push_refspec` |
12541254
| `git_remote_get_refspec` | `remote::operator[]` |
1255-
| `git_remote_init_callbacks` | |
1255+
| `git_remote_init_callbacks` | `remote::callbacks::callbacks` |
12561256
| `git_remote_is_valid_name` | `remote::is_valid_name` |
12571257
| `git_remote_list` | `repository::remote_list` |
12581258
| `git_remote_lookup` | `repository::lookup_remote` |
1259-
| `git_remote_ls` | **Not Implemented** |
1259+
| `git_remote_ls` | `remote::reference_advertisement_list` |
12601260
| `git_remote_name` | `remote::name` |
12611261
| `git_remote_owner` | `remote::owner` |
1262-
| `git_remote_prune` | **Not Implemented** |
1262+
| `git_remote_prune` | `remote::prune` |
12631263
| `git_remote_prune_refs` | `remote::prune_references` |
12641264
| `git_remote_push` | `remote::push` |
12651265
| `git_remote_pushurl` | `remote::push_url` |
@@ -1270,7 +1270,7 @@ The project is available under the [MIT](https://opensource.org/licenses/MIT) li
12701270
| `git_remote_set_url` | `repository::set_remote_url` |
12711271
| `git_remote_stats` | `remote::stats` |
12721272
| `git_remote_stop` | `remote::stop` |
1273-
| `git_remote_update_tips` | |
1273+
| `git_remote_update_tips` | `remote::update_tips` |
12741274
| `git_remote_upload` | `remote::upload` |
12751275
| `git_remote_url` | `remote::url` |
12761276

include/cppgit2/remote.hpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,26 +183,32 @@ class remote : public libgit2_api {
183183
git_remote_head c_struct_;
184184
};
185185

186-
// Get the remote's list of push refspecs
187-
// The memory is owned by the user and should be freed
188-
strarray push_refspec() const;
189-
190186
// Ensure the remote name is well-formed.
191187
static bool is_valid_name(const std::string &name);
192188

189+
// Get the remote repository's reference advertisement list
190+
std::vector<head> reference_advertisement_list();
191+
193192
// Get the remote's name
194193
std::string name() const;
195194

196195
// Get the remote's repository
197196
class repository owner() const;
198197

198+
// Prune tracking refs that are no longer present on remote
199+
void prune(const callbacks &remote_callbacks = callbacks());
200+
199201
// Retrieve the ref-prune setting
200202
void prune_references();
201203

202204
// Peform all the steps from a push.
203205
void push(const strarray &refspecs,
204206
const push::options &options = push::options());
205207

208+
// Get the remote's list of push refspecs
209+
// The memory is owned by the user and should be freed
210+
strarray push_refspec() const;
211+
206212
// Get the remote's url for pushing
207213
// If url.*.pushInsteadOf has been configured for this URL,
208214
// it will return the modified URL.
@@ -222,6 +228,10 @@ class remote : public libgit2_api {
222228
// whether the operation has been cancelled and if so stops the operation.
223229
void stop();
224230

231+
// Update the tips to the new state
232+
void update_tips(const callbacks &remote_callbacks, bool update_fetchhead,
233+
fetch::options::autotag download_tags, const std::string &reflog_message);
234+
225235
// Create a packfile and send it to the server
226236
//
227237
// Connect to the remote if it hasn't been done yet,

src/remote.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@ bool remote::is_valid_name(const std::string &name) {
9999
return git_remote_is_valid_name(name.c_str());
100100
}
101101

102+
std::vector<remote::head> remote::reference_advertisement_list() {
103+
const git_remote_head * head_ptr = nullptr;
104+
const git_remote_head ** head_ptr_ptr = &head_ptr;
105+
size_t size = 0;
106+
if (git_remote_ls(&head_ptr_ptr, &size, c_ptr_))
107+
throw git_exception();
108+
109+
std::vector<head> result;
110+
for (size_t i = 0; i < size; ++i)
111+
result.push_back(head(&head_ptr[i]));
112+
return result;
113+
}
114+
102115
std::string remote::name() const {
103116
auto ret = git_remote_name(c_ptr_);
104117
return ret ? std::string(ret) : "";
@@ -108,6 +121,11 @@ repository remote::owner() const {
108121
return repository(git_remote_owner(c_ptr_));
109122
}
110123

124+
void remote::prune(const callbacks &remote_callbacks) {
125+
if (git_remote_prune(c_ptr_, remote_callbacks.c_ptr()))
126+
throw git_exception();
127+
}
128+
111129
void remote::prune_references() {
112130
if (git_remote_prune_refs(c_ptr_))
113131
throw git_exception();
@@ -138,6 +156,13 @@ void remote::stop() {
138156
throw git_exception();
139157
}
140158

159+
void remote::update_tips(const callbacks &remote_callbacks, bool update_fetchhead,
160+
fetch::options::autotag download_tags, const std::string &reflog_message) {
161+
if (git_remote_update_tips(c_ptr_, remote_callbacks.c_ptr(), update_fetchhead,
162+
static_cast<git_remote_autotag_option_t>(download_tags), reflog_message.c_str()))
163+
throw git_exception();
164+
}
165+
141166
void remote::upload(const strarray &refspecs, const push::options &options) {
142167
if (git_remote_upload(c_ptr_, refspecs.c_ptr(), options.c_ptr()))
143168
throw git_exception();

0 commit comments

Comments
 (0)