MCPcopy Index your code
hub / github.com/git/git / get_fetch_map

Function get_fetch_map

remote.c:2075–2126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2073}
2074
2075int get_fetch_map(const struct ref *remote_refs,
2076 const struct refspec_item *refspec,
2077 struct ref ***tail,
2078 int missing_ok)
2079{
2080 struct ref *ref_map, **rmp;
2081
2082 if (refspec->negative)
2083 return 0;
2084
2085 if (refspec->pattern) {
2086 ref_map = get_expanded_map(remote_refs, refspec);
2087 } else {
2088 const char *name = refspec->src[0] ? refspec->src : "HEAD";
2089
2090 if (refspec->exact_sha1) {
2091 ref_map = alloc_ref(name);
2092 get_oid_hex(name, &ref_map->old_oid);
2093 ref_map->exact_oid = 1;
2094 } else {
2095 ref_map = get_remote_ref(remote_refs, name);
2096 }
2097 if (!missing_ok && !ref_map)
2098 die(_("couldn't find remote ref %s"), name);
2099 if (ref_map) {
2100 ref_map->peer_ref = get_local_ref(refspec->dst);
2101 if (ref_map->peer_ref && refspec->force)
2102 ref_map->peer_ref->force = 1;
2103 }
2104 }
2105
2106 for (rmp = &ref_map; *rmp; ) {
2107 if ((*rmp)->peer_ref) {
2108 if (!starts_with((*rmp)->peer_ref->name, "refs/") ||
2109 check_refname_format((*rmp)->peer_ref->name, 0)) {
2110 struct ref *ignore = *rmp;
2111 error(_("* Ignoring funny ref '%s' locally"),
2112 (*rmp)->peer_ref->name);
2113 *rmp = (*rmp)->next;
2114 free(ignore->peer_ref);
2115 free(ignore);
2116 continue;
2117 }
2118 }
2119 rmp = &((*rmp)->next);
2120 }
2121
2122 if (ref_map)
2123 tail_link_ref(ref_map, tail);
2124
2125 return 0;
2126}
2127
2128int get_remote_group(const char *key, const char *value,
2129 const struct config_context *ctx UNUSED,

Callers 6

add_merge_configFunction · 0.85
get_ref_mapFunction · 0.85
set_headFunction · 0.85
wanted_peer_refsFunction · 0.85
get_ref_statesFunction · 0.85
get_head_namesFunction · 0.85

Calls 10

get_expanded_mapFunction · 0.85
alloc_refFunction · 0.85
get_oid_hexFunction · 0.85
get_remote_refFunction · 0.85
get_local_refFunction · 0.85
starts_withFunction · 0.85
check_refname_formatFunction · 0.85
errorFunction · 0.85
tail_link_refFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected