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

Function update_shallow

fetch-pack.c:2049–2145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2047}
2048
2049static void update_shallow(struct fetch_pack_args *args,
2050 struct ref **sought, int nr_sought,
2051 struct shallow_info *si)
2052{
2053 struct oid_array ref = OID_ARRAY_INIT;
2054 int *status;
2055 int i;
2056
2057 if (args->deepen && alternate_shallow_file) {
2058 if (*alternate_shallow_file == '\0') { /* --unshallow */
2059 unlink_or_warn(git_path_shallow(the_repository));
2060 rollback_shallow_file(the_repository, &shallow_lock);
2061 } else
2062 commit_shallow_file(the_repository, &shallow_lock);
2063 alternate_shallow_file = NULL;
2064 return;
2065 }
2066
2067 if (!si->shallow || !si->shallow->nr)
2068 return;
2069
2070 if (args->cloning) {
2071 /*
2072 * remote is shallow, but this is a clone, there are
2073 * no objects in repo to worry about. Accept any
2074 * shallow points that exist in the pack (iow in repo
2075 * after get_pack() and odb_reprepare())
2076 */
2077 struct oid_array extra = OID_ARRAY_INIT;
2078 struct object_id *oid = si->shallow->oid;
2079 for (i = 0; i < si->shallow->nr; i++)
2080 if (odb_has_object(the_repository->objects, &oid[i],
2081 ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
2082 oid_array_append(&extra, &oid[i]);
2083 if (extra.nr) {
2084 setup_alternate_shallow(&shallow_lock,
2085 &alternate_shallow_file,
2086 &extra);
2087 commit_shallow_file(the_repository, &shallow_lock);
2088 alternate_shallow_file = NULL;
2089 }
2090 oid_array_clear(&extra);
2091 return;
2092 }
2093
2094 if (!si->nr_ours && !si->nr_theirs)
2095 return;
2096
2097 remove_nonexistent_theirs_shallow(si);
2098 if (!si->nr_ours && !si->nr_theirs)
2099 return;
2100 for (i = 0; i < nr_sought; i++)
2101 oid_array_append(&ref, &sought[i]->old_oid);
2102 si->ref = &ref;
2103
2104 if (args->update_shallow) {
2105 /*
2106 * remote is also shallow, .git/shallow may be updated

Callers 1

fetch_packFunction · 0.85

Calls 9

unlink_or_warnFunction · 0.85
rollback_shallow_fileFunction · 0.85
commit_shallow_fileFunction · 0.85
odb_has_objectFunction · 0.85
oid_array_appendFunction · 0.85
setup_alternate_shallowFunction · 0.85
oid_array_clearFunction · 0.85

Tested by

no test coverage detected