137
string_list_append_nodup(fname_nonkept_list, fname);
138
}
139
closedir(dir);
140
+
141
+ string_list_sort(fname_kept_list);
142
}
143
144
static void remove_redundant_pack(const char *dir_name, const char *base_name)
334
return 0;
335
}
336
335
-static void init_pack_geometry(struct pack_geometry **geometry_p)
337
+static void init_pack_geometry(struct pack_geometry **geometry_p,
338
+ struct string_list *existing_kept_packs)
339
{
340
struct packed_git *p;
341
struct pack_geometry *geometry;
342
+ struct strbuf buf = STRBUF_INIT;
343
344
*geometry_p = xcalloc(1, sizeof(struct pack_geometry));
345
geometry = *geometry_p;
346
347
for (p = get_all_packs(the_repository); p; p = p->next) {
344
- if (!pack_kept_objects && p->pack_keep)
345
- continue;
348
+ if (!pack_kept_objects) {
349
+ /*
350
+ * Any pack that has its pack_keep bit set will appear
351
+ * in existing_kept_packs below, but this saves us from
352
+ * doing a more expensive check.
353
+ */
354
+ if (p->pack_keep)
355
+ continue;
356
+
357
+ /*
358
+ * The pack may be kept via the --keep-pack option;
359
+ * check 'existing_kept_packs' to determine whether to
360
+ * ignore it.
361
+ */
362
+ strbuf_reset(&buf);
363
+ strbuf_addstr(&buf, pack_basename(p));
364
+ strbuf_strip_suffix(&buf, ".pack");
365
+
366
+ if (string_list_has_string(existing_kept_packs, buf.buf))
367
+ continue;
368
+ }
369
370
ALLOC_GROW(geometry->pack,
371
geometry->pack_nr + 1,
376
}
377
378
QSORT(geometry->pack, geometry->pack_nr, geometry_cmp);
379
+ strbuf_release(&buf);
380
}
381
382
static void split_pack_geometry(struct pack_geometry *geometry, int factor)
738
strbuf_release(&path);
739
}
740
741
+ packdir = mkpathdup("%s/pack", get_object_directory());
742
+ packtmp_name = xstrfmt(".tmp-%d-pack", (int)getpid());
743
+ packtmp = mkpathdup("%s/%s", packdir, packtmp_name);
744
+
745
+ collect_pack_filenames(&existing_nonkept_packs, &existing_kept_packs,
746
+ &keep_pack_list);
747
+
748
if (geometric_factor) {
749
if (pack_everything)
750
die(_("options '%s' and '%s' cannot be used together"), "--geometric", "-A/-a");
720
- init_pack_geometry(&geometry);
751
+ init_pack_geometry(&geometry, &existing_kept_packs);
752
split_pack_geometry(geometry, geometric_factor);
753
}
754
724
- packdir = mkpathdup("%s/pack", get_object_directory());
725
- packtmp_name = xstrfmt(".tmp-%d-pack", (int)getpid());
726
- packtmp = mkpathdup("%s/%s", packdir, packtmp_name);
727
-
755
sigchain_push_common(remove_pack_on_signal);
756
757
prepare_pack_objects(&cmd, &po_args);
791
if (use_delta_islands)
792
strvec_push(&cmd.args, "--delta-islands");
793
767
- collect_pack_filenames(&existing_nonkept_packs, &existing_kept_packs,
768
- &keep_pack_list);
769
-
794
if (pack_everything & ALL_INTO_ONE) {
795
repack_promisor_objects(&po_args, &names);
796