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

Function add_cruft_object_entry

builtin/pack-objects.c:4134–4186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4132}
4133
4134static void add_cruft_object_entry(const struct object_id *oid, enum object_type type,
4135 struct packed_git *pack, off_t offset,
4136 const char *name, uint32_t mtime)
4137{
4138 struct object_entry *entry;
4139
4140 display_progress(progress_state, ++nr_seen);
4141
4142 entry = packlist_find(&to_pack, oid);
4143 if (entry) {
4144 if (name) {
4145 entry->hash = pack_name_hash_fn(name);
4146 entry->no_try_delta = no_try_delta(name);
4147 }
4148 } else {
4149 if (!want_object_in_pack_mtime(oid, 0, &pack, &offset, mtime))
4150 return;
4151 if (!pack && type == OBJ_BLOB) {
4152 struct odb_source *source = the_repository->objects->sources;
4153 int found = 0;
4154
4155 for (; !found && source; source = source->next) {
4156 struct odb_source_files *files = odb_source_files_downcast(source);
4157 if (!odb_source_read_object_info(&files->loose->base, oid, NULL, 0))
4158 found = 1;
4159 }
4160
4161 /*
4162 * If a traversed tree has a missing blob then we want
4163 * to avoid adding that missing object to our pack.
4164 *
4165 * This only applies to missing blobs, not trees,
4166 * because the traversal needs to parse sub-trees but
4167 * not blobs.
4168 *
4169 * Note we only perform this check when we couldn't
4170 * already find the object in a pack, so we're really
4171 * limited to "ensure non-tip blobs which don't exist in
4172 * packs do exist via loose objects". Confused?
4173 */
4174 if (!found)
4175 return;
4176 }
4177
4178 entry = create_object_entry(oid, type, pack_name_hash_fn(name),
4179 0, name && no_try_delta(name),
4180 pack, offset);
4181 }
4182
4183 if (mtime > oe_cruft_mtime(&to_pack, entry))
4184 oe_set_cruft_mtime(&to_pack, entry, mtime);
4185 return;
4186}
4187
4188static void show_cruft_object(struct object *obj, const char *name, void *data UNUSED)
4189{

Callers 4

show_cruft_objectFunction · 0.85
set_cruft_mtimeFunction · 0.85
add_loose_objectFunction · 0.85

Calls 10

display_progressFunction · 0.85
packlist_findFunction · 0.85
pack_name_hash_fnFunction · 0.85
no_try_deltaFunction · 0.85
create_object_entryFunction · 0.85
oe_cruft_mtimeFunction · 0.85
oe_set_cruft_mtimeFunction · 0.85

Tested by

no test coverage detected