|
1 | 1 | #pragma once |
2 | 2 | #include <cppgit2/bitmask_operators.hpp> |
| 3 | +#include <cppgit2/connection_direction.hpp> |
3 | 4 | #include <cppgit2/data_buffer.hpp> |
4 | 5 | #include <cppgit2/fetch.hpp> |
5 | 6 | #include <cppgit2/indexer.hpp> |
@@ -31,6 +32,35 @@ class remote : public libgit2_api { |
31 | 32 | // is connected to the remote host. |
32 | 33 | bool is_connected() const; |
33 | 34 |
|
| 35 | + class callbacks : public libgit2_api { |
| 36 | + public: |
| 37 | + callbacks() : c_ptr_(nullptr) { |
| 38 | + auto ret = git_remote_init_callbacks(&default_options_, |
| 39 | + GIT_REMOTE_CALLBACKS_VERSION); |
| 40 | + c_ptr_ = &default_options_; |
| 41 | + if (ret != 0) |
| 42 | + throw git_exception(); |
| 43 | + } |
| 44 | + |
| 45 | + callbacks(git_remote_callbacks *c_ptr) : c_ptr_(c_ptr) {} |
| 46 | + |
| 47 | + // Access libgit2 C ptr |
| 48 | + const git_remote_callbacks *c_ptr() const { return c_ptr_; } |
| 49 | + |
| 50 | + private: |
| 51 | + git_remote_callbacks *c_ptr_; |
| 52 | + git_remote_callbacks default_options_; |
| 53 | + }; |
| 54 | + |
| 55 | + // Open a connection to a remote |
| 56 | + // The transport is selected based on the URL. The direction argument is due |
| 57 | + // to a limitation of the git protocol (over TCP or SSH) which starts up a |
| 58 | + // specific binary which can only do the one or the other. |
| 59 | + void connect(connection_direction direction, |
| 60 | + const callbacks &remote_callbacks = callbacks(), |
| 61 | + const proxy::options &proxy_options = proxy::options(), |
| 62 | + const strarray &custom_headers = strarray(nullptr)); |
| 63 | + |
34 | 64 | // Remote creation options flags |
35 | 65 | enum class create_flag { |
36 | 66 | // Ignore the repository apply.insteadOf configuration |
|
0 commit comments