6
6
#include "hashmap.h"
7
7
#include "refspec.h"
8
8
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
+
9
17
enum {
10
18
REMOTE_UNCONFIGURED = 0 ,
11
19
REMOTE_CONFIG ,
@@ -16,16 +24,22 @@ enum {
16
24
struct remote {
17
25
struct hashmap_entry ent ;
18
26
27
+ /* The user's nickname for the remote */
19
28
const char * name ;
29
+
20
30
int origin , configured_in_repo ;
21
31
22
32
const char * foreign_vcs ;
23
33
34
+ /* An array of all of the url_nr URLs configured for the remote */
24
35
const char * * url ;
36
+
25
37
int url_nr ;
26
38
int url_alloc ;
27
39
40
+ /* An array of all of the pushurl_nr push URLs configured for the remote */
28
41
const char * * pushurl ;
42
+
29
43
int pushurl_nr ;
30
44
int pushurl_alloc ;
31
45
@@ -34,32 +48,47 @@ struct remote {
34
48
struct refspec fetch ;
35
49
36
50
/*
51
+ * The setting for whether to fetch tags (as a separate rule from the
52
+ * configured refspecs);
37
53
* -1 to never fetch tags
38
54
* 0 to auto-follow tags on heuristic (default)
39
55
* 1 to always auto-follow tags
40
56
* 2 to always fetch tags
41
57
*/
42
58
int fetch_tags ;
59
+
43
60
int skip_default_update ;
44
61
int mirror ;
45
62
int prune ;
46
63
int prune_tags ;
47
64
65
+ /**
66
+ * The configured helper programs to run on the remote side, for
67
+ * Git-native protocols.
68
+ */
48
69
const char * receivepack ;
49
70
const char * uploadpack ;
50
71
51
- /*
52
- * for curl remotes only
53
- */
72
+ /* The proxy to use for curl (http, https, ftp, etc.) URLs. */
54
73
char * http_proxy ;
74
+
75
+ /* The method used for authenticating against `http_proxy`. */
55
76
char * http_proxy_authmethod ;
56
77
};
57
78
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
+ */
58
84
struct remote * remote_get (const char * name );
85
+
59
86
struct remote * pushremote_get (const char * name );
60
87
int remote_is_configured (struct remote * remote , int in_repo );
61
88
62
89
typedef int each_remote_fn (struct remote * remote , void * priv );
90
+
91
+ /* iterate through struct remotes */
63
92
int for_each_remote (each_remote_fn fn , void * priv );
64
93
65
94
int 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);
194
223
*/
195
224
int remote_find_tracking (struct remote * remote , struct refspec_item * refspec );
196
225
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
+ */
197
230
struct branch {
231
+
232
+ /* The short name of the branch. */
198
233
const char * name ;
234
+
235
+ /* The full path for the branch ref. */
199
236
const char * refname ;
200
237
238
+ /* The name of the remote listed in the configuration. */
201
239
const char * remote_name ;
240
+
202
241
const char * pushremote_name ;
203
242
243
+ /* An array of the "merge" lines in the configuration. */
204
244
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
+ */
205
251
struct refspec_item * * merge ;
252
+
253
+ /* The number of merge configurations */
206
254
int merge_nr ;
255
+
207
256
int merge_alloc ;
208
257
209
258
const char * push_tracking_ref ;
@@ -215,7 +264,9 @@ const char *pushremote_for_branch(struct branch *branch, int *explicit);
215
264
const char * remote_ref_for_branch (struct branch * branch , int for_push ,
216
265
int * explicit );
217
266
267
+ /* returns true if the given branch has merge configuration given. */
218
268
int branch_has_merge_config (struct branch * branch );
269
+
219
270
int branch_merge_matches (struct branch * , int n , const char * );
220
271
221
272
/**
0 commit comments