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

Commit 37b7f96

Browse files
committed
Minor updates
1 parent 4b7f882 commit 37b7f96

File tree

4 files changed

+54
-16
lines changed

4 files changed

+54
-16
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,8 +1233,8 @@ The project is available under the [MIT](https://opensource.org/licenses/MIT) li
12331233
| --- | --- |
12341234
| `git_remote_add_fetch` | `repository::add_fetch_refspec_to_remote` |
12351235
| `git_remote_add_push` | `repository::add_push_refspec_to_remote` |
1236-
| `git_remote_autotag` | |
1237-
| `git_remote_connect` | |
1236+
| `git_remote_autotag` | **Not Implemented** |
1237+
| `git_remote_connect` | **Not Implemented** |
12381238
| `git_remote_connected` | `remote::is_connected` |
12391239
| `git_remote_create` | `repository::create_remote` |
12401240
| `git_remote_create_anonymous` | `repository::create_anonymous_remote` |
@@ -1256,10 +1256,10 @@ The project is available under the [MIT](https://opensource.org/licenses/MIT) li
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` | |
1259+
| `git_remote_ls` | **Not Implemented** |
12601260
| `git_remote_name` | `remote::name` |
12611261
| `git_remote_owner` | `remote::owner` |
1262-
| `git_remote_prune` | |
1262+
| `git_remote_prune` | **Not Implemented** |
12631263
| `git_remote_prune_refs` | `remote::prune_references` |
12641264
| `git_remote_push` | `remote::push` |
12651265
| `git_remote_pushurl` | `remote::push_url` |

include/cppgit2/odb.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@ class odb : public libgit2_api {
5050
void add_alternate_backend(const backend &backend, int priority);
5151

5252
// Add a custom backend to an existing Object DB
53-
// The backends are checked in relative ordering, based on the value of the priority parameter.
53+
// The backends are checked in relative ordering, based on the value of the
54+
// priority parameter.
5455
void add_backend(const backend &backend, int priority);
5556

5657
// Add an on-disk alternate to an existing Object DB.
57-
// Note that the added path must point to an objects, not to a full repository, to use it as an alternate store.
58-
// Alternate backends are always checked for objects after all the main backends have been exhausted.
58+
// Note that the added path must point to an objects, not to a full
59+
// repository, to use it as an alternate store. Alternate backends are always
60+
// checked for objects after all the main backends have been exhausted.
5961
// Writing is disabled on alternate backends.
6062
void add_disk_alternate_backend(const std::string &path);
6163

include/cppgit2/remote.hpp

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class remote : public libgit2_api {
4242
class create_options : public libgit2_api {
4343
public:
4444
create_options() : c_ptr_(nullptr) {
45-
auto ret =
46-
git_remote_create_init_options(&default_options_, GIT_REMOTE_CREATE_OPTIONS_VERSION);
45+
auto ret = git_remote_create_init_options(
46+
&default_options_, GIT_REMOTE_CREATE_OPTIONS_VERSION);
4747
c_ptr_ = &default_options_;
4848
if (ret != 0)
4949
throw git_exception();
@@ -60,15 +60,23 @@ class remote : public libgit2_api {
6060
void set_repository(const class repository &repo);
6161

6262
// Name
63-
std::string name() const { return c_ptr_->name ? std::string(c_ptr_->name) : ""; }
63+
std::string name() const {
64+
return c_ptr_->name ? std::string(c_ptr_->name) : "";
65+
}
6466
void set_name(const std::string &name) { c_ptr_->name = name.c_str(); }
6567

6668
// Fetchspec
67-
std::string fetchspec() const { return c_ptr_->fetchspec ? std::string(c_ptr_->fetchspec) : ""; }
68-
void set_fetchspec(const std::string &fetchspec) { c_ptr_->fetchspec = fetchspec.c_str(); }
69+
std::string fetchspec() const {
70+
return c_ptr_->fetchspec ? std::string(c_ptr_->fetchspec) : "";
71+
}
72+
void set_fetchspec(const std::string &fetchspec) {
73+
c_ptr_->fetchspec = fetchspec.c_str();
74+
}
6975

7076
// Flags
71-
create_flag flags() const { return static_cast<create_flag>(c_ptr_->flags); }
77+
create_flag flags() const {
78+
return static_cast<create_flag>(c_ptr_->flags);
79+
}
7280
void set_flags(const create_flag &flags) {
7381
c_ptr_->flags = static_cast<unsigned int>(flags);
7482
}
@@ -96,8 +104,8 @@ class remote : public libgit2_api {
96104

97105
// Create a remote, with options.
98106
// This function allows more fine-grained control over the remote creation.
99-
static remote create_remote(const std::string &url,
100-
const create_options &options = create_options());
107+
static remote create_remote(const std::string &url,
108+
const create_options &options = create_options());
101109

102110
// Retrieve the name of the remote's default branch
103111
// This function must only be called after connecting.
@@ -118,6 +126,33 @@ class remote : public libgit2_api {
118126
// The memory is owned by the user and should be freed
119127
strarray fetch_refspec() const;
120128

129+
// Description of a reference advertised by a remote server, given out on `ls`
130+
// calls.
131+
class head : public libgit2_api {
132+
public:
133+
head(const git_remote_head *c_ptr) : c_struct_(*c_ptr) {}
134+
135+
bool local() const { return c_struct_.local; }
136+
137+
oid id() const { return oid(&c_struct_.oid); }
138+
139+
oid lid() const { return oid(&c_struct_.loid); }
140+
141+
std::string name() const {
142+
return c_struct_.name ? std::string(c_struct_.name) : "";
143+
}
144+
145+
// If the server send a symref mapping for this ref, this will point to the
146+
// target.
147+
std::string symref_target() const {
148+
return c_struct_.symref_target ? std::string(c_struct_.symref_target)
149+
: "";
150+
}
151+
152+
private:
153+
git_remote_head c_struct_;
154+
};
155+
121156
// Get the remote's list of push refspecs
122157
// The memory is owned by the user and should be freed
123158
strarray push_refspec() const;

src/remote.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ remote remote::create_detached_remote(const std::string &url) {
3939
return result;
4040
}
4141

42-
remote remote::create_remote(const std::string &url, const create_options &options) {
42+
remote remote::create_remote(const std::string &url,
43+
const create_options &options) {
4344
remote result;
4445
if (git_remote_create_with_opts(&result.c_ptr_, url.c_str(), options.c_ptr()))
4546
throw git_exception();

0 commit comments

Comments
 (0)