1#ifndef REMOTE_H 2#define REMOTE_H 3 4enum{ 5 REMOTE_CONFIG, 6 REMOTE_REMOTES, 7 REMOTE_BRANCHES 8}; 9 10struct remote { 11const char*name; 12int origin; 13 14const char**url; 15int url_nr; 16int url_alloc; 17 18const char**pushurl; 19int pushurl_nr; 20int pushurl_alloc; 21 22const char**push_refspec; 23struct refspec *push; 24int push_refspec_nr; 25int push_refspec_alloc; 26 27const char**fetch_refspec; 28struct refspec *fetch; 29int fetch_refspec_nr; 30int 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 */ 38int fetch_tags; 39int skip_default_update; 40int mirror; 41 42const char*receivepack; 43const char*uploadpack; 44 45/* 46 * for curl remotes only 47 */ 48char*http_proxy; 49}; 50 51struct remote *remote_get(const char*name); 52intremote_is_configured(const char*name); 53 54typedefinteach_remote_fn(struct remote *remote,void*priv); 55intfor_each_remote(each_remote_fn fn,void*priv); 56 57intremote_has_url(struct remote *remote,const char*url); 58 59struct refspec { 60unsigned force :1; 61unsigned pattern :1; 62unsigned matching :1; 63 64char*src; 65char*dst; 66}; 67 68externconst struct refspec *tag_refspec; 69 70struct ref *alloc_ref(const char*name); 71 72struct ref *copy_ref_list(const struct ref *ref); 73 74intcheck_ref_type(const struct ref *ref,int flags); 75 76/* 77 * Frees the entire list and peers of elements. 78 */ 79voidfree_refs(struct ref *ref); 80 81intresolve_remote_symref(struct ref *ref,struct ref *list); 82intref_newer(const unsigned char*new_sha1,const unsigned char*old_sha1); 83 84/* 85 * Removes and frees any duplicate refs in the map. 86 */ 87voidref_remove_duplicates(struct ref *ref_map); 88 89intvalid_fetch_refspec(const char*refspec); 90struct refspec *parse_fetch_refspec(int nr_refspec,const char**refspec); 91 92intmatch_refs(struct ref *src,struct ref **dst, 93int 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 */ 107intget_fetch_map(const struct ref *remote_refs,const struct refspec *refspec, 108struct 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 */ 115intremote_find_tracking(struct remote *remote,struct refspec *refspec); 116 117struct branch { 118const char*name; 119const char*refname; 120 121const char*remote_name; 122struct remote *remote; 123 124const char**merge_name; 125struct refspec **merge; 126int merge_nr; 127int merge_alloc; 128}; 129 130struct branch *branch_get(const char*name); 131 132intbranch_has_merge_config(struct branch *branch); 133intbranch_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 */ 143intstat_tracking_info(struct branch *branch,int*num_ours,int*num_theirs); 144intformat_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, 154const struct ref *refs, 155int all); 156 157/* Return refs which no longer exist on remote */ 158struct ref *get_stale_heads(struct remote *remote,struct ref *fetch_map); 159 160#endif