* Create and return a list of (struct ref) consisting of copies of * each remote_ref that matches refspec. refspec must be a pattern. * Fill in the copies' peer_ref to describe the local tracking refs to * which they map. Omit any references that would map to an existing * local symbolic ref. */
| 1995 | * local symbolic ref. |
| 1996 | */ |
| 1997 | static struct ref *get_expanded_map(const struct ref *remote_refs, |
| 1998 | const struct refspec_item *refspec) |
| 1999 | { |
| 2000 | struct strbuf scratch = STRBUF_INIT; |
| 2001 | const struct ref *ref; |
| 2002 | struct ref *ret = NULL; |
| 2003 | struct ref **tail = &ret; |
| 2004 | |
| 2005 | for (ref = remote_refs; ref; ref = ref->next) { |
| 2006 | char *expn_name = NULL; |
| 2007 | |
| 2008 | strbuf_reset(&scratch); |
| 2009 | |
| 2010 | if (strchr(ref->name, '^')) |
| 2011 | continue; /* a dereference item */ |
| 2012 | if (match_refname_with_pattern(refspec->src, ref->name, |
| 2013 | refspec->dst, &expn_name) && |
| 2014 | !ignore_symref_update(expn_name, &scratch)) { |
| 2015 | struct ref *cpy = copy_ref(ref); |
| 2016 | |
| 2017 | if (cpy->peer_ref) |
| 2018 | free_one_ref(cpy->peer_ref); |
| 2019 | cpy->peer_ref = alloc_ref(expn_name); |
| 2020 | if (refspec->force) |
| 2021 | cpy->peer_ref->force = 1; |
| 2022 | *tail = cpy; |
| 2023 | tail = &cpy->next; |
| 2024 | } |
| 2025 | free(expn_name); |
| 2026 | } |
| 2027 | |
| 2028 | strbuf_release(&scratch); |
| 2029 | return ret; |
| 2030 | } |
| 2031 | |
| 2032 | static const struct ref *find_ref_by_name_abbrev(const struct ref *refs, const char *name) |
| 2033 | { |
no test coverage detected