MCPcopy Create free account
hub / github.com/git/git / get_stale_heads_cb

Function get_stale_heads_cb

remote.c:2552–2587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2550};
2551
2552static int get_stale_heads_cb(const struct reference *ref, void *cb_data)
2553{
2554 struct stale_heads_info *info = cb_data;
2555 struct string_list matches = STRING_LIST_INIT_DUP;
2556 struct refspec_item query;
2557 int i, stale = 1;
2558 memset(&query, 0, sizeof(struct refspec_item));
2559 query.dst = (char *)ref->name;
2560
2561 refspec_find_all_matches(info->rs, &query, &matches);
2562 if (matches.nr == 0)
2563 goto clean_exit; /* No matches */
2564
2565 /*
2566 * If we did find a suitable refspec and it's not a symref and
2567 * it's not in the list of refs that currently exist in that
2568 * remote, we consider it to be stale. In order to deal with
2569 * overlapping refspecs, we need to go over all of the
2570 * matching refs.
2571 */
2572 if (ref->flags & REF_ISSYMREF)
2573 goto clean_exit;
2574
2575 for (i = 0; stale && i < matches.nr; i++)
2576 if (string_list_has_string(info->ref_names, matches.items[i].string))
2577 stale = 0;
2578
2579 if (stale) {
2580 struct ref *linked_ref = make_linked_ref(ref->name, &info->stale_refs_tail);
2581 oidcpy(&linked_ref->new_oid, ref->oid);
2582 }
2583
2584clean_exit:
2585 string_list_clear(&matches, 0);
2586 return 0;
2587}
2588
2589struct ref *get_stale_heads(struct refspec *rs, struct ref *fetch_map)
2590{

Callers

nothing calls this directly

Calls 5

refspec_find_all_matchesFunction · 0.85
string_list_has_stringFunction · 0.85
make_linked_refFunction · 0.85
oidcpyFunction · 0.85
string_list_clearFunction · 0.85

Tested by

no test coverage detected