git repack: keep commits hidden by a graft
[git/dscho.git] / remote.h
blob86b18dc091f0e3b21bcb1bbdce2f0fb5fe4c89fc
1 #ifndef REMOTE_H
2 #define REMOTE_H
4 enum {
5 REMOTE_CONFIG,
6 REMOTE_REMOTES,
7 REMOTE_BRANCHES
8 };
10 struct remote {
11 const char *name;
12 int origin;
14 const char **url;
15 int url_nr;
16 int url_alloc;
18 const char **pushurl;
19 int pushurl_nr;
20 int pushurl_alloc;
22 const char **push_refspec;
23 struct refspec *push;
24 int push_refspec_nr;
25 int push_refspec_alloc;
27 const char **fetch_refspec;
28 struct refspec *fetch;
29 int fetch_refspec_nr;
30 int fetch_refspec_alloc;
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
38 int fetch_tags;
39 int skip_default_update;
40 int mirror;
41 struct tracking_config track;
43 const char *receivepack;
44 const char *uploadpack;
47 * for curl remotes only
49 char *http_proxy;
52 struct remote *remote_get(const char *name);
53 int remote_is_configured(const char *name);
55 typedef int each_remote_fn(struct remote *remote, void *priv);
56 int for_each_remote(each_remote_fn fn, void *priv);
58 int remote_has_url(struct remote *remote, const char *url);
60 struct refspec {
61 unsigned force : 1;
62 unsigned pattern : 1;
63 unsigned matching : 1;
65 char *src;
66 char *dst;
69 extern const struct refspec *tag_refspec;
71 struct ref *alloc_ref(const char *name);
73 struct ref *copy_ref_list(const struct ref *ref);
75 int check_ref_type(const struct ref *ref, int flags);
78 * Frees the entire list and peers of elements.
80 void free_refs(struct ref *ref);
82 int resolve_remote_symref(struct ref *ref, struct ref *list);
83 int ref_newer(const unsigned char *new_sha1, const unsigned char *old_sha1);
86 * Removes and frees any duplicate refs in the map.
88 void ref_remove_duplicates(struct ref *ref_map);
90 int valid_fetch_refspec(const char *refspec);
91 struct refspec *parse_fetch_refspec(int nr_refspec, const char **refspec);
93 int match_refs(struct ref *src, struct ref **dst,
94 int nr_refspec, const char **refspec, int all);
97 * Given a list of the remote refs and the specification of things to
98 * fetch, makes a (separate) list of the refs to fetch and the local
99 * refs to store into.
101 * *tail is the pointer to the tail pointer of the list of results
102 * beforehand, and will be set to the tail pointer of the list of
103 * results afterward.
105 * missing_ok is usually false, but when we are adding branch.$name.merge
106 * it is Ok if the branch is not at the remote anymore.
108 int get_fetch_map(const struct ref *remote_refs, const struct refspec *refspec,
109 struct ref ***tail, int missing_ok);
111 struct ref *get_remote_ref(const struct ref *remote_refs, const char *name);
114 * For the given remote, reads the refspec's src and sets the other fields.
116 int remote_find_tracking(struct remote *remote, struct refspec *refspec);
118 struct branch {
119 const char *name;
120 const char *refname;
122 const char *remote_name;
123 struct remote *remote;
125 const char **merge_name;
126 struct refspec **merge;
127 int merge_nr;
128 int merge_alloc;
131 struct branch *branch_get(const char *name);
133 int branch_has_merge_config(struct branch *branch);
134 int branch_merge_matches(struct branch *, int n, const char *);
136 /* Flags to match_refs. */
137 enum match_refs_flags {
138 MATCH_REFS_NONE = 0,
139 MATCH_REFS_ALL = (1 << 0),
140 MATCH_REFS_MIRROR = (1 << 1),
143 /* Reporting of tracking info */
144 int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs);
145 int format_tracking_info(struct branch *branch, struct strbuf *sb);
147 struct ref *get_local_heads(void);
149 * Find refs from a list which are likely to be pointed to by the given HEAD
150 * ref. If 'all' is false, returns the most likely ref; otherwise, returns a
151 * list of all candidate refs. If no match is found (or 'head' is NULL),
152 * returns NULL. All returns are newly allocated and should be freed.
154 struct ref *guess_remote_head(const struct ref *head,
155 const struct ref *refs,
156 int all);
158 #endif