@@ -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 ;
0 commit comments