1#ifndef REMOTE_H2#define REMOTE_H34enum {5REMOTE_CONFIG,6REMOTE_REMOTES,7REMOTE_BRANCHES8};910struct remote {11const char *name;12int origin;1314const char **url;15int url_nr;16int url_alloc;1718const char **push_refspec;19struct refspec *push;20int push_refspec_nr;21int push_refspec_alloc;2223const char **fetch_refspec;24struct refspec *fetch;25int fetch_refspec_nr;26int fetch_refspec_alloc;2728/*29* -1 to never fetch tags30* 0 to auto-follow tags on heuristic (default)31* 1 to always auto-follow tags32* 2 to always fetch tags33*/34int fetch_tags;35int skip_default_update;36int mirror;3738const char *receivepack;39const char *uploadpack;4041/*42* for curl remotes only43*/44char *http_proxy;45};4647struct remote *remote_get(const char *name);4849typedef int each_remote_fn(struct remote *remote, void *priv);50int for_each_remote(each_remote_fn fn, void *priv);5152int remote_has_url(struct remote *remote, const char *url);5354struct refspec {55unsigned force : 1;56unsigned pattern : 1;57unsigned matching : 1;5859char *src;60char *dst;61};6263extern const struct refspec *tag_refspec;6465struct ref *alloc_ref(const char *name);6667struct ref *copy_ref_list(const struct ref *ref);6869int 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);7576int 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);8283int valid_fetch_refspec(const char *refspec);84struct refspec *parse_fetch_refspec(int nr_refspec, const char **refspec);8586int 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 to91* fetch, makes a (separate) list of the refs to fetch and the local92* refs to store into.93*94* *tail is the pointer to the tail pointer of the list of results95* beforehand, and will be set to the tail pointer of the list of96* results afterward.97*98* missing_ok is usually false, but when we are adding branch.$name.merge99* 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);103104struct 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);110111struct branch {112const char *name;113const char *refname;114115const char *remote_name;116struct remote *remote;117118const char **merge_name;119struct refspec **merge;120int merge_nr;121int merge_alloc;122};123124struct branch *branch_get(const char *name);125126int 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