1 /*
2  * Copyright (C) the libgit2 contributors. All rights reserved.
3  *
4  * This file is part of libgit2, distributed under the GNU GPL v2 with
5  * a Linking Exception. For full terms see the included COPYING file.
6  */
7 module libgit2_d.remote;
8 
9 
10 private static import libgit2_d.buffer;
11 private static import libgit2_d.cert;
12 private static import libgit2_d.credential;
13 private static import libgit2_d.indexer;
14 private static import libgit2_d.net;
15 private static import libgit2_d.oid;
16 private static import libgit2_d.pack;
17 private static import libgit2_d.proxy;
18 private static import libgit2_d.strarray;
19 private static import libgit2_d.transport;
20 private static import libgit2_d.types;
21 
22 /**
23  * @file git2/remote.h
24  * @brief Git remote management functions
25  * @defgroup git_remote remote management functions
26  * @ingroup Git
27  * @{
28  */
29 extern (C):
30 nothrow @nogc:
31 public:
32 
33 /**
34  * Add a remote with the default fetch refspec to the repository's
35  * configuration.
36  *
37  * @param out_ the resulting remote
38  * @param repo the repository in which to create the remote
39  * @param name the remote's name
40  * @param url the remote's url
41  * @return 0, git_error_code.GIT_EINVALIDSPEC, git_error_code.GIT_EEXISTS or an error code
42  */
43 //GIT_EXTERN
44 int git_remote_create(libgit2_d.types.git_remote** out_, libgit2_d.types.git_repository* repo, const (char)* name, const (char)* url);
45 
46 /**
47  * Remote creation options flags
48  */
49 enum git_remote_create_flags
50 {
51 	/**
52 	 * Ignore the repository apply.insteadOf configuration
53 	 */
54 	GIT_REMOTE_CREATE_SKIP_INSTEADOF = 1 << 0,
55 
56 	/**
57 	 * Don't build a fetchspec from the name if none is set
58 	 */
59 	GIT_REMOTE_CREATE_SKIP_DEFAULT_FETCHSPEC = 1 << 1,
60 }
61 
62 /**
63  * Remote creation options structure
64  *
65  * Initialize with `GIT_REMOTE_CREATE_OPTIONS_INIT`. Alternatively, you can
66  * use `git_remote_create_options_init`.
67  *
68  */
69 struct git_remote_create_options
70 {
71 	uint version_;
72 
73 	/**
74 	 * The repository that should own the remote.
75 	 * Setting this to NULL results in a detached remote.
76 	 */
77 	libgit2_d.types.git_repository* repository;
78 
79 	/**
80 	 * The remote's name.
81 	 * Setting this to NULL results in an in-memory/anonymous remote.
82 	 */
83 	const (char)* name;
84 
85 	/**
86 	 * The fetchspec the remote should use.
87 	 */
88 	const (char)* fetchspec;
89 
90 	/**
91 	 * Additional flags for the remote. See git_remote_create_flags.
92 	 */
93 	uint flags;
94 }
95 
96 enum GIT_REMOTE_CREATE_OPTIONS_VERSION = 1;
97 
98 pragma(inline, true)
99 pure nothrow @safe @nogc
100 .git_remote_create_options GIT_REMOTE_CREATE_OPTIONS_INIT()
101 
102 	do
103 	{
104 		.git_remote_create_options OUTPUT =
105 		{
106 			version_: GIT_REMOTE_CREATE_OPTIONS_VERSION,
107 		};
108 
109 		return OUTPUT;
110 	}
111 
112 /**
113  * Initialize git_remote_create_options structure
114  *
115  * Initializes a `git_remote_create_options` with default values. Equivalent to
116  * creating an instance with `GIT_REMOTE_CREATE_OPTIONS_INIT`.
117  *
118  * @param opts The `git_remote_create_options` struct to initialize.
119  * @param version The struct version; pass `GIT_REMOTE_CREATE_OPTIONS_VERSION`.
120  * @return Zero on success; -1 on failure.
121  */
122 //GIT_EXTERN
123 int git_remote_create_options_init(.git_remote_create_options* opts, uint version_);
124 
125 /**
126  * Create a remote, with options.
127  *
128  * This function allows more fine-grained control over the remote creation.
129  *
130  * Passing NULL as the opts argument will result in a detached remote.
131  *
132  * @param out_ the resulting remote
133  * @param url the remote's url
134  * @param opts the remote creation options
135  * @return 0, git_error_code.GIT_EINVALIDSPEC, git_error_code.GIT_EEXISTS or an error code
136  */
137 //GIT_EXTERN
138 int git_remote_create_with_opts(libgit2_d.types.git_remote** out_, const (char)* url, const (.git_remote_create_options)* opts);
139 
140 /**
141  * Add a remote with the provided fetch refspec (or default if null) to the
142  * repository's configuration.
143  *
144  * @param out_ the resulting remote
145  * @param repo the repository in which to create the remote
146  * @param name the remote's name
147  * @param url the remote's url
148  * @param fetch the remote fetch value
149  * @return 0, git_error_code.GIT_EINVALIDSPEC, git_error_code.GIT_EEXISTS or an error code
150  */
151 //GIT_EXTERN
152 int git_remote_create_with_fetchspec(libgit2_d.types.git_remote** out_, libgit2_d.types.git_repository* repo, const (char)* name, const (char)* url, const (char)* fetch);
153 
154 /**
155  * Create an anonymous remote
156  *
157  * Create a remote with the given url in-memory. You can use this when
158  * you have a URL instead of a remote's name.
159  *
160  * @param out_ pointer to the new remote objects
161  * @param repo the associated repository
162  * @param url the remote repository's URL
163  * @return 0 or an error code
164  */
165 //GIT_EXTERN
166 int git_remote_create_anonymous(libgit2_d.types.git_remote** out_, libgit2_d.types.git_repository* repo, const (char)* url);
167 
168 /**
169  * Create a remote without a connected local repo
170  *
171  * Create a remote with the given url in-memory. You can use this when
172  * you have a URL instead of a remote's name.
173  *
174  * Contrasted with git_remote_create_anonymous, a detached remote
175  * will not consider any repo configuration values (such as insteadof url
176  * substitutions).
177  *
178  * @param out_ pointer to the new remote objects
179  * @param url the remote repository's URL
180  * @return 0 or an error code
181  */
182 //GIT_EXTERN
183 int git_remote_create_detached(libgit2_d.types.git_remote** out_, const (char)* url);
184 
185 /**
186  * Get the information for a particular remote
187  *
188  * The name will be checked for validity.
189  * See `git_tag_create()` for rules about valid names.
190  *
191  * @param out_ pointer to the new remote object
192  * @param repo the associated repository
193  * @param name the remote's name
194  * @return 0, git_error_code.GIT_ENOTFOUND, git_error_code.GIT_EINVALIDSPEC or an error code
195  */
196 //GIT_EXTERN
197 int git_remote_lookup(libgit2_d.types.git_remote** out_, libgit2_d.types.git_repository* repo, const (char)* name);
198 
199 /**
200  * Create a copy of an existing remote.  All internal strings are also
201  * duplicated. Callbacks are not duplicated.
202  *
203  * Call `git_remote_free` to free the data.
204  *
205  * @param dest pointer where to store the copy
206  * @param source object to copy
207  * @return 0 or an error code
208  */
209 //GIT_EXTERN
210 int git_remote_dup(libgit2_d.types.git_remote** dest, libgit2_d.types.git_remote* source);
211 
212 /**
213  * Get the remote's repository
214  *
215  * @param remote the remote
216  * @return a pointer to the repository
217  */
218 //GIT_EXTERN
219 libgit2_d.types.git_repository* git_remote_owner(const (libgit2_d.types.git_remote)* remote);
220 
221 /**
222  * Get the remote's name
223  *
224  * @param remote the remote
225  * @return a pointer to the name or null for in-memory remotes
226  */
227 //GIT_EXTERN
228 const (char)* git_remote_name(const (libgit2_d.types.git_remote)* remote);
229 
230 /**
231  * Get the remote's url
232  *
233  * If url.*.insteadOf has been configured for this URL, it will
234  * return the modified URL.
235  *
236  * @param remote the remote
237  * @return a pointer to the url
238  */
239 //GIT_EXTERN
240 const (char)* git_remote_url(const (libgit2_d.types.git_remote)* remote);
241 
242 /**
243  * Get the remote's url for pushing
244  *
245  * If url.*.pushInsteadOf has been configured for this URL, it
246  * will return the modified URL.
247  *
248  * @param remote the remote
249  * @return a pointer to the url or null if no special url for pushing is set
250  */
251 //GIT_EXTERN
252 const (char)* git_remote_pushurl(const (libgit2_d.types.git_remote)* remote);
253 
254 /**
255  * Set the remote's url in the configuration
256  *
257  * Remote objects already in memory will not be affected. This assumes
258  * the common case of a single-url remote and will otherwise return an error.
259  *
260  * @param repo the repository in which to perform the change
261  * @param remote the remote's name
262  * @param url the url to set
263  * @return 0 or an error value
264  */
265 //GIT_EXTERN
266 int git_remote_set_url(libgit2_d.types.git_repository* repo, const (char)* remote, const (char)* url);
267 
268 /**
269  * Set the remote's url for pushing in the configuration.
270  *
271  * Remote objects already in memory will not be affected. This assumes
272  * the common case of a single-url remote and will otherwise return an error.
273  *
274  *
275  * @param repo the repository in which to perform the change
276  * @param remote the remote's name
277  * @param url the url to set
278  */
279 //GIT_EXTERN
280 int git_remote_set_pushurl(libgit2_d.types.git_repository* repo, const (char)* remote, const (char)* url);
281 
282 /**
283  * Add a fetch refspec to the remote's configuration
284  *
285  * Add the given refspec to the fetch list in the configuration. No
286  * loaded remote instances will be affected.
287  *
288  * @param repo the repository in which to change the configuration
289  * @param remote the name of the remote to change
290  * @param refspec the new fetch refspec
291  * @return 0, git_error_code.GIT_EINVALIDSPEC if refspec is invalid or an error value
292  */
293 //GIT_EXTERN
294 int git_remote_add_fetch(libgit2_d.types.git_repository* repo, const (char)* remote, const (char)* refspec);
295 
296 /**
297  * Get the remote's list of fetch refspecs
298  *
299  * The memory is owned by the user and should be freed with
300  * `git_strarray_free`.
301  *
302  * @param array pointer to the array in which to store the strings
303  * @param remote the remote to query
304  */
305 //GIT_EXTERN
306 int git_remote_get_fetch_refspecs(libgit2_d.strarray.git_strarray* array, const (libgit2_d.types.git_remote)* remote);
307 
308 /**
309  * Add a push refspec to the remote's configuration
310  *
311  * Add the given refspec to the push list in the configuration. No
312  * loaded remote instances will be affected.
313  *
314  * @param repo the repository in which to change the configuration
315  * @param remote the name of the remote to change
316  * @param refspec the new push refspec
317  * @return 0, git_error_code.GIT_EINVALIDSPEC if refspec is invalid or an error value
318  */
319 //GIT_EXTERN
320 int git_remote_add_push(libgit2_d.types.git_repository* repo, const (char)* remote, const (char)* refspec);
321 
322 /**
323  * Get the remote's list of push refspecs
324  *
325  * The memory is owned by the user and should be freed with
326  * `git_strarray_free`.
327  *
328  * @param array pointer to the array in which to store the strings
329  * @param remote the remote to query
330  */
331 //GIT_EXTERN
332 int git_remote_get_push_refspecs(libgit2_d.strarray.git_strarray* array, const (libgit2_d.types.git_remote)* remote);
333 
334 /**
335  * Get the number of refspecs for a remote
336  *
337  * @param remote the remote
338  * @return the amount of refspecs configured in this remote
339  */
340 //GIT_EXTERN
341 size_t git_remote_refspec_count(const (libgit2_d.types.git_remote)* remote);
342 
343 /**
344  * Get a refspec from the remote
345  *
346  * @param remote the remote to query
347  * @param n the refspec to get
348  * @return the nth refspec
349  */
350 //GIT_EXTERN
351 const (libgit2_d.types.git_refspec)* git_remote_get_refspec(const (libgit2_d.types.git_remote)* remote, size_t n);
352 
353 /**
354  * Open a connection to a remote
355  *
356  * The transport is selected based on the URL. The direction argument
357  * is due to a limitation of the git protocol (over TCP or SSH) which
358  * starts up a specific binary which can only do the one or the other.
359  *
360  * @param remote the remote to connect to
361  * @param direction git_direction.GIT_DIRECTION_FETCH if you want to fetch or
362  * git_direction.GIT_DIRECTION_PUSH if you want to push
363  * @param callbacks the callbacks to use for this connection
364  * @param proxy_opts proxy settings
365  * @param custom_headers extra HTTP headers to use in this connection
366  * @return 0 or an error code
367  */
368 //GIT_EXTERN
369 int git_remote_connect(libgit2_d.types.git_remote* remote, libgit2_d.net.git_direction direction, const (.git_remote_callbacks)* callbacks, const (libgit2_d.proxy.git_proxy_options)* proxy_opts, const (libgit2_d.strarray.git_strarray)* custom_headers);
370 
371 /**
372  * Get the remote repository's reference advertisement list
373  *
374  * Get the list of references with which the server responds to a new
375  * connection.
376  *
377  * The remote (or more exactly its transport) must have connected to
378  * the remote repository. This list is available as soon as the
379  * connection to the remote is initiated and it remains available
380  * after disconnecting.
381  *
382  * The memory belongs to the remote. The pointer will be valid as long
383  * as a new connection is not initiated, but it is recommended that
384  * you make a copy in order to make use of the data.
385  *
386  * @param out_ pointer to the array
387  * @param size the number of remote heads
388  * @param remote the remote
389  * @return 0 on success, or an error code
390  */
391 //GIT_EXTERN
392 int git_remote_ls(const (libgit2_d.types.git_remote_head)*** out_, size_t* size, libgit2_d.types.git_remote* remote);
393 
394 /**
395  * Check whether the remote is connected
396  *
397  * Check whether the remote's underlying transport is connected to the
398  * remote host.
399  *
400  * @param remote the remote
401  * @return 1 if it's connected, 0 otherwise.
402  */
403 //GIT_EXTERN
404 int git_remote_connected(const (libgit2_d.types.git_remote)* remote);
405 
406 /**
407  * Cancel the operation
408  *
409  * At certain points in its operation, the network code checks whether
410  * the operation has been cancelled and if so stops the operation.
411  *
412  * @param remote the remote
413  * @return 0 on success, or an error code
414  */
415 //GIT_EXTERN
416 int git_remote_stop(libgit2_d.types.git_remote* remote);
417 
418 /**
419  * Disconnect from the remote
420  *
421  * Close the connection to the remote.
422  *
423  * @param remote the remote to disconnect from
424  * @return 0 on success, or an error code
425  */
426 //GIT_EXTERN
427 int git_remote_disconnect(libgit2_d.types.git_remote* remote);
428 
429 /**
430  * Free the memory associated with a remote
431  *
432  * This also disconnects from the remote, if the connection
433  * has not been closed yet (using git_remote_disconnect).
434  *
435  * @param remote the remote to free
436  */
437 //GIT_EXTERN
438 void git_remote_free(libgit2_d.types.git_remote* remote);
439 
440 /**
441  * Get a list of the configured remotes for a repo
442  *
443  * The string array must be freed by the user.
444  *
445  * @param out_ a string array which receives the names of the remotes
446  * @param repo the repository to query
447  * @return 0 or an error code
448  */
449 //GIT_EXTERN
450 int git_remote_list(libgit2_d.strarray.git_strarray* out_, libgit2_d.types.git_repository* repo);
451 
452 /**
453  * Argument to the completion callback which tells it which operation
454  * finished.
455  */
456 enum git_remote_completion_t
457 {
458 	GIT_REMOTE_COMPLETION_DOWNLOAD,
459 	GIT_REMOTE_COMPLETION_INDEXING,
460 	GIT_REMOTE_COMPLETION_ERROR,
461 }
462 
463 /**
464  * Push network progress notification function
465  */
466 alias git_push_transfer_progress_cb = int function(uint current, uint total, size_t bytes, void* payload);
467 
468 /**
469  * Represents an update which will be performed on the remote during push
470  */
471 struct git_push_update
472 {
473 	/**
474 	 * The source name of the reference
475 	 */
476 	char* src_refname;
477 
478 	/**
479 	 * The name of the reference to update on the server
480 	 */
481 	char* dst_refname;
482 
483 	/**
484 	 * The current target of the reference
485 	 */
486 	libgit2_d.oid.git_oid src;
487 
488 	/**
489 	 * The new target for the reference
490 	 */
491 	libgit2_d.oid.git_oid dst;
492 }
493 
494 /**
495  * Callback used to inform of upcoming updates.
496  *
497  * @param updates an array containing the updates which will be sent
498  * as commands to the destination.
499  * @param len number of elements in `updates`
500  * @param payload Payload provided by the caller
501  */
502 alias git_push_negotiation = int function(const (.git_push_update)** updates, size_t len, void* payload);
503 
504 /**
505  * Callback used to inform of the update status from the remote.
506  *
507  * Called for each updated reference on push. If `status` is
508  * not `null`, the update was rejected by the remote server
509  * and `status` contains the reason given.
510  *
511  * @param refname refname specifying to the remote ref
512  * @param status status message sent from the remote
513  * @param data data provided by the caller
514  * @return 0 on success, otherwise an error
515  */
516 alias git_push_update_reference_cb = int function(const (char)* refname, const (char)* status, void* data);
517 
518 /**
519  * Callback to resolve URLs before connecting to remote
520  *
521  * If you return git_error_code.GIT_PASSTHROUGH, you don't need to write anything to
522  * url_resolved.
523  *
524  * @param url_resolved The buffer to write the resolved URL to
525  * @param url The URL to resolve
526  * @param direction git_direction.GIT_DIRECTION_FETCH or git_direction.GIT_DIRECTION_PUSH
527  * @param payload Payload provided by the caller
528  * @return 0 on success, git_error_code.GIT_PASSTHROUGH or an error
529  */
530 alias git_url_resolve_cb = int function(libgit2_d.buffer.git_buf* url_resolved, const (char)* url, int direction, void* payload);
531 
532 /**
533  * The callback settings structure
534  *
535  * Set the callbacks to be called by the remote when informing the user
536  * about the progress of the network operations.
537  */
538 struct git_remote_callbacks
539 {
540 	/**
541 	 * The version
542 	 */
543 	uint version_;
544 
545 	/**
546 	 * Textual progress from the remote. Text send over the
547 	 * progress side-band will be passed to this function (this is
548 	 * the 'counting objects' output).
549 	 */
550 	libgit2_d.transport.git_transport_message_cb sideband_progress;
551 
552 	/**
553 	 * Completion is called when different parts of the download
554 	 * process are done (currently unused).
555 	 */
556 	int function(.git_remote_completion_t type, void* data) completion;
557 
558 	/**
559 	 * This will be called if the remote host requires
560 	 * authentication in order to connect to it.
561 	 *
562 	 * Returning git_error_code.GIT_PASSTHROUGH will make libgit2 behave as
563 	 * though this field isn't set.
564 	 */
565 	libgit2_d.credential.git_credential_acquire_cb credentials;
566 
567 	/**
568 	 * If cert verification fails, this will be called to let the
569 	 * user make the final decision of whether to allow the
570 	 * connection to proceed. Returns 0 to allow the connection
571 	 * or a negative value to indicate an error.
572 	 */
573 	libgit2_d.cert.git_transport_certificate_check_cb certificate_check;
574 
575 	/**
576 	 * During the download of new data, this will be regularly
577 	 * called with the current count of progress done by the
578 	 * indexer.
579 	 */
580 	libgit2_d.indexer.git_indexer_progress_cb transfer_progress;
581 
582 	/**
583 	 * Each time a reference is updated locally, this function
584 	 * will be called with information about it.
585 	 */
586 	int function(const (char)* refname, const (libgit2_d.oid.git_oid)* a, const (libgit2_d.oid.git_oid)* b, void* data) update_tips;
587 
588 	/**
589 	 * Function to call with progress information during pack
590 	 * building. Be aware that this is called inline with pack
591 	 * building operations, so performance may be affected.
592 	 */
593 	libgit2_d.pack.git_packbuilder_progress pack_progress;
594 
595 	/**
596 	 * Function to call with progress information during the
597 	 * upload portion of a push. Be aware that this is called
598 	 * inline with pack building operations, so performance may be
599 	 * affected.
600 	 */
601 	.git_push_transfer_progress_cb push_transfer_progress;
602 
603 	/**
604 	 * See documentation of git_push_update_reference_cb
605 	 */
606 	.git_push_update_reference_cb push_update_reference;
607 
608 	/**
609 	 * Called once between the negotiation step and the upload. It
610 	 * provides information about what updates will be performed.
611 	 */
612 	.git_push_negotiation push_negotiation;
613 
614 	/**
615 	 * Create the transport to use for this operation. Leave null
616 	 * to auto-detect.
617 	 */
618 	libgit2_d.transport.git_transport_cb transport;
619 
620 	/**
621 	 * This will be passed to each of the callbacks in this struct
622 	 * as the last parameter.
623 	 */
624 	void* payload;
625 
626 	/**
627 	 * Resolve URL before connecting to remote.
628 	 * The returned URL will be used to connect to the remote instead.
629 	 */
630 	.git_url_resolve_cb resolve_url;
631 }
632 
633 enum GIT_REMOTE_CALLBACKS_VERSION = 1;
634 
635 pragma(inline, true)
636 pure nothrow @safe @nogc
637 .git_remote_callbacks GIT_REMOTE_CALLBACKS_INIT()
638 
639 	do
640 	{
641 		.git_remote_callbacks OUTPUT =
642 		{
643 			version_: .GIT_REMOTE_CALLBACKS_VERSION,
644 		};
645 
646 		return OUTPUT;
647 	}
648 
649 /**
650  * Initializes a `git_remote_callbacks` with default values. Equivalent to
651  * creating an instance with GIT_REMOTE_CALLBACKS_INIT.
652  *
653  * @param opts the `git_remote_callbacks` struct to initialize
654  * @param version_ Version of struct; pass `GIT_REMOTE_CALLBACKS_VERSION`
655  * @return Zero on success; -1 on failure.
656  */
657 //GIT_EXTERN
658 int git_remote_init_callbacks(.git_remote_callbacks* opts, uint version_);
659 
660 /**
661  * Acceptable prune settings when fetching
662  */
663 enum git_fetch_prune_t
664 {
665 	/**
666 	 * Use the setting from the configuration
667 	 */
668 	GIT_FETCH_PRUNE_UNSPECIFIED,
669 
670 	/**
671 	 * Force pruning on
672 	 */
673 	GIT_FETCH_PRUNE,
674 
675 	/**
676 	 * Force pruning off
677 	 */
678 	GIT_FETCH_NO_PRUNE,
679 }
680 
681 /**
682  * Automatic tag following option
683  *
684  * Lets us select the --tags option to use.
685  */
686 enum git_remote_autotag_option_t
687 {
688 	/**
689 	 * Use the setting from the configuration.
690 	 */
691 	GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED = 0,
692 
693 	/**
694 	 * Ask the server for tags pointing to objects we're already
695 	 * downloading.
696 	 */
697 	GIT_REMOTE_DOWNLOAD_TAGS_AUTO,
698 
699 	/**
700 	 * Don't ask for any tags beyond the refspecs.
701 	 */
702 	GIT_REMOTE_DOWNLOAD_TAGS_NONE,
703 
704 	/**
705 	 * Ask for the all the tags.
706 	 */
707 	GIT_REMOTE_DOWNLOAD_TAGS_ALL,
708 }
709 
710 /**
711  * Fetch options structure.
712  *
713  * Zero out for defaults.  Initialize with `GIT_FETCH_OPTIONS_INIT` macro to
714  * correctly set the `version_` field.  E.g.
715  *
716  *		git_fetch_options opts = GIT_FETCH_OPTIONS_INIT;
717  */
718 struct git_fetch_options
719 {
720 	int version_;
721 
722 	/**
723 	 * Callbacks to use for this fetch operation
724 	 */
725 	.git_remote_callbacks callbacks;
726 
727 	/**
728 	 * Whether to perform a prune after the fetch
729 	 */
730 	.git_fetch_prune_t prune;
731 
732 	/**
733 	 * Whether to write the results to FETCH_HEAD. Defaults to
734 	 * on. Leave this default in order to behave like git.
735 	 */
736 	int update_fetchhead;
737 
738 	/**
739 	 * Determines how to behave regarding tags on the remote, such
740 	 * as auto-downloading tags for objects we're downloading or
741 	 * downloading all of them.
742 	 *
743 	 * The default is to auto-follow tags.
744 	 */
745 	.git_remote_autotag_option_t download_tags;
746 
747 	/**
748 	 * Proxy options to use, by default no proxy is used.
749 	 */
750 	libgit2_d.proxy.git_proxy_options proxy_opts;
751 
752 	/**
753 	 * Extra headers for this fetch operation
754 	 */
755 	libgit2_d.strarray.git_strarray custom_headers;
756 }
757 
758 enum GIT_FETCH_OPTIONS_VERSION = 1;
759 
760 pragma(inline, true)
761 pure nothrow @safe @nogc
762 .git_fetch_options GIT_FETCH_OPTIONS_INIT()
763 
764 	do
765 	{
766 		.git_fetch_options OUTPUT =
767 		{
768 			version_: .GIT_FETCH_OPTIONS_VERSION,
769 			callbacks: .GIT_REMOTE_CALLBACKS_INIT(),
770 			prune: .git_fetch_prune_t.GIT_FETCH_PRUNE_UNSPECIFIED,
771 			update_fetchhead: 1,
772 			download_tags: .git_remote_autotag_option_t.GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED,
773 			proxy_opts: libgit2_d.proxy.GIT_PROXY_OPTIONS_INIT(),
774 		};
775 
776 		return OUTPUT;
777 	}
778 
779 /**
780  * Initialize git_fetch_options structure
781  *
782  * Initializes a `git_fetch_options` with default values. Equivalent to
783  * creating an instance with `GIT_FETCH_OPTIONS_INIT`.
784  *
785  * @param opts The `git_fetch_options` struct to initialize.
786  * @param version The struct version; pass `GIT_FETCH_OPTIONS_VERSION`.
787  * @return Zero on success; -1 on failure.
788  */
789 //GIT_EXTERN
790 int git_fetch_options_init(.git_fetch_options* opts, uint version_);
791 
792 /**
793  * Controls the behavior of a git_push object.
794  */
795 struct git_push_options
796 {
797 	uint version_;
798 
799 	/**
800 	 * If the transport being used to push to the remote requires the creation
801 	 * of a pack file, this controls the number of worker threads used by
802 	 * the packbuilder when creating that pack file to be sent to the remote.
803 	 *
804 	 * If set to 0, the packbuilder will auto-detect the number of threads
805 	 * to create. The default value is 1.
806 	 */
807 	uint pb_parallelism;
808 
809 	/**
810 	 * Callbacks to use for this push operation
811 	 */
812 	.git_remote_callbacks callbacks;
813 
814 	/**
815 	 * Proxy options to use, by default no proxy is used.
816 	 */
817 	libgit2_d.proxy.git_proxy_options proxy_opts;
818 
819 	/**
820 	 * Extra headers for this push operation
821 	 */
822 	libgit2_d.strarray.git_strarray custom_headers;
823 }
824 
825 enum GIT_PUSH_OPTIONS_VERSION = 1;
826 
827 pragma(inline, true)
828 pure nothrow @safe @nogc
829 .git_push_options GIT_PUSH_OPTIONS_INIT()
830 
831 	do
832 	{
833 		.git_push_options OUTPUT =
834 		{
835 			version_: .GIT_PUSH_OPTIONS_VERSION,
836 			pb_parallelism: 1,
837 			callbacks: .GIT_REMOTE_CALLBACKS_INIT(),
838 			proxy_opts: libgit2_d.proxy.GIT_PROXY_OPTIONS_INIT(),
839 		};
840 
841 		return OUTPUT;
842 	}
843 
844 /**
845  * Initialize git_push_options structure
846  *
847  * Initializes a `git_push_options` with default values. Equivalent to
848  * creating an instance with `GIT_PUSH_OPTIONS_INIT`.
849  *
850  * @param opts The `git_push_options` struct to initialize.
851  * @param version The struct version; pass `GIT_PUSH_OPTIONS_VERSION`.
852  * @return Zero on success; -1 on failure.
853  */
854 //GIT_EXTERN
855 int git_push_options_init(.git_push_options* opts, uint version_);
856 
857 /**
858  * Download and index the packfile
859  *
860  * Connect to the remote if it hasn't been done yet, negotiate with
861  * the remote git which objects are missing, download and index the
862  * packfile.
863  *
864  * The .idx file will be created and both it and the packfile with be
865  * renamed to their final name.
866  *
867  * @param remote the remote
868  * @param refspecs the refspecs to use for this negotiation and
869  * download. Use null or an empty array to use the base refspecs
870  * @param opts the options to use for this fetch
871  * @return 0 or an error code
872  */
873 //GIT_EXTERN
874 int git_remote_download(libgit2_d.types.git_remote* remote, const (libgit2_d.strarray.git_strarray)* refspecs, const (.git_fetch_options)* opts);
875 
876 /**
877  * Create a packfile and send it to the server
878  *
879  * Connect to the remote if it hasn't been done yet, negotiate with
880  * the remote git which objects are missing, create a packfile with the missing
881  * objects and send it.
882  *
883  * @param remote the remote
884  * @param refspecs the refspecs to use for this negotiation and
885  * upload. Use null or an empty array to use the base refspecs
886  * @param opts the options to use for this push
887  * @return 0 or an error code
888  */
889 //GIT_EXTERN
890 int git_remote_upload(libgit2_d.types.git_remote* remote, const (libgit2_d.strarray.git_strarray)* refspecs, const (.git_push_options)* opts);
891 
892 /**
893  * Update the tips to the new state
894  *
895  * @param remote the remote to update
896  * @param reflog_message The message to insert into the reflogs. If
897  * null and fetching, the default is "fetch <name>", where <name> is
898  * the name of the remote (or its url, for in-memory remotes). This
899  * parameter is ignored when pushing.
900  * @param callbacks  pointer to the callback structure to use
901  * @param update_fetchhead whether to write to FETCH_HEAD. Pass 1 to behave like
902  * git.
903  * @param download_tags what the behaviour for downloading tags is for this
904  * fetch. This is ignored for push. This must be the same value passed to
905  * `git_remote_download()`.
906  * @return 0 or an error code
907  */
908 //GIT_EXTERN
909 int git_remote_update_tips(libgit2_d.types.git_remote* remote, const (.git_remote_callbacks)* callbacks, int update_fetchhead, .git_remote_autotag_option_t download_tags, const (char)* reflog_message);
910 
911 /**
912  * Download new data and update tips
913  *
914  * Convenience function to connect to a remote, download the data,
915  * disconnect and update the remote-tracking branches.
916  *
917  * @param remote the remote to fetch from
918  * @param refspecs the refspecs to use for this fetch. Pass null or an
919  *                 empty array to use the base refspecs.
920  * @param opts options to use for this fetch
921  * @param reflog_message The message to insert into the reflogs. If null, the
922  *								 default is
923  *"fetch"
924  * @return 0 or an error code
925  */
926 //GIT_EXTERN
927 int git_remote_fetch(libgit2_d.types.git_remote* remote, const (libgit2_d.strarray.git_strarray)* refspecs, const (.git_fetch_options)* opts, const (char)* reflog_message);
928 
929 /**
930  * Prune tracking refs that are no longer present on remote
931  *
932  * @param remote the remote to prune
933  * @param callbacks callbacks to use for this prune
934  * @return 0 or an error code
935  */
936 //GIT_EXTERN
937 int git_remote_prune(libgit2_d.types.git_remote* remote, const (.git_remote_callbacks)* callbacks);
938 
939 /**
940  * Perform a push
941  *
942  * Peform all the steps from a push.
943  *
944  * @param remote the remote to push to
945  * @param refspecs the refspecs to use for pushing. If null or an empty
946  *                 array, the configured refspecs will be used
947  * @param opts options to use for this push
948  */
949 //GIT_EXTERN
950 int git_remote_push(libgit2_d.types.git_remote* remote, const (libgit2_d.strarray.git_strarray)* refspecs, const (.git_push_options)* opts);
951 
952 /**
953  * Get the statistics structure that is filled in by the fetch operation.
954  */
955 //GIT_EXTERN
956 const (libgit2_d.indexer.git_indexer_progress)* git_remote_stats(libgit2_d.types.git_remote* remote);
957 
958 /**
959  * Retrieve the tag auto-follow setting
960  *
961  * @param remote the remote to query
962  * @return the auto-follow setting
963  */
964 //GIT_EXTERN
965 .git_remote_autotag_option_t git_remote_autotag(const (libgit2_d.types.git_remote)* remote);
966 
967 /**
968  * Set the remote's tag following setting.
969  *
970  * The change will be made in the configuration. No loaded remotes
971  * will be affected.
972  *
973  * @param repo the repository in which to make the change
974  * @param remote the name of the remote
975  * @param value the new value to take.
976  */
977 //GIT_EXTERN
978 int git_remote_set_autotag(libgit2_d.types.git_repository* repo, const (char)* remote, .git_remote_autotag_option_t value);
979 
980 /**
981  * Retrieve the ref-prune setting
982  *
983  * @param remote the remote to query
984  * @return the ref-prune setting
985  */
986 //GIT_EXTERN
987 int git_remote_prune_refs(const (libgit2_d.types.git_remote)* remote);
988 
989 /**
990  * Give the remote a new name
991  *
992  * All remote-tracking branches and configuration settings
993  * for the remote are updated.
994  *
995  * The new name will be checked for validity.
996  * See `git_tag_create()` for rules about valid names.
997  *
998  * No loaded instances of a the remote with the old name will change
999  * their name or their list of refspecs.
1000  *
1001  * @param problems non-default refspecs cannot be renamed and will be
1002  * stored here for further processing by the caller. Always free this
1003  * strarray on successful return.
1004  * @param repo the repository in which to rename
1005  * @param name the current name of the remote
1006  * @param new_name the new name the remote should bear
1007  * @return 0, git_error_code.GIT_EINVALIDSPEC, git_error_code.GIT_EEXISTS or an error code
1008  */
1009 //GIT_EXTERN
1010 int git_remote_rename(libgit2_d.strarray.git_strarray* problems, libgit2_d.types.git_repository* repo, const (char)* name, const (char)* new_name);
1011 
1012 /**
1013  * Ensure the remote name is well-formed.
1014  *
1015  * @param remote_name name to be checked.
1016  * @return 1 if the reference name is acceptable; 0 if it isn't
1017  */
1018 //GIT_EXTERN
1019 int git_remote_is_valid_name(const (char)* remote_name);
1020 
1021 /**
1022  * Delete an existing persisted remote.
1023  *
1024  * All remote-tracking branches and configuration settings
1025  * for the remote will be removed.
1026  *
1027  * @param repo the repository in which to act
1028  * @param name the name of the remote to delete
1029  * @return 0 on success, or an error code.
1030  */
1031 //GIT_EXTERN
1032 int git_remote_delete(libgit2_d.types.git_repository* repo, const (char)* name);
1033 
1034 /**
1035  * Retrieve the name of the remote's default branch
1036  *
1037  * The default branch of a repository is the branch which HEAD points
1038  * to. If the remote does not support reporting this information
1039  * directly, it performs the guess as git does; that is, if there are
1040  * multiple branches which point to the same commit, the first one is
1041  * chosen. If the master branch is a candidate, it wins.
1042  *
1043  * This function must only be called after connecting.
1044  *
1045  * @param out_ the buffern in which to store the reference name
1046  * @param remote the remote
1047  * @return 0, git_error_code.GIT_ENOTFOUND if the remote does not have any references
1048  * or none of them point to HEAD's commit, or an error message.
1049  */
1050 //GIT_EXTERN
1051 int git_remote_default_branch(libgit2_d.buffer.git_buf* out_, libgit2_d.types.git_remote* remote);
1052 
1053 /** @} */