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

Function packed_ref_iterator_begin

refs/packed-backend.c:1156–1198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1154}
1155
1156static struct ref_iterator *packed_ref_iterator_begin(
1157 struct ref_store *ref_store,
1158 const char *prefix, const char **exclude_patterns,
1159 unsigned int flags)
1160{
1161 struct packed_ref_store *refs;
1162 struct snapshot *snapshot;
1163 struct packed_ref_iterator *iter;
1164 struct ref_iterator *ref_iterator;
1165 unsigned int required_flags = REF_STORE_READ;
1166
1167 if (!(flags & REFS_FOR_EACH_INCLUDE_BROKEN))
1168 required_flags |= REF_STORE_ODB;
1169 refs = packed_downcast(ref_store, required_flags, "ref_iterator_begin");
1170
1171 /*
1172 * Note that `get_snapshot()` internally checks whether the
1173 * snapshot is up to date with what is on disk, and re-reads
1174 * it if not.
1175 */
1176 snapshot = get_snapshot(refs);
1177
1178 CALLOC_ARRAY(iter, 1);
1179 ref_iterator = &iter->base;
1180 base_ref_iterator_init(ref_iterator, &packed_ref_iterator_vtable);
1181
1182 if (exclude_patterns)
1183 populate_excluded_jump_list(iter, snapshot, exclude_patterns);
1184
1185 iter->snapshot = snapshot;
1186 acquire_snapshot(snapshot);
1187 strbuf_init(&iter->refname_buf, 0);
1188 iter->repo = ref_store->repo;
1189 iter->flags = flags;
1190
1191 if (packed_ref_iterator_seek(&iter->base, prefix,
1192 REF_ITERATOR_SEEK_SET_PREFIX) < 0) {
1193 ref_iterator_free(&iter->base);
1194 return NULL;
1195 }
1196
1197 return ref_iterator;
1198}
1199
1200/*
1201 * Write an entry to the packed-refs file for the specified refname.

Callers 1

write_with_updatesFunction · 0.85

Calls 8

packed_downcastFunction · 0.85
get_snapshotFunction · 0.85
base_ref_iterator_initFunction · 0.85
acquire_snapshotFunction · 0.85
strbuf_initFunction · 0.85
packed_ref_iterator_seekFunction · 0.85
ref_iterator_freeFunction · 0.85

Tested by

no test coverage detected