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

Function loose_fill_ref_dir_regular_file

refs/files-backend.c:267–304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265}
266
267static void loose_fill_ref_dir_regular_file(struct files_ref_store *refs,
268 const char *refname,
269 struct ref_dir *dir)
270{
271 struct object_id oid;
272 int flag;
273 const char *referent = refs_resolve_ref_unsafe(&refs->base,
274 refname,
275 RESOLVE_REF_READING,
276 &oid, &flag);
277
278 if (!referent) {
279 oidclr(&oid, refs->base.repo->hash_algo);
280 flag |= REF_ISBROKEN;
281 } else if (is_null_oid(&oid)) {
282 /*
283 * It is so astronomically unlikely
284 * that null_oid is the OID of an
285 * actual object that we consider its
286 * appearance in a loose reference
287 * file to be repo corruption
288 * (probably due to a software bug).
289 */
290 flag |= REF_ISBROKEN;
291 }
292
293 if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) {
294 if (!refname_is_safe(refname))
295 die("loose refname is dangerous: %s", refname);
296 oidclr(&oid, refs->base.repo->hash_algo);
297 flag |= REF_BAD_NAME | REF_ISBROKEN;
298 }
299
300 if (!(flag & REF_ISSYMREF))
301 referent = NULL;
302
303 add_entry_to_dir(dir, create_ref_entry(refname, referent, &oid, flag));
304}
305
306/*
307 * Read the loose references from the namespace dirname into dir

Callers 2

loose_fill_ref_dirFunction · 0.85
fill_root_refFunction · 0.85

Calls 8

refs_resolve_ref_unsafeFunction · 0.85
oidclrFunction · 0.85
is_null_oidFunction · 0.85
check_refname_formatFunction · 0.85
refname_is_safeFunction · 0.85
add_entry_to_dirFunction · 0.85
create_ref_entryFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected