]> git.proxmox.com Git - libgit2.git/blame - include/git2/remote.h
Properly tag all `enums` with a `_t`
[libgit2.git] / include / git2 / remote.h
CommitLineData
bdd18829 1/*
5e0de328 2 * Copyright (C) 2009-2012 the libgit2 contributors
bdd18829 3 *
bb742ede
VM
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.
bdd18829 6 */
9c82357b
CMN
7#ifndef INCLUDE_git_remote_h__
8#define INCLUDE_git_remote_h__
9
2cbca8b0
VM
10#include "common.h"
11#include "repository.h"
12#include "refspec.h"
d88d4311 13#include "net.h"
dee5515a 14#include "indexer.h"
d88d4311 15
1e76676f
CMN
16/**
17 * @file git2/remote.h
18 * @brief Git remote management functions
19 * @defgroup git_remote remote management functions
20 * @ingroup Git
21 * @{
22 */
23GIT_BEGIN_DECL
9c82357b 24
f8f3feb0
CMN
25/*
26 * TODO: This functions still need to be implemented:
27 * - _listcb/_foreach
28 * - _add
29 * - _rename
30 * - _del (needs support from config)
31 */
32
778e1c73 33/**
617bfdf4 34 * Create a remote in memory
778e1c73 35 *
617bfdf4
CMN
36 * Create a remote with the default refspecs in memory. You can use
37 * this when you have a URL instead of a remote's name.
778e1c73
CMN
38 *
39 * @param out pointer to the new remote object
40 * @param repo the associtated repository
617bfdf4 41 * @param name the remote's name
baaa8a44
CMN
42 * @param url the remote repository's URL
43 * @param fetch the fetch refspec to use for this remote
d9111722 44 * @return GIT_SUCCESS or an error code
778e1c73 45 */
baaa8a44 46GIT_EXTERN(int) git_remote_new(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch);
778e1c73 47
9c82357b
CMN
48/**
49 * Get the information for a particular remote
50 *
51 * @param out pointer to the new remote object
52 * @param cfg the repository's configuration
53 * @param name the remote's name
d9111722 54 * @return GIT_SUCCESS or an error code
9c82357b 55 */
9462c471 56GIT_EXTERN(int) git_remote_load(git_remote **out, git_repository *repo, const char *name);
9c82357b 57
89e5ed98
CMN
58/**
59 * Save a remote to its repository's configuration
60 *
61 * @param remote the remote to save to config
62 * @return GIT_SUCCESS or an error code
63 */
64GIT_EXTERN(int) git_remote_save(const git_remote *remote);
65
9c82357b
CMN
66/**
67 * Get the remote's name
68 *
69 * @param remote the remote
70 * @return a pointer to the name
71 */
9462c471 72GIT_EXTERN(const char *) git_remote_name(git_remote *remote);
9c82357b
CMN
73
74/**
75 * Get the remote's url
76 *
77 * @param remote the remote
78 * @return a pointer to the url
79 */
9462c471 80GIT_EXTERN(const char *) git_remote_url(git_remote *remote);
9c82357b 81
bcb8c007
CMN
82/**
83 * Set the remote's fetch refspec
84 *
85 * @param remote the remote
86 * @apram spec the new fetch refspec
87 * @return GIT_SUCCESS or an error value
88 */
89GIT_EXTERN(int) git_remote_set_fetchspec(git_remote *remote, const char *spec);
90
9c82357b
CMN
91/**
92 * Get the fetch refspec
93 *
94 * @param remote the remote
95 * @return a pointer to the fetch refspec or NULL if it doesn't exist
96 */
9462c471 97GIT_EXTERN(const git_refspec *) git_remote_fetchspec(git_remote *remote);
9c82357b 98
bcb8c007
CMN
99/**
100 * Set the remote's push refspec
101 *
102 * @param remote the remote
103 * @apram spec the new push refspec
104 * @return GIT_SUCCESS or an error value
105 */
106GIT_EXTERN(int) git_remote_set_pushspec(git_remote *remote, const char *spec);
107
9c82357b
CMN
108/**
109 * Get the push refspec
110 *
111 * @param remote the remote
112 * @return a pointer to the push refspec or NULL if it doesn't exist
113 */
114
9462c471 115GIT_EXTERN(const git_refspec *) git_remote_pushspec(git_remote *remote);
9c82357b 116
9ba49bb5
CMN
117/**
118 * Open a connection to a remote
119 *
e1d88030
CMN
120 * The transport is selected based on the URL. The direction argument
121 * is due to a limitation of the git protocol (over TCP or SSH) which
122 * starts up a specific binary which can only do the one or the other.
9ba49bb5
CMN
123 *
124 * @param remote the remote to connect to
e1d88030 125 * @param direction whether you want to receive or send data
9ba49bb5
CMN
126 * @return GIT_SUCCESS or an error code
127 */
9462c471 128GIT_EXTERN(int) git_remote_connect(git_remote *remote, int direction);
9ba49bb5
CMN
129
130/**
131 * Get a list of refs at the remote
132 *
6616e207
CMN
133 * The remote (or more exactly its transport) must be connected. The
134 * memory belongs to the remote.
9ba49bb5
CMN
135 *
136 * @param refs where to store the refs
137 * @param remote the remote
138 * @return GIT_SUCCESS or an error code
139 */
d88d4311 140GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void *payload);
9ba49bb5 141
48a65a07
CMN
142/**
143 * Download the packfile
144 *
95057b85
CMN
145 * Negotiate what objects should be downloaded and download the
146 * packfile with those objects. The packfile is downloaded with a
147 * temporary filename, as it's final name is not known yet. If there
148 * was no packfile needed (all the objects were available locally),
149 * filename will be NULL and the function will return success.
48a65a07
CMN
150 *
151 * @param remote the remote to download from
152 * @param filename where to store the temproray filename
153 * @return GIT_SUCCESS or an error code
154 */
7a520f5d 155GIT_EXTERN(int) git_remote_download(git_remote *remote, git_off_t *bytes, git_indexer_stats *stats);
48a65a07 156
6ac3b707
CMN
157/**
158 * Check whether the remote is connected
159 *
160 * Check whether the remote's underlying transport is connected to the
161 * remote host.
162 *
163 * @return 1 if it's connected, 0 otherwise.
164 */
165GIT_EXTERN(int) git_remote_connected(git_remote *remote);
166
4cf01e9a
CMN
167/**
168 * Disconnect from the remote
169 *
170 * Close the connection to the remote and free the underlying
171 * transport.
172 *
173 * @param remote the remote to disconnect from
174 */
175GIT_EXTERN(void) git_remote_disconnect(git_remote *remote);
176
9c82357b
CMN
177/**
178 * Free the memory associated with a remote
179 *
8af503bc
MS
180 * This also disconnects from the remote, if the connection
181 * has not been closed yet (using git_remote_disconnect).
182 *
9c82357b
CMN
183 * @param remote the remote to free
184 */
9462c471 185GIT_EXTERN(void) git_remote_free(git_remote *remote);
9c82357b 186
441f57c2
CMN
187/**
188 * Update the tips to the new state
189 *
441f57c2 190 * @param remote the remote to update
f184836b 191 * @param cb callback to run on each ref update. 'a' is the old value, 'b' is then new value
441f57c2 192 */
f184836b 193GIT_EXTERN(int) git_remote_update_tips(git_remote *remote, int (*cb)(const char *refname, const git_oid *a, const git_oid *b));
441f57c2 194
d88d4311
VM
195/**
196 * Return whether a string is a valid remote URL
197 *
198 * @param tranport the url to check
199 * @param 1 if the url is valid, 0 otherwise
200 */
201GIT_EXTERN(int) git_remote_valid_url(const char *url);
202
4f8efc97
CMN
203/**
204 * Return whether the passed URL is supported by this version of the library.
205 *
206 * @param url the url to check
207 * @return 1 if the url is supported, 0 otherwise
208*/
209GIT_EXTERN(int) git_remote_supported_url(const char* url);
210
8171998f
CMN
211/**
212 * Get a list of the configured remotes for a repo
213 *
214 * The string array must be freed by the user.
215 *
216 * @param remotes_list a string array with the names of the remotes
217 * @param repo the repository to query
218 * @return GIT_SUCCESS or an error code
219 */
220GIT_EXTERN(int) git_remote_list(git_strarray *remotes_list, git_repository *repo);
221
a209a025
CMN
222/**
223 * Add a remote with the default fetch refspec to the repository's configuration
224 *
225 * @param out the resulting remote
226 * @param repo the repository in which to create the remote
227 * @param name the remote's name
228 * @param url the remote's url
229 */
230GIT_EXTERN(int) git_remote_add(git_remote **out, git_repository *repo, const char *name, const char *url);
231
1e76676f 232/** @} */
bdd18829 233GIT_END_DECL
9c82357b 234#endif