]> git.proxmox.com Git - libgit2.git/blob - include/git2/remote.h
Merge pull request #3157 from mgorny/ssh_memory_auth
[libgit2.git] / include / git2 / remote.h
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 #ifndef INCLUDE_git_remote_h__
8 #define INCLUDE_git_remote_h__
9
10 #include "common.h"
11 #include "repository.h"
12 #include "refspec.h"
13 #include "net.h"
14 #include "indexer.h"
15 #include "strarray.h"
16 #include "transport.h"
17 #include "pack.h"
18
19 /**
20 * @file git2/remote.h
21 * @brief Git remote management functions
22 * @defgroup git_remote remote management functions
23 * @ingroup Git
24 * @{
25 */
26 GIT_BEGIN_DECL
27
28 typedef int (*git_remote_rename_problem_cb)(const char *problematic_refspec, void *payload);
29
30 /**
31 * Add a remote with the default fetch refspec to the repository's configuration.
32 *
33 * @param out the resulting remote
34 * @param repo the repository in which to create the remote
35 * @param name the remote's name
36 * @param url the remote's url
37 * @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code
38 */
39 GIT_EXTERN(int) git_remote_create(
40 git_remote **out,
41 git_repository *repo,
42 const char *name,
43 const char *url);
44
45 /**
46 * Add a remote with the provided fetch refspec (or default if NULL) to the repository's
47 * configuration.
48 *
49 * @param out the resulting remote
50 * @param repo the repository in which to create the remote
51 * @param name the remote's name
52 * @param url the remote's url
53 * @param fetch the remote fetch value
54 * @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code
55 */
56 GIT_EXTERN(int) git_remote_create_with_fetchspec(
57 git_remote **out,
58 git_repository *repo,
59 const char *name,
60 const char *url,
61 const char *fetch);
62
63 /**
64 * Create an anonymous remote
65 *
66 * Create a remote with the given url in-memory. You can use this when
67 * you have a URL instead of a remote's name.
68 *
69 * @param out pointer to the new remote objects
70 * @param repo the associated repository
71 * @param url the remote repository's URL
72 * @return 0 or an error code
73 */
74 GIT_EXTERN(int) git_remote_create_anonymous(
75 git_remote **out,
76 git_repository *repo,
77 const char *url);
78
79 /**
80 * Get the information for a particular remote
81 *
82 * The name will be checked for validity.
83 * See `git_tag_create()` for rules about valid names.
84 *
85 * @param out pointer to the new remote object
86 * @param repo the associated repository
87 * @param name the remote's name
88 * @return 0, GIT_ENOTFOUND, GIT_EINVALIDSPEC or an error code
89 */
90 GIT_EXTERN(int) git_remote_lookup(git_remote **out, git_repository *repo, const char *name);
91
92 /**
93 * Create a copy of an existing remote. All internal strings are also
94 * duplicated. Callbacks are not duplicated.
95 *
96 * Call `git_remote_free` to free the data.
97 *
98 * @param dest pointer where to store the copy
99 * @param source object to copy
100 * @return 0 or an error code
101 */
102 GIT_EXTERN(int) git_remote_dup(git_remote **dest, git_remote *source);
103
104 /**
105 * Get the remote's repository
106 *
107 * @param remote the remote
108 * @return a pointer to the repository
109 */
110 GIT_EXTERN(git_repository *) git_remote_owner(const git_remote *remote);
111
112 /**
113 * Get the remote's name
114 *
115 * @param remote the remote
116 * @return a pointer to the name or NULL for in-memory remotes
117 */
118 GIT_EXTERN(const char *) git_remote_name(const git_remote *remote);
119
120 /**
121 * Get the remote's url
122 *
123 * @param remote the remote
124 * @return a pointer to the url
125 */
126 GIT_EXTERN(const char *) git_remote_url(const git_remote *remote);
127
128 /**
129 * Get the remote's url for pushing
130 *
131 * @param remote the remote
132 * @return a pointer to the url or NULL if no special url for pushing is set
133 */
134 GIT_EXTERN(const char *) git_remote_pushurl(const git_remote *remote);
135
136 /**
137 * Set the remote's url in the configuration
138 *
139 * Remote objects already in memory will not be affected. This assumes
140 * the common case of a single-url remote and will otherwise return an error.
141 *
142 * @param repo the repository in which to perform the change
143 * @param remote the remote's name
144 * @param url the url to set
145 * @return 0 or an error value
146 */
147 GIT_EXTERN(int) git_remote_set_url(git_repository *repo, const char *remote, const char* url);
148
149 /**
150 * Set the remote's url for pushing in the configuration.
151 *
152 * Remote objects already in memory will not be affected. This assumes
153 * the common case of a single-url remote and will otherwise return an error.
154 *
155 *
156 * @param repo the repository in which to perform the change
157 * @param remote the remote's name
158 * @param url the url to set
159 */
160 GIT_EXTERN(int) git_remote_set_pushurl(git_repository *repo, const char *remote, const char* url);
161
162 /**
163 * Add a fetch refspec to the remote's configuration
164 *
165 * Add the given refspec to the fetch list in the configuration. No
166 * loaded remote instances will be affected.
167 *
168 * @param repo the repository in which to change the configuration
169 * @param remote the name of the remote to change
170 * @param refspec the new fetch refspec
171 * @return 0, GIT_EINVALIDSPEC if refspec is invalid or an error value
172 */
173 GIT_EXTERN(int) git_remote_add_fetch(git_repository *repo, const char *remote, const char *refspec);
174
175 /**
176 * Get the remote's list of fetch refspecs
177 *
178 * The memory is owned by the user and should be freed with
179 * `git_strarray_free`.
180 *
181 * @param array pointer to the array in which to store the strings
182 * @param remote the remote to query
183 */
184 GIT_EXTERN(int) git_remote_get_fetch_refspecs(git_strarray *array, const git_remote *remote);
185
186 /**
187 * Add a push refspec to the remote's configuration
188 *
189 * Add the given refspec to the push list in the configuration. No
190 * loaded remote instances will be affected.
191 *
192 * @param repo the repository in which to change the configuration
193 * @param remote the name of the remote to change
194 * @param refspec the new push refspec
195 * @return 0, GIT_EINVALIDSPEC if refspec is invalid or an error value
196 */
197 GIT_EXTERN(int) git_remote_add_push(git_repository *repo, const char *remote, const char *refspec);
198
199 /**
200 * Get the remote's list of push refspecs
201 *
202 * The memory is owned by the user and should be freed with
203 * `git_strarray_free`.
204 *
205 * @param array pointer to the array in which to store the strings
206 * @param remote the remote to query
207 */
208 GIT_EXTERN(int) git_remote_get_push_refspecs(git_strarray *array, const git_remote *remote);
209
210 /**
211 * Get the number of refspecs for a remote
212 *
213 * @param remote the remote
214 * @return the amount of refspecs configured in this remote
215 */
216 GIT_EXTERN(size_t) git_remote_refspec_count(const git_remote *remote);
217
218 /**
219 * Get a refspec from the remote
220 *
221 * @param remote the remote to query
222 * @param n the refspec to get
223 * @return the nth refspec
224 */
225 GIT_EXTERN(const git_refspec *)git_remote_get_refspec(const git_remote *remote, size_t n);
226
227 /**
228 * Open a connection to a remote
229 *
230 * The transport is selected based on the URL. The direction argument
231 * is due to a limitation of the git protocol (over TCP or SSH) which
232 * starts up a specific binary which can only do the one or the other.
233 *
234 * @param remote the remote to connect to
235 * @param direction GIT_DIRECTION_FETCH if you want to fetch or
236 * GIT_DIRECTION_PUSH if you want to push
237 * @param callbacks the callbacks to use for this connection
238 * @return 0 or an error code
239 */
240 GIT_EXTERN(int) git_remote_connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks);
241
242 /**
243 * Get the remote repository's reference advertisement list
244 *
245 * Get the list of references with which the server responds to a new
246 * connection.
247 *
248 * The remote (or more exactly its transport) must have connected to
249 * the remote repository. This list is available as soon as the
250 * connection to the remote is initiated and it remains available
251 * after disconnecting.
252 *
253 * The memory belongs to the remote. The pointer will be valid as long
254 * as a new connection is not initiated, but it is recommended that
255 * you make a copy in order to make use of the data.
256 *
257 * @param out pointer to the array
258 * @param size the number of remote heads
259 * @param remote the remote
260 * @return 0 on success, or an error code
261 */
262 GIT_EXTERN(int) git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote);
263
264 /**
265 * Check whether the remote is connected
266 *
267 * Check whether the remote's underlying transport is connected to the
268 * remote host.
269 *
270 * @param remote the remote
271 * @return 1 if it's connected, 0 otherwise.
272 */
273 GIT_EXTERN(int) git_remote_connected(const git_remote *remote);
274
275 /**
276 * Cancel the operation
277 *
278 * At certain points in its operation, the network code checks whether
279 * the operation has been cancelled and if so stops the operation.
280 *
281 * @param remote the remote
282 */
283 GIT_EXTERN(void) git_remote_stop(git_remote *remote);
284
285 /**
286 * Disconnect from the remote
287 *
288 * Close the connection to the remote.
289 *
290 * @param remote the remote to disconnect from
291 */
292 GIT_EXTERN(void) git_remote_disconnect(git_remote *remote);
293
294 /**
295 * Free the memory associated with a remote
296 *
297 * This also disconnects from the remote, if the connection
298 * has not been closed yet (using git_remote_disconnect).
299 *
300 * @param remote the remote to free
301 */
302 GIT_EXTERN(void) git_remote_free(git_remote *remote);
303
304 /**
305 * Get a list of the configured remotes for a repo
306 *
307 * The string array must be freed by the user.
308 *
309 * @param out a string array which receives the names of the remotes
310 * @param repo the repository to query
311 * @return 0 or an error code
312 */
313 GIT_EXTERN(int) git_remote_list(git_strarray *out, git_repository *repo);
314
315 /**
316 * Argument to the completion callback which tells it which operation
317 * finished.
318 */
319 typedef enum git_remote_completion_type {
320 GIT_REMOTE_COMPLETION_DOWNLOAD,
321 GIT_REMOTE_COMPLETION_INDEXING,
322 GIT_REMOTE_COMPLETION_ERROR,
323 } git_remote_completion_type;
324
325 /** Push network progress notification function */
326 typedef int (*git_push_transfer_progress)(
327 unsigned int current,
328 unsigned int total,
329 size_t bytes,
330 void* payload);
331 /**
332 * Represents an update which will be performed on the remote during push
333 */
334 typedef struct {
335 /**
336 * The source name of the reference
337 */
338 char *src_refname;
339 /**
340 * The name of the reference to update on the server
341 */
342 char *dst_refname;
343 /**
344 * The current target of the reference
345 */
346 git_oid src;
347 /**
348 * The new target for the reference
349 */
350 git_oid dst;
351 } git_push_update;
352
353 /**
354 * @param updates an array containing the updates which will be sent
355 * as commands to the destination.
356 * @param len number of elements in `updates`
357 * @param payload Payload provided by the caller
358 */
359 typedef int (*git_push_negotiation)(const git_push_update **updates, size_t len, void *payload);
360
361 /**
362 * The callback settings structure
363 *
364 * Set the callbacks to be called by the remote when informing the user
365 * about the progress of the network operations.
366 */
367 struct git_remote_callbacks {
368 unsigned int version;
369 /**
370 * Textual progress from the remote. Text send over the
371 * progress side-band will be passed to this function (this is
372 * the 'counting objects' output.
373 */
374 git_transport_message_cb sideband_progress;
375
376 /**
377 * Completion is called when different parts of the download
378 * process are done (currently unused).
379 */
380 int (*completion)(git_remote_completion_type type, void *data);
381
382 /**
383 * This will be called if the remote host requires
384 * authentication in order to connect to it.
385 *
386 * Returning GIT_PASSTHROUGH will make libgit2 behave as
387 * though this field isn't set.
388 */
389 git_cred_acquire_cb credentials;
390
391 /**
392 * If cert verification fails, this will be called to let the
393 * user make the final decision of whether to allow the
394 * connection to proceed. Returns 1 to allow the connection, 0
395 * to disallow it or a negative value to indicate an error.
396 */
397 git_transport_certificate_check_cb certificate_check;
398
399 /**
400 * During the download of new data, this will be regularly
401 * called with the current count of progress done by the
402 * indexer.
403 */
404 git_transfer_progress_cb transfer_progress;
405
406 /**
407 * Each time a reference is updated locally, this function
408 * will be called with information about it.
409 */
410 int (*update_tips)(const char *refname, const git_oid *a, const git_oid *b, void *data);
411
412 /**
413 * Function to call with progress information during pack
414 * building. Be aware that this is called inline with pack
415 * building operations, so performance may be affected.
416 */
417 git_packbuilder_progress pack_progress;
418
419 /**
420 * Function to call with progress information during the
421 * upload portion of a push. Be aware that this is called
422 * inline with pack building operations, so performance may be
423 * affected.
424 */
425 git_push_transfer_progress push_transfer_progress;
426
427 /**
428 * Called for each updated reference on push. If `status` is
429 * not `NULL`, the update was rejected by the remote server
430 * and `status` contains the reason given.
431 */
432 int (*push_update_reference)(const char *refname, const char *status, void *data);
433
434 /**
435 * Called once between the negotiation step and the upload. It
436 * provides information about what updates will be performed.
437 */
438 git_push_negotiation push_negotiation;
439
440 /**
441 * Create the transport to use for this operation. Leave NULL
442 * to auto-detect.
443 */
444 git_transport_cb transport;
445
446 /**
447 * This will be passed to each of the callbacks in this struct
448 * as the last parameter.
449 */
450 void *payload;
451 };
452
453 #define GIT_REMOTE_CALLBACKS_VERSION 1
454 #define GIT_REMOTE_CALLBACKS_INIT {GIT_REMOTE_CALLBACKS_VERSION}
455
456 /**
457 * Initializes a `git_remote_callbacks` with default values. Equivalent to
458 * creating an instance with GIT_REMOTE_CALLBACKS_INIT.
459 *
460 * @param opts the `git_remote_callbacks` struct to initialize
461 * @param version Version of struct; pass `GIT_REMOTE_CALLBACKS_VERSION`
462 * @return Zero on success; -1 on failure.
463 */
464 GIT_EXTERN(int) git_remote_init_callbacks(
465 git_remote_callbacks *opts,
466 unsigned int version);
467
468 typedef enum {
469 /**
470 * Use the setting from the configuration
471 */
472 GIT_FETCH_PRUNE_FALLBACK,
473 /**
474 * Force pruning on
475 */
476 GIT_FETCH_PRUNE,
477 /**
478 * Force pruning off
479 */
480 GIT_FETCH_NO_PRUNE,
481 } git_fetch_prune_t;
482
483 /**
484 * Automatic tag following option
485 *
486 * Lets us select the --tags option to use.
487 */
488 typedef enum {
489 /**
490 * Use the setting from the configuration.
491 */
492 GIT_REMOTE_DOWNLOAD_TAGS_FALLBACK = 0,
493 /**
494 * Ask the server for tags pointing to objects we're already
495 * downloading.
496 */
497 GIT_REMOTE_DOWNLOAD_TAGS_AUTO,
498 /**
499 * Don't ask for any tags beyond the refspecs.
500 */
501 GIT_REMOTE_DOWNLOAD_TAGS_NONE,
502 /**
503 * Ask for the all the tags.
504 */
505 GIT_REMOTE_DOWNLOAD_TAGS_ALL,
506 } git_remote_autotag_option_t;
507
508 typedef struct {
509 int version;
510
511 /**
512 * Callbacks to use for this fetch operation
513 */
514 git_remote_callbacks callbacks;
515
516 /**
517 * Whether to perform a prune after the fetch
518 */
519 git_fetch_prune_t prune;
520
521 /**
522 * Whether to write the results to FETCH_HEAD. Defaults to
523 * on. Leave this default in order to behave like git.
524 */
525 int update_fetchhead;
526
527 /**
528 * Determines how to behave regarding tags on the remote, such
529 * as auto-downloading tags for objects we're downloading or
530 * downloading all of them.
531 *
532 * The default is to auto-follow tags.
533 */
534 git_remote_autotag_option_t download_tags;
535 } git_fetch_options;
536
537 #define GIT_FETCH_OPTIONS_VERSION 1
538 #define GIT_FETCH_OPTIONS_INIT { GIT_FETCH_OPTIONS_VERSION, GIT_REMOTE_CALLBACKS_INIT, GIT_FETCH_PRUNE_FALLBACK, 1 }
539
540 /**
541 * Initializes a `git_fetch_options` with default values. Equivalent to
542 * creating an instance with GIT_FETCH_OPTIONS_INIT.
543 *
544 * @param opts the `git_push_options` instance to initialize.
545 * @param version the version of the struct; you should pass
546 * `GIT_FETCH_OPTIONS_VERSION` here.
547 * @return Zero on success; -1 on failure.
548 */
549 GIT_EXTERN(int) git_fetch_init_options(
550 git_fetch_options *opts,
551 unsigned int version);
552
553
554 /**
555 * Controls the behavior of a git_push object.
556 */
557 typedef struct {
558 unsigned int version;
559
560 /**
561 * If the transport being used to push to the remote requires the creation
562 * of a pack file, this controls the number of worker threads used by
563 * the packbuilder when creating that pack file to be sent to the remote.
564 *
565 * If set to 0, the packbuilder will auto-detect the number of threads
566 * to create. The default value is 1.
567 */
568 unsigned int pb_parallelism;
569
570 /**
571 * Callbacks to use for this push operation
572 */
573 git_remote_callbacks callbacks;
574 } git_push_options;
575
576 #define GIT_PUSH_OPTIONS_VERSION 1
577 #define GIT_PUSH_OPTIONS_INIT { GIT_PUSH_OPTIONS_VERSION, 0, GIT_REMOTE_CALLBACKS_INIT }
578
579 /**
580 * Initializes a `git_push_options` with default values. Equivalent to
581 * creating an instance with GIT_PUSH_OPTIONS_INIT.
582 *
583 * @param opts the `git_push_options` instance to initialize.
584 * @param version the version of the struct; you should pass
585 * `GIT_PUSH_OPTIONS_VERSION` here.
586 * @return Zero on success; -1 on failure.
587 */
588 GIT_EXTERN(int) git_push_init_options(
589 git_push_options *opts,
590 unsigned int version);
591
592 /**
593 * Download and index the packfile
594 *
595 * Connect to the remote if it hasn't been done yet, negotiate with
596 * the remote git which objects are missing, download and index the
597 * packfile.
598 *
599 * The .idx file will be created and both it and the packfile with be
600 * renamed to their final name.
601 *
602 * @param remote the remote
603 * @param refspecs the refspecs to use for this negotiation and
604 * download. Use NULL or an empty array to use the base refspecs
605 * @param opts the options to use for this fetch
606 * @return 0 or an error code
607 */
608 GIT_EXTERN(int) git_remote_download(git_remote *remote, const git_strarray *refspecs, const git_fetch_options *opts);
609
610 /**
611 * Create a packfile and send it to the server
612 *
613 * Connect to the remote if it hasn't been done yet, negotiate with
614 * the remote git which objects are missing, create a packfile with the missing objects and send it.
615 *
616 * @param remote the remote
617 * @param refspecs the refspecs to use for this negotiation and
618 * upload. Use NULL or an empty array to use the base refspecs
619 * @param opts the options to use for this push
620 * @return 0 or an error code
621 */
622 GIT_EXTERN(int) git_remote_upload(git_remote *remote, const git_strarray *refspecs, const git_push_options *opts);
623
624 /**
625 * Update the tips to the new state
626 *
627 * @param remote the remote to update
628 * @param reflog_message The message to insert into the reflogs. If
629 * NULL and fetching, the default is "fetch <name>", where <name> is
630 * the name of the remote (or its url, for in-memory remotes). This
631 * parameter is ignored when pushing.
632 * @param callbacks pointer to the callback structure to use
633 * @param update_fetchhead whether to write to FETCH_HEAD. Pass 1 to behave like git.
634 * @param download_tags what the behaviour for downloading tags is for this fetch. This is
635 * ignored for push. This must be the same value passed to `git_remote_download()`.
636 * @return 0 or an error code
637 */
638 GIT_EXTERN(int) git_remote_update_tips(
639 git_remote *remote,
640 const git_remote_callbacks *callbacks,
641 int update_fetchhead,
642 git_remote_autotag_option_t download_tags,
643 const char *reflog_message);
644
645 /**
646 * Download new data and update tips
647 *
648 * Convenience function to connect to a remote, download the data,
649 * disconnect and update the remote-tracking branches.
650 *
651 * @param remote the remote to fetch from
652 * @param refspecs the refspecs to use for this fetch. Pass NULL or an
653 * empty array to use the base refspecs.
654 * @param opts options to use for this fetch
655 * @param reflog_message The message to insert into the reflogs. If NULL, the
656 * default is "fetch"
657 * @return 0 or an error code
658 */
659 GIT_EXTERN(int) git_remote_fetch(
660 git_remote *remote,
661 const git_strarray *refspecs,
662 const git_fetch_options *opts,
663 const char *reflog_message);
664
665 /**
666 * Prune tracking refs that are no longer present on remote
667 *
668 * @param remote the remote to prune
669 * @param callbacks callbacks to use for this prune
670 * @return 0 or an error code
671 */
672 GIT_EXTERN(int) git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks);
673
674 /**
675 * Perform a push
676 *
677 * Peform all the steps from a push.
678 *
679 * @param remote the remote to push to
680 * @param refspecs the refspecs to use for pushing. If none are
681 * passed, the configured refspecs will be used
682 * @param opts options to use for this push
683 */
684 GIT_EXTERN(int) git_remote_push(git_remote *remote,
685 const git_strarray *refspecs,
686 const git_push_options *opts);
687
688 /**
689 * Get the statistics structure that is filled in by the fetch operation.
690 */
691 GIT_EXTERN(const git_transfer_progress *) git_remote_stats(git_remote *remote);
692
693 /**
694 * Retrieve the tag auto-follow setting
695 *
696 * @param remote the remote to query
697 * @return the auto-follow setting
698 */
699 GIT_EXTERN(git_remote_autotag_option_t) git_remote_autotag(const git_remote *remote);
700
701 /**
702 * Set the remote's tag following setting.
703 *
704 * The change will be made in the configuration. No loaded remotes
705 * will be affected.
706 *
707 * @param repo the repository in which to make the change
708 * @param remote the name of the remote
709 * @param value the new value to take.
710 */
711 GIT_EXTERN(int) git_remote_set_autotag(git_repository *repo, const char *remote, git_remote_autotag_option_t value);
712 /**
713 * Retrieve the ref-prune setting
714 *
715 * @param remote the remote to query
716 * @return the ref-prune setting
717 */
718 GIT_EXTERN(int) git_remote_prune_refs(const git_remote *remote);
719
720 /**
721 * Give the remote a new name
722 *
723 * All remote-tracking branches and configuration settings
724 * for the remote are updated.
725 *
726 * The new name will be checked for validity.
727 * See `git_tag_create()` for rules about valid names.
728 *
729 * No loaded instances of a the remote with the old name will change
730 * their name or their list of refspecs.
731 *
732 * @param problems non-default refspecs cannot be renamed and will be
733 * stored here for further processing by the caller. Always free this
734 * strarray on successful return.
735 * @param repo the repository in which to rename
736 * @param name the current name of the reamote
737 * @param new_name the new name the remote should bear
738 * @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code
739 */
740 GIT_EXTERN(int) git_remote_rename(
741 git_strarray *problems,
742 git_repository *repo,
743 const char *name,
744 const char *new_name);
745
746 /**
747 * Ensure the remote name is well-formed.
748 *
749 * @param remote_name name to be checked.
750 * @return 1 if the reference name is acceptable; 0 if it isn't
751 */
752 GIT_EXTERN(int) git_remote_is_valid_name(const char *remote_name);
753
754 /**
755 * Delete an existing persisted remote.
756 *
757 * All remote-tracking branches and configuration settings
758 * for the remote will be removed.
759 *
760 * @param repo the repository in which to act
761 * @param name the name of the remove to delete
762 * @return 0 on success, or an error code.
763 */
764 GIT_EXTERN(int) git_remote_delete(git_repository *repo, const char *name);
765
766 /**
767 * Retrieve the name of the remote's default branch
768 *
769 * The default branch of a repository is the branch which HEAD points
770 * to. If the remote does not support reporting this information
771 * directly, it performs the guess as git does; that is, if there are
772 * multiple branches which point to the same commit, the first one is
773 * chosen. If the master branch is a candidate, it wins.
774 *
775 * This function must only be called after connecting.
776 *
777 * @param out the buffern in which to store the reference name
778 * @param remote the remote
779 * @return 0, GIT_ENOTFOUND if the remote does not have any references
780 * or none of them point to HEAD's commit, or an error message.
781 */
782 GIT_EXTERN(int) git_remote_default_branch(git_buf *out, git_remote *remote);
783
784 /** @} */
785 GIT_END_DECL
786 #endif