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