]> git.proxmox.com Git - libgit2.git/blob - include/git2/remote.h
Update Copyright header
[libgit2.git] / include / git2 / remote.h
1 /*
2 * Copyright (C) 2009-2012 the libgit2 contributors
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
15 /**
16 * @file git2/remote.h
17 * @brief Git remote management functions
18 * @defgroup git_remote remote management functions
19 * @ingroup Git
20 * @{
21 */
22 GIT_BEGIN_DECL
23
24 /*
25 * TODO: This functions still need to be implemented:
26 * - _listcb/_foreach
27 * - _add
28 * - _rename
29 * - _del (needs support from config)
30 */
31
32 /**
33 * Create a remote in memory
34 *
35 * Create a remote with the default refspecs in memory. You can use
36 * this when you have a URL instead of a remote's name.
37 *
38 * @param out pointer to the new remote object
39 * @param repo the associtated repository
40 * @param url the remote repository's URL
41 * @param name the remote's name
42 * @return GIT_SUCCESS or an error code
43 */
44 GIT_EXTERN(int) git_remote_new(git_remote **out, git_repository *repo, const char *url, const char *name);
45
46 /**
47 * Get the information for a particular remote
48 *
49 * @param out pointer to the new remote object
50 * @param cfg the repository's configuration
51 * @param name the remote's name
52 * @return GIT_SUCCESS or an error code
53 */
54 GIT_EXTERN(int) git_remote_load(git_remote **out, git_repository *repo, const char *name);
55
56 /**
57 * Get the remote's name
58 *
59 * @param remote the remote
60 * @return a pointer to the name
61 */
62 GIT_EXTERN(const char *) git_remote_name(git_remote *remote);
63
64 /**
65 * Get the remote's url
66 *
67 * @param remote the remote
68 * @return a pointer to the url
69 */
70 GIT_EXTERN(const char *) git_remote_url(git_remote *remote);
71
72 /**
73 * Get the fetch refspec
74 *
75 * @param remote the remote
76 * @return a pointer to the fetch refspec or NULL if it doesn't exist
77 */
78 GIT_EXTERN(const git_refspec *) git_remote_fetchspec(git_remote *remote);
79
80 /**
81 * Get the push refspec
82 *
83 * @param remote the remote
84 * @return a pointer to the push refspec or NULL if it doesn't exist
85 */
86
87 GIT_EXTERN(const git_refspec *) git_remote_pushspec(git_remote *remote);
88
89 /**
90 * Open a connection to a remote
91 *
92 * The transport is selected based on the URL. The direction argument
93 * is due to a limitation of the git protocol (over TCP or SSH) which
94 * starts up a specific binary which can only do the one or the other.
95 *
96 * @param remote the remote to connect to
97 * @param direction whether you want to receive or send data
98 * @return GIT_SUCCESS or an error code
99 */
100 GIT_EXTERN(int) git_remote_connect(git_remote *remote, int direction);
101
102 /**
103 * Get a list of refs at the remote
104 *
105 * The remote (or more exactly its transport) must be connected. The
106 * memory belongs to the remote.
107 *
108 * @param refs where to store the refs
109 * @param remote the remote
110 * @return GIT_SUCCESS or an error code
111 */
112 GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void *payload);
113
114 /**
115 * Download the packfile
116 *
117 * Negotiate what objects should be downloaded and download the
118 * packfile with those objects. The packfile is downloaded with a
119 * temporary filename, as it's final name is not known yet. If there
120 * was no packfile needed (all the objects were available locally),
121 * filename will be NULL and the function will return success.
122 *
123 * @param remote the remote to download from
124 * @param filename where to store the temproray filename
125 * @return GIT_SUCCESS or an error code
126 */
127 GIT_EXTERN(int) git_remote_download(char **filename, git_remote *remote);
128
129 /**
130 * Check whether the remote is connected
131 *
132 * Check whether the remote's underlying transport is connected to the
133 * remote host.
134 *
135 * @return 1 if it's connected, 0 otherwise.
136 */
137 GIT_EXTERN(int) git_remote_connected(git_remote *remote);
138
139 /**
140 * Disconnect from the remote
141 *
142 * Close the connection to the remote and free the underlying
143 * transport.
144 *
145 * @param remote the remote to disconnect from
146 */
147 GIT_EXTERN(void) git_remote_disconnect(git_remote *remote);
148
149 /**
150 * Free the memory associated with a remote
151 *
152 * @param remote the remote to free
153 */
154 GIT_EXTERN(void) git_remote_free(git_remote *remote);
155
156 /**
157 * Update the tips to the new state
158 *
159 * Make sure that you only call this once you've successfully indexed
160 * or expanded the packfile.
161 *
162 * @param remote the remote to update
163 */
164 GIT_EXTERN(int) git_remote_update_tips(git_remote *remote);
165
166 /**
167 * Return whether a string is a valid remote URL
168 *
169 * @param tranport the url to check
170 * @param 1 if the url is valid, 0 otherwise
171 */
172 GIT_EXTERN(int) git_remote_valid_url(const char *url);
173
174 /** @} */
175 GIT_END_DECL
176 #endif