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