Skip to content

Commit d27eb35

Browse files
HebaWalygitster
authored andcommitted
remote: move doc to remote.h and refspec.h
Move the documentation from Documentation/technical/api-remote.txt to remote.h and refspec.h as it's easier for the developers to find the usage information beside the code instead of looking for it in another doc file. N.B. The doc for both push and fetch members of the remote struct aren't moved because they are out of date, as the members were changed from arrays of rspecs to struct refspec 2 years ago. Also documentation/technical/api-remote.txt is removed because the information it has is now redundant and it'll be hard to keep it up to date and synchronized with the documentation in the header file. Signed-off-by: Heba Waly <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 405c6b1 commit d27eb35

File tree

3 files changed

+70
-130
lines changed

3 files changed

+70
-130
lines changed

Documentation/technical/api-remote.txt

Lines changed: 0 additions & 127 deletions
This file was deleted.

refspec.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@ struct refspec_item {
2020
#define REFSPEC_INIT_FETCH { .fetch = REFSPEC_FETCH }
2121
#define REFSPEC_INIT_PUSH { .fetch = REFSPEC_PUSH }
2222
23+
/**
24+
* A struct refspec holds the parsed interpretation of a refspec. If it will
25+
* force updates (starts with a '+'), force is true. If it is a pattern
26+
* (sides end with '*') pattern is true. src and dest are the two sides
27+
* (including '*' characters if present); if there is only one side, it is src,
28+
* and dst is NULL; if sides exist but are empty (i.e., the refspec either
29+
* starts or ends with ':'), the corresponding side is "".
30+
*
31+
* An array of strings can be parsed into an array of struct refspecs using
32+
* parse_fetch_refspec() or parse_push_refspec().
33+
*
34+
* remote_find_tracking(), given a remote and a struct refspec with either src
35+
* or dst filled out, will fill out the other such that the result is in the
36+
* "fetch" specification for the remote (note that this evaluates patterns and
37+
* returns a single result).
38+
*/
2339
struct refspec {
2440
struct refspec_item *items;
2541
int alloc;

remote.h

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
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+
917
enum {
1018
REMOTE_UNCONFIGURED = 0,
1119
REMOTE_CONFIG,
@@ -16,16 +24,22 @@ enum {
1624
struct 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+
*/
5884
struct remote *remote_get(const char *name);
85+
5986
struct remote *pushremote_get(const char *name);
6087
int remote_is_configured(struct remote *remote, int in_repo);
6188

6289
typedef int each_remote_fn(struct remote *remote, void *priv);
90+
91+
/* iterate through struct remotes */
6392
int for_each_remote(each_remote_fn fn, void *priv);
6493

6594
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);
194223
*/
195224
int 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+
*/
197230
struct 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);
215264
const 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. */
218268
int branch_has_merge_config(struct branch *branch);
269+
219270
int branch_merge_matches(struct branch *, int n, const char *);
220271

221272
/**

0 commit comments

Comments
 (0)