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

Function should_pack_ref

refs/files-backend.c:1367–1394  ·  view source on GitHub ↗

* Return true if the specified reference should be packed. */

Source from the content-addressed store, hash-verified

1365 * Return true if the specified reference should be packed.
1366 */
1367static int should_pack_ref(struct files_ref_store *refs,
1368 const struct reference *ref,
1369 struct refs_optimize_opts *opts)
1370{
1371 struct string_list_item *item;
1372
1373 /* Do not pack per-worktree refs: */
1374 if (parse_worktree_ref(ref->name, NULL, NULL, NULL) !=
1375 REF_WORKTREE_SHARED)
1376 return 0;
1377
1378 /* Do not pack symbolic refs: */
1379 if (ref->flags & REF_ISSYMREF)
1380 return 0;
1381
1382 /* Do not pack broken refs: */
1383 if (!ref_resolves_to_object(ref->name, refs->base.repo, ref->oid, ref->flags))
1384 return 0;
1385
1386 if (ref_excluded(opts->exclusions, ref->name))
1387 return 0;
1388
1389 for_each_string_list_item(item, opts->includes)
1390 if (!wildmatch(item->string, ref->name, 0))
1391 return 1;
1392
1393 return 0;
1394}
1395
1396static int should_pack_refs(struct files_ref_store *refs,
1397 struct refs_optimize_opts *opts)

Callers 2

should_pack_refsFunction · 0.85
files_optimizeFunction · 0.85

Calls 4

parse_worktree_refFunction · 0.85
ref_resolves_to_objectFunction · 0.85
ref_excludedFunction · 0.85
wildmatchFunction · 0.85

Tested by

no test coverage detected