66#include "hashmap.h"
77#include "refspec.h"
88
9+ /**
10+ * The API gives access to the configuration related to remotes. It handles
11+ * all three configuration mechanisms historically and currently used by Git,
12+ * and presents the information in a uniform fashion. Note that the code also
13+ * handles plain URLs without any configuration, giving them just the default
14+ * information.
15+ */
16+
917enum {
1018 REMOTE_UNCONFIGURED = 0 ,
1119 REMOTE_CONFIG ,
@@ -16,16 +24,22 @@ enum {
1624struct remote {
1725 struct hashmap_entry ent ;
1826
27+ /* The user's nickname for the remote */
1928 const char * name ;
29+
2030 int origin , configured_in_repo ;
2131
2232 const char * foreign_vcs ;
2333
34+ /* An array of all of the url_nr URLs configured for the remote */
2435 const char * * url ;
36+
2537 int url_nr ;
2638 int url_alloc ;
2739
40+ /* An array of all of the pushurl_nr push URLs configured for the remote */
2841 const char * * pushurl ;
42+
2943 int pushurl_nr ;
3044 int pushurl_alloc ;
3145
@@ -34,32 +48,47 @@ struct remote {
3448 struct refspec fetch ;
3549
3650 /*
51+ * The setting for whether to fetch tags (as a separate rule from the
52+ * configured refspecs);
3753 * -1 to never fetch tags
3854 * 0 to auto-follow tags on heuristic (default)
3955 * 1 to always auto-follow tags
4056 * 2 to always fetch tags
4157 */
4258 int fetch_tags ;
59+
4360 int skip_default_update ;
4461 int mirror ;
4562 int prune ;
4663 int prune_tags ;
4764
65+ /**
66+ * The configured helper programs to run on the remote side, for
67+ * Git-native protocols.
68+ */
4869 const char * receivepack ;
4970 const char * uploadpack ;
5071
51- /*
52- * for curl remotes only
53- */
72+ /* The proxy to use for curl (http, https, ftp, etc.) URLs. */
5473 char * http_proxy ;
74+
75+ /* The method used for authenticating against `http_proxy`. */
5576 char * http_proxy_authmethod ;
5677};
5778
79+ /**
80+ * struct remotes can be found by name with remote_get().
81+ * remote_get(NULL) will return the default remote, given the current branch
82+ * and configuration.
83+ */
5884struct remote * remote_get (const char * name );
85+
5986struct remote * pushremote_get (const char * name );
6087int remote_is_configured (struct remote * remote , int in_repo );
6188
6289typedef int each_remote_fn (struct remote * remote , void * priv );
90+
91+ /* iterate through struct remotes */
6392int for_each_remote (each_remote_fn fn , void * priv );
6493
6594int remote_has_url (struct remote * remote , const char * url );
@@ -194,16 +223,36 @@ struct ref *get_remote_ref(const struct ref *remote_refs, const char *name);
194223 */
195224int remote_find_tracking (struct remote * remote , struct refspec_item * refspec );
196225
226+ /**
227+ * struct branch holds the configuration for a branch. It can be looked up with
228+ * branch_get(name) for "refs/heads/{name}", or with branch_get(NULL) for HEAD.
229+ */
197230struct branch {
231+
232+ /* The short name of the branch. */
198233 const char * name ;
234+
235+ /* The full path for the branch ref. */
199236 const char * refname ;
200237
238+ /* The name of the remote listed in the configuration. */
201239 const char * remote_name ;
240+
202241 const char * pushremote_name ;
203242
243+ /* An array of the "merge" lines in the configuration. */
204244 const char * * merge_name ;
245+
246+ /**
247+ * An array of the struct refspecs used for the merge lines. That is,
248+ * merge[i]->dst is a local tracking ref which should be merged into this
249+ * branch by default.
250+ */
205251 struct refspec_item * * merge ;
252+
253+ /* The number of merge configurations */
206254 int merge_nr ;
255+
207256 int merge_alloc ;
208257
209258 const char * push_tracking_ref ;
@@ -215,7 +264,9 @@ const char *pushremote_for_branch(struct branch *branch, int *explicit);
215264const char * remote_ref_for_branch (struct branch * branch , int for_push ,
216265 int * explicit );
217266
267+ /* returns true if the given branch has merge configuration given. */
218268int branch_has_merge_config (struct branch * branch );
269+
219270int branch_merge_matches (struct branch * , int n , const char * );
220271
221272/**
0 commit comments