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

Function existing_packs_collect

repack.c:127–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125#define RETAIN_PACK 2
126
127void existing_packs_collect(struct existing_packs *existing,
128 const struct string_list *extra_keep)
129{
130 struct packed_git *p;
131 struct strbuf buf = STRBUF_INIT;
132
133 repo_for_each_pack(existing->repo, p) {
134 size_t i;
135 const char *base;
136
137 if (p->multi_pack_index)
138 string_list_append(&existing->midx_packs,
139 pack_basename(p));
140 if (!p->pack_local)
141 continue;
142
143 base = pack_basename(p);
144
145 for (i = 0; i < extra_keep->nr; i++)
146 if (!fspathcmp(base, extra_keep->items[i].string))
147 break;
148
149 strbuf_reset(&buf);
150 strbuf_addstr(&buf, base);
151 strbuf_strip_suffix(&buf, ".pack");
152
153 if ((extra_keep->nr > 0 && i < extra_keep->nr) || p->pack_keep)
154 string_list_append(&existing->kept_packs, buf.buf);
155 else if (p->is_cruft)
156 string_list_append(&existing->cruft_packs, buf.buf);
157 else
158 string_list_append(&existing->non_kept_packs, buf.buf);
159 }
160
161 existing->source = existing->repo->objects->sources;
162
163 string_list_sort(&existing->kept_packs);
164 string_list_sort(&existing->non_kept_packs);
165 string_list_sort(&existing->cruft_packs);
166 string_list_sort(&existing->midx_packs);
167 strbuf_release(&buf);
168}
169
170int existing_packs_has_non_kept(const struct existing_packs *existing)
171{

Callers 3

cmd_repackFunction · 0.85

Calls 6

pack_basenameFunction · 0.85
strbuf_addstrFunction · 0.85
strbuf_strip_suffixFunction · 0.85
strbuf_releaseFunction · 0.85
string_list_appendFunction · 0.70
string_list_sortFunction · 0.70

Tested by

no test coverage detected