1#ifndef REMOTE_H
2#define REMOTE_H
34
enum {
5REMOTE_CONFIG,
6REMOTE_REMOTES,
7REMOTE_BRANCHES
8};
910
struct remote {
11const char *name;
12int origin;
1314
const char **url;
15int url_nr;
16int url_alloc;
1718
const char **push_refspec;
19struct refspec *push;
20int push_refspec_nr;
21int push_refspec_alloc;
2223
const char **fetch_refspec;
24struct refspec *fetch;
25int fetch_refspec_nr;
26int fetch_refspec_alloc;
2728
/*
29* -1 to never fetch tags
30* 0 to auto-follow tags on heuristic (default)
31* 1 to always auto-follow tags
32* 2 to always fetch tags
33*/
34int fetch_tags;
35int skip_default_update;
36int mirror;
3738
const char *receivepack;
39const char *uploadpack;
4041
/*
42* for curl remotes only
43*/
44char *http_proxy;
45};
4647
struct remote *remote_get(const char *name);
4849
typedef int each_remote_fn(struct remote *remote, void *priv);
50int for_each_remote(each_remote_fn fn, void *priv);
5152
int remote_has_url(struct remote *remote, const char *url);
5354
struct refspec {
55unsigned force : 1;
56unsigned pattern : 1;
57unsigned matching : 1;
5859
char *src;
60char *dst;
61};
6263
extern const struct refspec *tag_refspec;
6465
struct ref *alloc_ref(const char *name);
6667
struct ref *copy_ref_list(const struct ref *ref);
6869
int check_ref_type(const struct ref *ref, int flags);
7071
/*
72* Frees the entire list and peers of elements.
73*/
74void free_refs(struct ref *ref);
7576
int resolve_remote_symref(struct ref *ref, struct ref *list);
7778
/*
79* Removes and frees any duplicate refs in the map.
80*/
81void ref_remove_duplicates(struct ref *ref_map);
8283
int valid_fetch_refspec(const char *refspec);
84struct refspec *parse_fetch_refspec(int nr_refspec, const char **refspec);
8586
int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
87int nr_refspec, const char **refspec, int all);
8889
/*
90* Given a list of the remote refs and the specification of things to
91* fetch, makes a (separate) list of the refs to fetch and the local
92* refs to store into.
93*
94* *tail is the pointer to the tail pointer of the list of results
95* beforehand, and will be set to the tail pointer of the list of
96* results afterward.
97*
98* missing_ok is usually false, but when we are adding branch.$name.merge
99* it is Ok if the branch is not at the remote anymore.
100*/
101int get_fetch_map(const struct ref *remote_refs, const struct refspec *refspec,
102struct ref ***tail, int missing_ok);
103104
struct ref *get_remote_ref(const struct ref *remote_refs, const char *name);
105106
/*
107* For the given remote, reads the refspec's src and sets the other fields.
108*/
109int remote_find_tracking(struct remote *remote, struct refspec *refspec);
110111
struct branch {
112const char *name;
113const char *refname;
114115
const char *remote_name;
116struct remote *remote;
117118
const char **merge_name;
119struct refspec **merge;
120int merge_nr;
121int merge_alloc;
122};
123124
struct branch *branch_get(const char *name);
125126
int branch_has_merge_config(struct branch *branch);
127int branch_merge_matches(struct branch *, int n, const char *);
128129
/* Flags to match_refs. */
130enum match_refs_flags {
131MATCH_REFS_NONE = 0,
132MATCH_REFS_ALL = (1 << 0),
133MATCH_REFS_MIRROR = (1 << 1),
134};
135136
/* Reporting of tracking info */
137int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs);
138int format_tracking_info(struct branch *branch, struct strbuf *sb);
139140
#endif