]> git.ipfire.org Git - thirdparty/git.git/blame_incremental - remote.h
Add missing test for 'git remote update --prune'
[thirdparty/git.git] / remote.h
... / ...
CommitLineData
1#ifndef REMOTE_H
2#define REMOTE_H
3
4enum {
5 REMOTE_CONFIG,
6 REMOTE_REMOTES,
7 REMOTE_BRANCHES
8};
9
10struct remote {
11 const char *name;
12 int origin;
13
14 const char **url;
15 int url_nr;
16 int url_alloc;
17
18 const char **pushurl;
19 int pushurl_nr;
20 int pushurl_alloc;
21
22 const char **push_refspec;
23 struct refspec *push;
24 int push_refspec_nr;
25 int push_refspec_alloc;
26
27 const char **fetch_refspec;
28 struct refspec *fetch;
29 int fetch_refspec_nr;
30 int fetch_refspec_alloc;
31
32 /*
33 * -1 to never fetch tags
34 * 0 to auto-follow tags on heuristic (default)
35 * 1 to always auto-follow tags
36 * 2 to always fetch tags
37 */
38 int fetch_tags;
39 int skip_default_update;
40 int mirror;
41
42 const char *receivepack;
43 const char *uploadpack;
44
45 /*
46 * for curl remotes only
47 */
48 char *http_proxy;
49};
50
51struct remote *remote_get(const char *name);
52int remote_is_configured(const char *name);
53
54typedef int each_remote_fn(struct remote *remote, void *priv);
55int for_each_remote(each_remote_fn fn, void *priv);
56
57int remote_has_url(struct remote *remote, const char *url);
58
59struct refspec {
60 unsigned force : 1;
61 unsigned pattern : 1;
62 unsigned matching : 1;
63
64 char *src;
65 char *dst;
66};
67
68extern const struct refspec *tag_refspec;
69
70struct ref *alloc_ref(const char *name);
71
72struct ref *copy_ref_list(const struct ref *ref);
73
74int check_ref_type(const struct ref *ref, int flags);
75
76/*
77 * Frees the entire list and peers of elements.
78 */
79void free_refs(struct ref *ref);
80
81int resolve_remote_symref(struct ref *ref, struct ref *list);
82int ref_newer(const unsigned char *new_sha1, const unsigned char *old_sha1);
83
84/*
85 * Removes and frees any duplicate refs in the map.
86 */
87void ref_remove_duplicates(struct ref *ref_map);
88
89int valid_fetch_refspec(const char *refspec);
90struct refspec *parse_fetch_refspec(int nr_refspec, const char **refspec);
91
92int match_refs(struct ref *src, struct ref **dst,
93 int nr_refspec, const char **refspec, int all);
94
95/*
96 * Given a list of the remote refs and the specification of things to
97 * fetch, makes a (separate) list of the refs to fetch and the local
98 * refs to store into.
99 *
100 * *tail is the pointer to the tail pointer of the list of results
101 * beforehand, and will be set to the tail pointer of the list of
102 * results afterward.
103 *
104 * missing_ok is usually false, but when we are adding branch.$name.merge
105 * it is Ok if the branch is not at the remote anymore.
106 */
107int get_fetch_map(const struct ref *remote_refs, const struct refspec *refspec,
108 struct ref ***tail, int missing_ok);
109
110struct ref *get_remote_ref(const struct ref *remote_refs, const char *name);
111
112/*
113 * For the given remote, reads the refspec's src and sets the other fields.
114 */
115int remote_find_tracking(struct remote *remote, struct refspec *refspec);
116
117struct branch {
118 const char *name;
119 const char *refname;
120
121 const char *remote_name;
122 struct remote *remote;
123
124 const char **merge_name;
125 struct refspec **merge;
126 int merge_nr;
127 int merge_alloc;
128};
129
130struct branch *branch_get(const char *name);
131
132int branch_has_merge_config(struct branch *branch);
133int branch_merge_matches(struct branch *, int n, const char *);
134
135/* Flags to match_refs. */
136enum match_refs_flags {
137 MATCH_REFS_NONE = 0,
138 MATCH_REFS_ALL = (1 << 0),
139 MATCH_REFS_MIRROR = (1 << 1),
140};
141
142/* Reporting of tracking info */
143int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs);
144int format_tracking_info(struct branch *branch, struct strbuf *sb);
145
146struct ref *get_local_heads(void);
147/*
148 * Find refs from a list which are likely to be pointed to by the given HEAD
149 * ref. If 'all' is false, returns the most likely ref; otherwise, returns a
150 * list of all candidate refs. If no match is found (or 'head' is NULL),
151 * returns NULL. All returns are newly allocated and should be freed.
152 */
153struct ref *guess_remote_head(const struct ref *head,
154 const struct ref *refs,
155 int all);
156
157#endif