1678
}
1679
1680
struct stale_heads_info {
1681
- struct remote *remote;
1681
struct string_list *ref_names;
1682
struct ref **stale_refs_tail;
1683
+ struct refspec *refs;
1684
+ int ref_count;
1685
};
1686
1687
static int get_stale_heads_cb(const char *refname,
1688
const unsigned char *sha1, int flags, void *cb_data)
1689
{
1690
struct stale_heads_info *info = cb_data;
1690
- struct refspec refspec;
1691
- memset(&refspec, 0, sizeof(refspec));
1692
- refspec.dst = (char *)refname;
1693
- if (!remote_find_tracking(info->remote, &refspec)) {
1694
- if (!((flags & REF_ISSYMREF) ||
1695
- string_list_has_string(info->ref_names, refspec.src))) {
1696
- struct ref *ref = make_linked_ref(refname, &info->stale_refs_tail);
1697
- hashcpy(ref->new_sha1, sha1);
1698
- }
1691
+ struct refspec query;
1692
+ memset(&query, 0, sizeof(struct refspec));
1693
+ query.dst = (char *)refname;
1694
+
1695
+ if (query_refspecs(info->refs, info->ref_count, &query))
1696
+ return 0; /* No matches */
1697
+
1698
+ /*
1699
+ * If we did find a suitable refspec and it's not a symref and
1700
+ * it's not in the list of refs that currently exist in that
1701
+ * remote we consider it to be stale.
1702
+ */
1703
+ if (!((flags & REF_ISSYMREF) ||
1704
+ string_list_has_string(info->ref_names, query.src))) {
1705
+ struct ref *ref = make_linked_ref(refname, &info->stale_refs_tail);
1706
+ hashcpy(ref->new_sha1, sha1);
1707
}
1708
+
1709
+ free(query.src);
1710
return 0;
1711
}
1712
1703
-struct ref *get_stale_heads(struct remote *remote, struct ref *fetch_map)
1713
+struct ref *get_stale_heads(struct refspec *refs, int ref_count, struct ref *fetch_map)
1714
{
1715
struct ref *ref, *stale_refs = NULL;
1716
struct string_list ref_names = STRING_LIST_INIT_NODUP;
1717
struct stale_heads_info info;
1708
- info.remote = remote;
1718
info.ref_names = &ref_names;
1719
info.stale_refs_tail = &stale_refs;
1720
+ info.refs = refs;
1721
+ info.ref_count = ref_count;
1722
for (ref = fetch_map; ref; ref = ref->next)
1723
string_list_append(&ref_names, ref->name);
1724
sort_string_list(&ref_names);