4 #include "environment.h"
7 #include "parse-options.h"
9 #include "run-command.h"
10 #include "server-info.h"
13 #include "string-list.h"
17 #include "prune-packed.h"
18 #include "object-store-ll.h"
19 #include "promisor-remote.h"
22 #include "pack-bitmap.h"
24 #include "list-objects-filter-options.h"
26 #define ALL_INTO_ONE 1
27 #define LOOSEN_UNREACHABLE 2
33 static int pack_everything
;
34 static int delta_base_offset
= 1;
35 static int pack_kept_objects
= -1;
36 static int write_bitmaps
= -1;
37 static int use_delta_islands
;
38 static int run_update_server_info
= 1;
39 static char *packdir
, *packtmp_name
, *packtmp
;
41 static const char *const git_repack_usage
[] = {
42 N_("git repack [<options>]"),
46 static const char incremental_bitmap_conflict_error
[] = N_(
47 "Incremental repacks are incompatible with bitmap indexes. Use\n"
48 "--no-write-bitmap-index or disable the pack.writeBitmaps configuration."
51 struct pack_objects_args
{
53 const char *window_memory
;
56 unsigned long max_pack_size
;
61 struct list_objects_filter_options filter_options
;
64 static int repack_config(const char *var
, const char *value
,
65 const struct config_context
*ctx
, void *cb
)
67 struct pack_objects_args
*cruft_po_args
= cb
;
68 if (!strcmp(var
, "repack.usedeltabaseoffset")) {
69 delta_base_offset
= git_config_bool(var
, value
);
72 if (!strcmp(var
, "repack.packkeptobjects")) {
73 pack_kept_objects
= git_config_bool(var
, value
);
76 if (!strcmp(var
, "repack.writebitmaps") ||
77 !strcmp(var
, "pack.writebitmaps")) {
78 write_bitmaps
= git_config_bool(var
, value
);
81 if (!strcmp(var
, "repack.usedeltaislands")) {
82 use_delta_islands
= git_config_bool(var
, value
);
85 if (strcmp(var
, "repack.updateserverinfo") == 0) {
86 run_update_server_info
= git_config_bool(var
, value
);
89 if (!strcmp(var
, "repack.cruftwindow"))
90 return git_config_string(&cruft_po_args
->window
, var
, value
);
91 if (!strcmp(var
, "repack.cruftwindowmemory"))
92 return git_config_string(&cruft_po_args
->window_memory
, var
, value
);
93 if (!strcmp(var
, "repack.cruftdepth"))
94 return git_config_string(&cruft_po_args
->depth
, var
, value
);
95 if (!strcmp(var
, "repack.cruftthreads"))
96 return git_config_string(&cruft_po_args
->threads
, var
, value
);
97 return git_default_config(var
, value
, ctx
, cb
);
100 struct existing_packs
{
101 struct string_list kept_packs
;
102 struct string_list non_kept_packs
;
103 struct string_list cruft_packs
;
106 #define EXISTING_PACKS_INIT { \
107 .kept_packs = STRING_LIST_INIT_DUP, \
108 .non_kept_packs = STRING_LIST_INIT_DUP, \
109 .cruft_packs = STRING_LIST_INIT_DUP, \
112 static int has_existing_non_kept_packs(const struct existing_packs
*existing
)
114 return existing
->non_kept_packs
.nr
|| existing
->cruft_packs
.nr
;
117 static void pack_mark_for_deletion(struct string_list_item
*item
)
119 item
->util
= (void*)((uintptr_t)item
->util
| DELETE_PACK
);
122 static void pack_unmark_for_deletion(struct string_list_item
*item
)
124 item
->util
= (void*)((uintptr_t)item
->util
& ~DELETE_PACK
);
127 static int pack_is_marked_for_deletion(struct string_list_item
*item
)
129 return (uintptr_t)item
->util
& DELETE_PACK
;
132 static void pack_mark_retained(struct string_list_item
*item
)
134 item
->util
= (void*)((uintptr_t)item
->util
| RETAIN_PACK
);
137 static int pack_is_retained(struct string_list_item
*item
)
139 return (uintptr_t)item
->util
& RETAIN_PACK
;
142 static void mark_packs_for_deletion_1(struct string_list
*names
,
143 struct string_list
*list
)
145 struct string_list_item
*item
;
146 const int hexsz
= the_hash_algo
->hexsz
;
148 for_each_string_list_item(item
, list
) {
150 size_t len
= strlen(item
->string
);
153 sha1
= item
->string
+ len
- hexsz
;
155 if (pack_is_retained(item
)) {
156 pack_unmark_for_deletion(item
);
157 } else if (!string_list_has_string(names
, sha1
)) {
159 * Mark this pack for deletion, which ensures
160 * that this pack won't be included in a MIDX
161 * (if `--write-midx` was given) and that we
162 * will actually delete this pack (if `-d` was
165 pack_mark_for_deletion(item
);
170 static void retain_cruft_pack(struct existing_packs
*existing
,
171 struct packed_git
*cruft
)
173 struct strbuf buf
= STRBUF_INIT
;
174 struct string_list_item
*item
;
176 strbuf_addstr(&buf
, pack_basename(cruft
));
177 strbuf_strip_suffix(&buf
, ".pack");
179 item
= string_list_lookup(&existing
->cruft_packs
, buf
.buf
);
181 BUG("could not find cruft pack '%s'", pack_basename(cruft
));
183 pack_mark_retained(item
);
184 strbuf_release(&buf
);
187 static void mark_packs_for_deletion(struct existing_packs
*existing
,
188 struct string_list
*names
)
191 mark_packs_for_deletion_1(names
, &existing
->non_kept_packs
);
192 mark_packs_for_deletion_1(names
, &existing
->cruft_packs
);
195 static void remove_redundant_pack(const char *dir_name
, const char *base_name
)
197 struct strbuf buf
= STRBUF_INIT
;
198 struct multi_pack_index
*m
= get_local_multi_pack_index(the_repository
);
199 strbuf_addf(&buf
, "%s.pack", base_name
);
200 if (m
&& midx_contains_pack(m
, buf
.buf
))
201 clear_midx_file(the_repository
);
202 strbuf_insertf(&buf
, 0, "%s/", dir_name
);
203 unlink_pack_path(buf
.buf
, 1);
204 strbuf_release(&buf
);
207 static void remove_redundant_packs_1(struct string_list
*packs
)
209 struct string_list_item
*item
;
210 for_each_string_list_item(item
, packs
) {
211 if (!pack_is_marked_for_deletion(item
))
213 remove_redundant_pack(packdir
, item
->string
);
217 static void remove_redundant_existing_packs(struct existing_packs
*existing
)
219 remove_redundant_packs_1(&existing
->non_kept_packs
);
220 remove_redundant_packs_1(&existing
->cruft_packs
);
223 static void existing_packs_release(struct existing_packs
*existing
)
225 string_list_clear(&existing
->kept_packs
, 0);
226 string_list_clear(&existing
->non_kept_packs
, 0);
227 string_list_clear(&existing
->cruft_packs
, 0);
231 * Adds all packs hex strings (pack-$HASH) to either packs->non_kept
232 * or packs->kept based on whether each pack has a corresponding
233 * .keep file or not. Packs without a .keep file are not to be kept
234 * if we are going to pack everything into one file.
236 static void collect_pack_filenames(struct existing_packs
*existing
,
237 const struct string_list
*extra_keep
)
239 struct packed_git
*p
;
240 struct strbuf buf
= STRBUF_INIT
;
242 for (p
= get_all_packs(the_repository
); p
; p
= p
->next
) {
249 base
= pack_basename(p
);
251 for (i
= 0; i
< extra_keep
->nr
; i
++)
252 if (!fspathcmp(base
, extra_keep
->items
[i
].string
))
256 strbuf_addstr(&buf
, base
);
257 strbuf_strip_suffix(&buf
, ".pack");
259 if ((extra_keep
->nr
> 0 && i
< extra_keep
->nr
) || p
->pack_keep
)
260 string_list_append(&existing
->kept_packs
, buf
.buf
);
261 else if (p
->is_cruft
)
262 string_list_append(&existing
->cruft_packs
, buf
.buf
);
264 string_list_append(&existing
->non_kept_packs
, buf
.buf
);
267 string_list_sort(&existing
->kept_packs
);
268 string_list_sort(&existing
->non_kept_packs
);
269 string_list_sort(&existing
->cruft_packs
);
270 strbuf_release(&buf
);
273 static void prepare_pack_objects(struct child_process
*cmd
,
274 const struct pack_objects_args
*args
,
277 strvec_push(&cmd
->args
, "pack-objects");
279 strvec_pushf(&cmd
->args
, "--window=%s", args
->window
);
280 if (args
->window_memory
)
281 strvec_pushf(&cmd
->args
, "--window-memory=%s", args
->window_memory
);
283 strvec_pushf(&cmd
->args
, "--depth=%s", args
->depth
);
285 strvec_pushf(&cmd
->args
, "--threads=%s", args
->threads
);
286 if (args
->max_pack_size
)
287 strvec_pushf(&cmd
->args
, "--max-pack-size=%lu", args
->max_pack_size
);
288 if (args
->no_reuse_delta
)
289 strvec_pushf(&cmd
->args
, "--no-reuse-delta");
290 if (args
->no_reuse_object
)
291 strvec_pushf(&cmd
->args
, "--no-reuse-object");
293 strvec_push(&cmd
->args
, "--local");
295 strvec_push(&cmd
->args
, "--quiet");
296 if (delta_base_offset
)
297 strvec_push(&cmd
->args
, "--delta-base-offset");
298 strvec_push(&cmd
->args
, out
);
304 * Write oid to the given struct child_process's stdin, starting it first if
307 static int write_oid(const struct object_id
*oid
,
308 struct packed_git
*pack UNUSED
,
309 uint32_t pos UNUSED
, void *data
)
311 struct child_process
*cmd
= data
;
314 if (start_command(cmd
))
315 die(_("could not start pack-objects to repack promisor objects"));
318 xwrite(cmd
->in
, oid_to_hex(oid
), the_hash_algo
->hexsz
);
319 xwrite(cmd
->in
, "\n", 1);
335 struct generated_pack_data
{
336 struct tempfile
*tempfiles
[ARRAY_SIZE(exts
)];
339 static struct generated_pack_data
*populate_pack_exts(const char *name
)
342 struct strbuf path
= STRBUF_INIT
;
343 struct generated_pack_data
*data
= xcalloc(1, sizeof(*data
));
346 for (i
= 0; i
< ARRAY_SIZE(exts
); i
++) {
348 strbuf_addf(&path
, "%s-%s%s", packtmp
, name
, exts
[i
].name
);
350 if (stat(path
.buf
, &statbuf
))
353 data
->tempfiles
[i
] = register_tempfile(path
.buf
);
356 strbuf_release(&path
);
360 static int has_pack_ext(const struct generated_pack_data
*data
,
364 for (i
= 0; i
< ARRAY_SIZE(exts
); i
++) {
365 if (strcmp(exts
[i
].name
, ext
))
367 return !!data
->tempfiles
[i
];
369 BUG("unknown pack extension: '%s'", ext
);
372 static void repack_promisor_objects(const struct pack_objects_args
*args
,
373 struct string_list
*names
)
375 struct child_process cmd
= CHILD_PROCESS_INIT
;
377 struct strbuf line
= STRBUF_INIT
;
379 prepare_pack_objects(&cmd
, args
, packtmp
);
383 * NEEDSWORK: Giving pack-objects only the OIDs without any ordering
384 * hints may result in suboptimal deltas in the resulting pack. See if
385 * the OIDs can be sent with fake paths such that pack-objects can use a
386 * {type -> existing pack order} ordering when computing deltas instead
387 * of a {type -> size} ordering, which may produce better deltas.
389 for_each_packed_object(write_oid
, &cmd
,
390 FOR_EACH_OBJECT_PROMISOR_ONLY
);
393 /* No packed objects; cmd was never started */
394 child_process_clear(&cmd
);
400 out
= xfdopen(cmd
.out
, "r");
401 while (strbuf_getline_lf(&line
, out
) != EOF
) {
402 struct string_list_item
*item
;
405 if (line
.len
!= the_hash_algo
->hexsz
)
406 die(_("repack: Expecting full hex object ID lines only from pack-objects."));
407 item
= string_list_append(names
, line
.buf
);
410 * pack-objects creates the .pack and .idx files, but not the
411 * .promisor file. Create the .promisor file, which is empty.
413 * NEEDSWORK: fetch-pack sometimes generates non-empty
414 * .promisor files containing the ref names and associated
415 * hashes at the point of generation of the corresponding
416 * packfile, but this would not preserve their contents. Maybe
417 * concatenate the contents of all .promisor files instead of
418 * just creating a new empty file.
420 promisor_name
= mkpathdup("%s-%s.promisor", packtmp
,
422 write_promisor_file(promisor_name
, NULL
, 0);
424 item
->util
= populate_pack_exts(item
->string
);
429 if (finish_command(&cmd
))
430 die(_("could not finish pack-objects to repack promisor objects"));
433 struct pack_geometry
{
434 struct packed_git
**pack
;
435 uint32_t pack_nr
, pack_alloc
;
441 static uint32_t geometry_pack_weight(struct packed_git
*p
)
443 if (open_pack_index(p
))
444 die(_("cannot open index for %s"), p
->pack_name
);
445 return p
->num_objects
;
448 static int geometry_cmp(const void *va
, const void *vb
)
450 uint32_t aw
= geometry_pack_weight(*(struct packed_git
**)va
),
451 bw
= geometry_pack_weight(*(struct packed_git
**)vb
);
460 static void init_pack_geometry(struct pack_geometry
*geometry
,
461 struct existing_packs
*existing
,
462 const struct pack_objects_args
*args
)
464 struct packed_git
*p
;
465 struct strbuf buf
= STRBUF_INIT
;
467 for (p
= get_all_packs(the_repository
); p
; p
= p
->next
) {
468 if (args
->local
&& !p
->pack_local
)
470 * When asked to only repack local packfiles we skip
471 * over any packfiles that are borrowed from alternate
472 * object directories.
476 if (!pack_kept_objects
) {
478 * Any pack that has its pack_keep bit set will
479 * appear in existing->kept_packs below, but
480 * this saves us from doing a more expensive
487 * The pack may be kept via the --keep-pack
488 * option; check 'existing->kept_packs' to
489 * determine whether to ignore it.
492 strbuf_addstr(&buf
, pack_basename(p
));
493 strbuf_strip_suffix(&buf
, ".pack");
495 if (string_list_has_string(&existing
->kept_packs
, buf
.buf
))
501 ALLOC_GROW(geometry
->pack
,
502 geometry
->pack_nr
+ 1,
503 geometry
->pack_alloc
);
505 geometry
->pack
[geometry
->pack_nr
] = p
;
509 QSORT(geometry
->pack
, geometry
->pack_nr
, geometry_cmp
);
510 strbuf_release(&buf
);
513 static void split_pack_geometry(struct pack_geometry
*geometry
)
517 off_t total_size
= 0;
519 if (!geometry
->pack_nr
) {
520 geometry
->split
= geometry
->pack_nr
;
525 * First, count the number of packs (in descending order of size) which
526 * already form a geometric progression.
528 for (i
= geometry
->pack_nr
- 1; i
> 0; i
--) {
529 struct packed_git
*ours
= geometry
->pack
[i
];
530 struct packed_git
*prev
= geometry
->pack
[i
- 1];
532 if (unsigned_mult_overflows(geometry
->split_factor
,
533 geometry_pack_weight(prev
)))
534 die(_("pack %s too large to consider in geometric "
538 if (geometry_pack_weight(ours
) <
539 geometry
->split_factor
* geometry_pack_weight(prev
))
547 * Move the split one to the right, since the top element in the
548 * last-compared pair can't be in the progression. Only do this
549 * when we split in the middle of the array (otherwise if we got
550 * to the end, then the split is in the right place).
556 * Then, anything to the left of 'split' must be in a new pack. But,
557 * creating that new pack may cause packs in the heavy half to no longer
558 * form a geometric progression.
560 * Compute an expected size of the new pack, and then determine how many
561 * packs in the heavy half need to be joined into it (if any) to restore
562 * the geometric progression.
564 for (i
= 0; i
< split
; i
++) {
565 struct packed_git
*p
= geometry
->pack
[i
];
567 if (unsigned_add_overflows(total_size
, geometry_pack_weight(p
)))
568 die(_("pack %s too large to roll up"), p
->pack_name
);
569 total_size
+= geometry_pack_weight(p
);
571 for (i
= split
; i
< geometry
->pack_nr
; i
++) {
572 struct packed_git
*ours
= geometry
->pack
[i
];
574 if (unsigned_mult_overflows(geometry
->split_factor
,
576 die(_("pack %s too large to roll up"), ours
->pack_name
);
578 if (geometry_pack_weight(ours
) <
579 geometry
->split_factor
* total_size
) {
580 if (unsigned_add_overflows(total_size
,
581 geometry_pack_weight(ours
)))
582 die(_("pack %s too large to roll up"),
586 total_size
+= geometry_pack_weight(ours
);
591 geometry
->split
= split
;
594 static struct packed_git
*get_preferred_pack(struct pack_geometry
*geometry
)
600 * No geometry means either an all-into-one repack (in which
601 * case there is only one pack left and it is the largest) or an
604 * If repacking incrementally, then we could check the size of
605 * all packs to determine which should be preferred, but leave
610 if (geometry
->split
== geometry
->pack_nr
)
614 * The preferred pack is the largest pack above the split line. In
615 * other words, it is the largest pack that does not get rolled up in
616 * the geometric repack.
618 for (i
= geometry
->pack_nr
; i
> geometry
->split
; i
--)
620 * A pack that is not local would never be included in a
621 * multi-pack index. We thus skip over any non-local packs.
623 if (geometry
->pack
[i
- 1]->pack_local
)
624 return geometry
->pack
[i
- 1];
629 static void geometry_remove_redundant_packs(struct pack_geometry
*geometry
,
630 struct string_list
*names
,
631 struct existing_packs
*existing
)
633 struct strbuf buf
= STRBUF_INIT
;
636 for (i
= 0; i
< geometry
->split
; i
++) {
637 struct packed_git
*p
= geometry
->pack
[i
];
638 if (string_list_has_string(names
, hash_to_hex(p
->hash
)))
642 strbuf_addstr(&buf
, pack_basename(p
));
643 strbuf_strip_suffix(&buf
, ".pack");
645 if ((p
->pack_keep
) ||
646 (string_list_has_string(&existing
->kept_packs
, buf
.buf
)))
649 remove_redundant_pack(packdir
, buf
.buf
);
652 strbuf_release(&buf
);
655 static void free_pack_geometry(struct pack_geometry
*geometry
)
660 free(geometry
->pack
);
663 struct midx_snapshot_ref_data
{
669 static int midx_snapshot_ref_one(const char *refname UNUSED
,
670 const struct object_id
*oid
,
671 int flag UNUSED
, void *_data
)
673 struct midx_snapshot_ref_data
*data
= _data
;
674 struct object_id peeled
;
676 if (!peel_iterated_oid(oid
, &peeled
))
679 if (oidset_insert(&data
->seen
, oid
))
680 return 0; /* already seen */
682 if (oid_object_info(the_repository
, oid
, NULL
) != OBJ_COMMIT
)
685 fprintf(data
->f
->fp
, "%s%s\n", data
->preferred
? "+" : "",
691 static void midx_snapshot_refs(struct tempfile
*f
)
693 struct midx_snapshot_ref_data data
;
694 const struct string_list
*preferred
= bitmap_preferred_tips(the_repository
);
698 oidset_init(&data
.seen
, 0);
700 if (!fdopen_tempfile(f
, "w"))
701 die(_("could not open tempfile %s for writing"),
702 get_tempfile_path(f
));
705 struct string_list_item
*item
;
708 for_each_string_list_item(item
, preferred
)
709 for_each_ref_in(item
->string
, midx_snapshot_ref_one
, &data
);
713 for_each_ref(midx_snapshot_ref_one
, &data
);
715 if (close_tempfile_gently(f
)) {
716 int save_errno
= errno
;
719 die_errno(_("could not close refs snapshot tempfile"));
722 oidset_clear(&data
.seen
);
725 static void midx_included_packs(struct string_list
*include
,
726 struct existing_packs
*existing
,
727 struct string_list
*names
,
728 struct pack_geometry
*geometry
)
730 struct string_list_item
*item
;
732 for_each_string_list_item(item
, &existing
->kept_packs
)
733 string_list_insert(include
, xstrfmt("%s.idx", item
->string
));
734 for_each_string_list_item(item
, names
)
735 string_list_insert(include
, xstrfmt("pack-%s.idx", item
->string
));
736 if (geometry
->split_factor
) {
737 struct strbuf buf
= STRBUF_INIT
;
739 for (i
= geometry
->split
; i
< geometry
->pack_nr
; i
++) {
740 struct packed_git
*p
= geometry
->pack
[i
];
743 * The multi-pack index never refers to packfiles part
744 * of an alternate object database, so we skip these.
745 * While git-multi-pack-index(1) would silently ignore
746 * them anyway, this allows us to skip executing the
747 * command completely when we have only non-local
753 strbuf_addstr(&buf
, pack_basename(p
));
754 strbuf_strip_suffix(&buf
, ".pack");
755 strbuf_addstr(&buf
, ".idx");
757 string_list_insert(include
, strbuf_detach(&buf
, NULL
));
760 for_each_string_list_item(item
, &existing
->non_kept_packs
) {
761 if (pack_is_marked_for_deletion(item
))
763 string_list_insert(include
, xstrfmt("%s.idx", item
->string
));
767 for_each_string_list_item(item
, &existing
->cruft_packs
) {
769 * When doing a --geometric repack, there is no need to check
770 * for deleted packs, since we're by definition not doing an
771 * ALL_INTO_ONE repack (hence no packs will be deleted).
772 * Otherwise we must check for and exclude any packs which are
773 * enqueued for deletion.
775 * So we could omit the conditional below in the --geometric
776 * case, but doing so is unnecessary since no packs are marked
777 * as pending deletion (since we only call
778 * `mark_packs_for_deletion()` when doing an all-into-one
781 if (pack_is_marked_for_deletion(item
))
783 string_list_insert(include
, xstrfmt("%s.idx", item
->string
));
787 static int write_midx_included_packs(struct string_list
*include
,
788 struct pack_geometry
*geometry
,
789 struct string_list
*names
,
790 const char *refs_snapshot
,
791 int show_progress
, int write_bitmaps
)
793 struct child_process cmd
= CHILD_PROCESS_INIT
;
794 struct string_list_item
*item
;
795 struct packed_git
*preferred
= get_preferred_pack(geometry
);
805 strvec_push(&cmd
.args
, "multi-pack-index");
806 strvec_pushl(&cmd
.args
, "write", "--stdin-packs", NULL
);
809 strvec_push(&cmd
.args
, "--progress");
811 strvec_push(&cmd
.args
, "--no-progress");
814 strvec_push(&cmd
.args
, "--bitmap");
817 strvec_pushf(&cmd
.args
, "--preferred-pack=%s",
818 pack_basename(preferred
));
819 else if (names
->nr
) {
820 /* The largest pack was repacked, meaning that either
821 * one or two packs exist depending on whether the
822 * repository has a cruft pack or not.
824 * Select the non-cruft one as preferred to encourage
825 * pack-reuse among packs containing reachable objects
826 * over unreachable ones.
828 * (Note we could write multiple packs here if
829 * `--max-pack-size` was given, but any one of them
830 * will suffice, so pick the first one.)
832 for_each_string_list_item(item
, names
) {
833 struct generated_pack_data
*data
= item
->util
;
834 if (has_pack_ext(data
, ".mtimes"))
837 strvec_pushf(&cmd
.args
, "--preferred-pack=pack-%s.pack",
843 * No packs were kept, and no packs were written. The
844 * only thing remaining are .keep packs (unless
845 * --pack-kept-objects was given).
847 * Set the `--preferred-pack` arbitrarily here.
853 strvec_pushf(&cmd
.args
, "--refs-snapshot=%s", refs_snapshot
);
855 ret
= start_command(&cmd
);
859 in
= xfdopen(cmd
.in
, "w");
860 for_each_string_list_item(item
, include
)
861 fprintf(in
, "%s\n", item
->string
);
864 return finish_command(&cmd
);
867 static void remove_redundant_bitmaps(struct string_list
*include
,
870 struct strbuf path
= STRBUF_INIT
;
871 struct string_list_item
*item
;
874 strbuf_addstr(&path
, packdir
);
875 strbuf_addch(&path
, '/');
876 packdir_len
= path
.len
;
879 * Remove any pack bitmaps corresponding to packs which are now
880 * included in the MIDX.
882 for_each_string_list_item(item
, include
) {
883 strbuf_addstr(&path
, item
->string
);
884 strbuf_strip_suffix(&path
, ".idx");
885 strbuf_addstr(&path
, ".bitmap");
887 if (unlink(path
.buf
) && errno
!= ENOENT
)
888 warning_errno(_("could not remove stale bitmap: %s"),
891 strbuf_setlen(&path
, packdir_len
);
893 strbuf_release(&path
);
896 static int finish_pack_objects_cmd(struct child_process
*cmd
,
897 struct string_list
*names
,
901 struct strbuf line
= STRBUF_INIT
;
903 out
= xfdopen(cmd
->out
, "r");
904 while (strbuf_getline_lf(&line
, out
) != EOF
) {
905 struct string_list_item
*item
;
907 if (line
.len
!= the_hash_algo
->hexsz
)
908 die(_("repack: Expecting full hex object ID lines only "
909 "from pack-objects."));
911 * Avoid putting packs written outside of the repository in the
915 item
= string_list_append(names
, line
.buf
);
916 item
->util
= populate_pack_exts(line
.buf
);
921 strbuf_release(&line
);
923 return finish_command(cmd
);
926 static int write_filtered_pack(const struct pack_objects_args
*args
,
927 const char *destination
,
928 const char *pack_prefix
,
929 struct existing_packs
*existing
,
930 struct string_list
*names
)
932 struct child_process cmd
= CHILD_PROCESS_INIT
;
933 struct string_list_item
*item
;
938 int local
= skip_prefix(destination
, packdir
, &scratch
);
940 prepare_pack_objects(&cmd
, args
, destination
);
942 strvec_push(&cmd
.args
, "--stdin-packs");
944 if (!pack_kept_objects
)
945 strvec_push(&cmd
.args
, "--honor-pack-keep");
946 for_each_string_list_item(item
, &existing
->kept_packs
)
947 strvec_pushf(&cmd
.args
, "--keep-pack=%s", item
->string
);
951 ret
= start_command(&cmd
);
956 * Here 'names' contains only the pack(s) that were just
957 * written, which is exactly the packs we want to keep. Also
958 * 'existing_kept_packs' already contains the packs in
961 in
= xfdopen(cmd
.in
, "w");
962 for_each_string_list_item(item
, names
)
963 fprintf(in
, "^%s-%s.pack\n", pack_prefix
, item
->string
);
964 for_each_string_list_item(item
, &existing
->non_kept_packs
)
965 fprintf(in
, "%s.pack\n", item
->string
);
966 for_each_string_list_item(item
, &existing
->cruft_packs
)
967 fprintf(in
, "%s.pack\n", item
->string
);
968 caret
= pack_kept_objects
? "" : "^";
969 for_each_string_list_item(item
, &existing
->kept_packs
)
970 fprintf(in
, "%s%s.pack\n", caret
, item
->string
);
973 return finish_pack_objects_cmd(&cmd
, names
, local
);
976 static int existing_cruft_pack_cmp(const void *va
, const void *vb
)
978 struct packed_git
*a
= *(struct packed_git
**)va
;
979 struct packed_git
*b
= *(struct packed_git
**)vb
;
981 if (a
->pack_size
< b
->pack_size
)
983 if (a
->pack_size
> b
->pack_size
)
988 static void collapse_small_cruft_packs(FILE *in
, size_t max_size
,
989 struct existing_packs
*existing
)
991 struct packed_git
**existing_cruft
, *p
;
992 struct strbuf buf
= STRBUF_INIT
;
993 size_t total_size
= 0;
994 size_t existing_cruft_nr
= 0;
997 ALLOC_ARRAY(existing_cruft
, existing
->cruft_packs
.nr
);
999 for (p
= get_all_packs(the_repository
); p
; p
= p
->next
) {
1000 if (!(p
->is_cruft
&& p
->pack_local
))
1004 strbuf_addstr(&buf
, pack_basename(p
));
1005 strbuf_strip_suffix(&buf
, ".pack");
1007 if (!string_list_has_string(&existing
->cruft_packs
, buf
.buf
))
1010 if (existing_cruft_nr
>= existing
->cruft_packs
.nr
)
1011 BUG("too many cruft packs (found %"PRIuMAX
", but knew "
1013 (uintmax_t)existing_cruft_nr
+ 1,
1014 (uintmax_t)existing
->cruft_packs
.nr
);
1015 existing_cruft
[existing_cruft_nr
++] = p
;
1018 QSORT(existing_cruft
, existing_cruft_nr
, existing_cruft_pack_cmp
);
1020 for (i
= 0; i
< existing_cruft_nr
; i
++) {
1023 p
= existing_cruft
[i
];
1024 proposed
= st_add(total_size
, p
->pack_size
);
1026 if (proposed
<= max_size
) {
1027 total_size
= proposed
;
1028 fprintf(in
, "-%s\n", pack_basename(p
));
1030 retain_cruft_pack(existing
, p
);
1031 fprintf(in
, "%s\n", pack_basename(p
));
1035 for (i
= 0; i
< existing
->non_kept_packs
.nr
; i
++)
1036 fprintf(in
, "-%s.pack\n",
1037 existing
->non_kept_packs
.items
[i
].string
);
1039 strbuf_release(&buf
);
1040 free(existing_cruft
);
1043 static int write_cruft_pack(const struct pack_objects_args
*args
,
1044 const char *destination
,
1045 const char *pack_prefix
,
1046 const char *cruft_expiration
,
1047 struct string_list
*names
,
1048 struct existing_packs
*existing
)
1050 struct child_process cmd
= CHILD_PROCESS_INIT
;
1051 struct string_list_item
*item
;
1054 const char *scratch
;
1055 int local
= skip_prefix(destination
, packdir
, &scratch
);
1057 prepare_pack_objects(&cmd
, args
, destination
);
1059 strvec_push(&cmd
.args
, "--cruft");
1060 if (cruft_expiration
)
1061 strvec_pushf(&cmd
.args
, "--cruft-expiration=%s",
1064 strvec_push(&cmd
.args
, "--honor-pack-keep");
1065 strvec_push(&cmd
.args
, "--non-empty");
1069 ret
= start_command(&cmd
);
1074 * names has a confusing double use: it both provides the list
1075 * of just-written new packs, and accepts the name of the cruft
1076 * pack we are writing.
1078 * By the time it is read here, it contains only the pack(s)
1079 * that were just written, which is exactly the set of packs we
1080 * want to consider kept.
1082 * If `--expire-to` is given, the double-use served by `names`
1083 * ensures that the pack written to `--expire-to` excludes any
1084 * objects contained in the cruft pack.
1086 in
= xfdopen(cmd
.in
, "w");
1087 for_each_string_list_item(item
, names
)
1088 fprintf(in
, "%s-%s.pack\n", pack_prefix
, item
->string
);
1089 if (args
->max_pack_size
&& !cruft_expiration
) {
1090 collapse_small_cruft_packs(in
, args
->max_pack_size
, existing
);
1092 for_each_string_list_item(item
, &existing
->non_kept_packs
)
1093 fprintf(in
, "-%s.pack\n", item
->string
);
1094 for_each_string_list_item(item
, &existing
->cruft_packs
)
1095 fprintf(in
, "-%s.pack\n", item
->string
);
1097 for_each_string_list_item(item
, &existing
->kept_packs
)
1098 fprintf(in
, "%s.pack\n", item
->string
);
1101 return finish_pack_objects_cmd(&cmd
, names
, local
);
1104 static const char *find_pack_prefix(const char *packdir
, const char *packtmp
)
1106 const char *pack_prefix
;
1107 if (!skip_prefix(packtmp
, packdir
, &pack_prefix
))
1108 die(_("pack prefix %s does not begin with objdir %s"),
1110 if (*pack_prefix
== '/')
1115 int cmd_repack(int argc
, const char **argv
, const char *prefix
)
1117 struct child_process cmd
= CHILD_PROCESS_INIT
;
1118 struct string_list_item
*item
;
1119 struct string_list names
= STRING_LIST_INIT_DUP
;
1120 struct existing_packs existing
= EXISTING_PACKS_INIT
;
1121 struct pack_geometry geometry
= { 0 };
1122 struct tempfile
*refs_snapshot
= NULL
;
1126 /* variables to be filled by option parsing */
1127 int delete_redundant
= 0;
1128 const char *unpack_unreachable
= NULL
;
1129 int keep_unreachable
= 0;
1130 struct string_list keep_pack_list
= STRING_LIST_INIT_NODUP
;
1131 struct pack_objects_args po_args
= {NULL
};
1132 struct pack_objects_args cruft_po_args
= {NULL
};
1134 const char *cruft_expiration
= NULL
;
1135 const char *expire_to
= NULL
;
1136 const char *filter_to
= NULL
;
1138 struct option builtin_repack_options
[] = {
1139 OPT_BIT('a', NULL
, &pack_everything
,
1140 N_("pack everything in a single pack"), ALL_INTO_ONE
),
1141 OPT_BIT('A', NULL
, &pack_everything
,
1142 N_("same as -a, and turn unreachable objects loose"),
1143 LOOSEN_UNREACHABLE
| ALL_INTO_ONE
),
1144 OPT_BIT(0, "cruft", &pack_everything
,
1145 N_("same as -a, pack unreachable cruft objects separately"),
1147 OPT_STRING(0, "cruft-expiration", &cruft_expiration
, N_("approxidate"),
1148 N_("with --cruft, expire objects older than this")),
1149 OPT_MAGNITUDE(0, "max-cruft-size", &cruft_po_args
.max_pack_size
,
1150 N_("with --cruft, limit the size of new cruft packs")),
1151 OPT_BOOL('d', NULL
, &delete_redundant
,
1152 N_("remove redundant packs, and run git-prune-packed")),
1153 OPT_BOOL('f', NULL
, &po_args
.no_reuse_delta
,
1154 N_("pass --no-reuse-delta to git-pack-objects")),
1155 OPT_BOOL('F', NULL
, &po_args
.no_reuse_object
,
1156 N_("pass --no-reuse-object to git-pack-objects")),
1157 OPT_NEGBIT('n', NULL
, &run_update_server_info
,
1158 N_("do not run git-update-server-info"), 1),
1159 OPT__QUIET(&po_args
.quiet
, N_("be quiet")),
1160 OPT_BOOL('l', "local", &po_args
.local
,
1161 N_("pass --local to git-pack-objects")),
1162 OPT_BOOL('b', "write-bitmap-index", &write_bitmaps
,
1163 N_("write bitmap index")),
1164 OPT_BOOL('i', "delta-islands", &use_delta_islands
,
1165 N_("pass --delta-islands to git-pack-objects")),
1166 OPT_STRING(0, "unpack-unreachable", &unpack_unreachable
, N_("approxidate"),
1167 N_("with -A, do not loosen objects older than this")),
1168 OPT_BOOL('k', "keep-unreachable", &keep_unreachable
,
1169 N_("with -a, repack unreachable objects")),
1170 OPT_STRING(0, "window", &po_args
.window
, N_("n"),
1171 N_("size of the window used for delta compression")),
1172 OPT_STRING(0, "window-memory", &po_args
.window_memory
, N_("bytes"),
1173 N_("same as the above, but limit memory size instead of entries count")),
1174 OPT_STRING(0, "depth", &po_args
.depth
, N_("n"),
1175 N_("limits the maximum delta depth")),
1176 OPT_STRING(0, "threads", &po_args
.threads
, N_("n"),
1177 N_("limits the maximum number of threads")),
1178 OPT_MAGNITUDE(0, "max-pack-size", &po_args
.max_pack_size
,
1179 N_("maximum size of each packfile")),
1180 OPT_PARSE_LIST_OBJECTS_FILTER(&po_args
.filter_options
),
1181 OPT_BOOL(0, "pack-kept-objects", &pack_kept_objects
,
1182 N_("repack objects in packs marked with .keep")),
1183 OPT_STRING_LIST(0, "keep-pack", &keep_pack_list
, N_("name"),
1184 N_("do not repack this pack")),
1185 OPT_INTEGER('g', "geometric", &geometry
.split_factor
,
1186 N_("find a geometric progression with factor <N>")),
1187 OPT_BOOL('m', "write-midx", &write_midx
,
1188 N_("write a multi-pack index of the resulting packs")),
1189 OPT_STRING(0, "expire-to", &expire_to
, N_("dir"),
1190 N_("pack prefix to store a pack containing pruned objects")),
1191 OPT_STRING(0, "filter-to", &filter_to
, N_("dir"),
1192 N_("pack prefix to store a pack containing filtered out objects")),
1196 list_objects_filter_init(&po_args
.filter_options
);
1198 git_config(repack_config
, &cruft_po_args
);
1200 argc
= parse_options(argc
, argv
, prefix
, builtin_repack_options
,
1201 git_repack_usage
, 0);
1203 if (delete_redundant
&& repository_format_precious_objects
)
1204 die(_("cannot delete packs in a precious-objects repo"));
1206 if (keep_unreachable
&&
1207 (unpack_unreachable
|| (pack_everything
& LOOSEN_UNREACHABLE
)))
1208 die(_("options '%s' and '%s' cannot be used together"), "--keep-unreachable", "-A");
1210 if (pack_everything
& PACK_CRUFT
) {
1211 pack_everything
|= ALL_INTO_ONE
;
1213 if (unpack_unreachable
|| (pack_everything
& LOOSEN_UNREACHABLE
))
1214 die(_("options '%s' and '%s' cannot be used together"), "--cruft", "-A");
1215 if (keep_unreachable
)
1216 die(_("options '%s' and '%s' cannot be used together"), "--cruft", "-k");
1219 if (write_bitmaps
< 0) {
1221 (!(pack_everything
& ALL_INTO_ONE
) || !is_bare_repository()))
1223 } else if (write_bitmaps
&&
1224 git_env_bool(GIT_TEST_MULTI_PACK_INDEX
, 0) &&
1225 git_env_bool(GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP
, 0)) {
1228 if (pack_kept_objects
< 0)
1229 pack_kept_objects
= write_bitmaps
> 0 && !write_midx
;
1231 if (write_bitmaps
&& !(pack_everything
& ALL_INTO_ONE
) && !write_midx
)
1232 die(_(incremental_bitmap_conflict_error
));
1234 if (write_bitmaps
&& po_args
.local
&& has_alt_odb(the_repository
)) {
1236 * When asked to do a local repack, but we have
1237 * packfiles that are inherited from an alternate, then
1238 * we cannot guarantee that the multi-pack-index would
1239 * have full coverage of all objects. We thus disable
1240 * writing bitmaps in that case.
1242 warning(_("disabling bitmap writing, as some objects are not being packed"));
1246 if (write_midx
&& write_bitmaps
) {
1247 struct strbuf path
= STRBUF_INIT
;
1249 strbuf_addf(&path
, "%s/%s_XXXXXX", get_object_directory(),
1252 refs_snapshot
= xmks_tempfile(path
.buf
);
1253 midx_snapshot_refs(refs_snapshot
);
1255 strbuf_release(&path
);
1258 packdir
= mkpathdup("%s/pack", get_object_directory());
1259 packtmp_name
= xstrfmt(".tmp-%d-pack", (int)getpid());
1260 packtmp
= mkpathdup("%s/%s", packdir
, packtmp_name
);
1262 collect_pack_filenames(&existing
, &keep_pack_list
);
1264 if (geometry
.split_factor
) {
1265 if (pack_everything
)
1266 die(_("options '%s' and '%s' cannot be used together"), "--geometric", "-A/-a");
1267 init_pack_geometry(&geometry
, &existing
, &po_args
);
1268 split_pack_geometry(&geometry
);
1271 prepare_pack_objects(&cmd
, &po_args
, packtmp
);
1273 show_progress
= !po_args
.quiet
&& isatty(2);
1275 strvec_push(&cmd
.args
, "--keep-true-parents");
1276 if (!pack_kept_objects
)
1277 strvec_push(&cmd
.args
, "--honor-pack-keep");
1278 for (i
= 0; i
< keep_pack_list
.nr
; i
++)
1279 strvec_pushf(&cmd
.args
, "--keep-pack=%s",
1280 keep_pack_list
.items
[i
].string
);
1281 strvec_push(&cmd
.args
, "--non-empty");
1282 if (!geometry
.split_factor
) {
1284 * We need to grab all reachable objects, including those that
1285 * are reachable from reflogs and the index.
1287 * When repacking into a geometric progression of packs,
1288 * however, we ask 'git pack-objects --stdin-packs', and it is
1289 * not about packing objects based on reachability but about
1290 * repacking all the objects in specified packs and loose ones
1291 * (indeed, --stdin-packs is incompatible with these options).
1293 strvec_push(&cmd
.args
, "--all");
1294 strvec_push(&cmd
.args
, "--reflog");
1295 strvec_push(&cmd
.args
, "--indexed-objects");
1297 if (repo_has_promisor_remote(the_repository
))
1298 strvec_push(&cmd
.args
, "--exclude-promisor-objects");
1300 if (write_bitmaps
> 0)
1301 strvec_push(&cmd
.args
, "--write-bitmap-index");
1302 else if (write_bitmaps
< 0)
1303 strvec_push(&cmd
.args
, "--write-bitmap-index-quiet");
1305 if (use_delta_islands
)
1306 strvec_push(&cmd
.args
, "--delta-islands");
1308 if (pack_everything
& ALL_INTO_ONE
) {
1309 repack_promisor_objects(&po_args
, &names
);
1311 if (has_existing_non_kept_packs(&existing
) &&
1313 !(pack_everything
& PACK_CRUFT
)) {
1314 for_each_string_list_item(item
, &names
) {
1315 strvec_pushf(&cmd
.args
, "--keep-pack=%s-%s.pack",
1316 packtmp_name
, item
->string
);
1318 if (unpack_unreachable
) {
1319 strvec_pushf(&cmd
.args
,
1320 "--unpack-unreachable=%s",
1321 unpack_unreachable
);
1322 } else if (pack_everything
& LOOSEN_UNREACHABLE
) {
1323 strvec_push(&cmd
.args
,
1324 "--unpack-unreachable");
1325 } else if (keep_unreachable
) {
1326 strvec_push(&cmd
.args
, "--keep-unreachable");
1327 strvec_push(&cmd
.args
, "--pack-loose-unreachable");
1330 } else if (geometry
.split_factor
) {
1331 strvec_push(&cmd
.args
, "--stdin-packs");
1332 strvec_push(&cmd
.args
, "--unpacked");
1334 strvec_push(&cmd
.args
, "--unpacked");
1335 strvec_push(&cmd
.args
, "--incremental");
1338 if (po_args
.filter_options
.choice
)
1339 strvec_pushf(&cmd
.args
, "--filter=%s",
1340 expand_list_objects_filter_spec(&po_args
.filter_options
));
1342 die(_("option '%s' can only be used along with '%s'"), "--filter-to", "--filter");
1344 if (geometry
.split_factor
)
1349 ret
= start_command(&cmd
);
1353 if (geometry
.split_factor
) {
1354 FILE *in
= xfdopen(cmd
.in
, "w");
1356 * The resulting pack should contain all objects in packs that
1357 * are going to be rolled up, but exclude objects in packs which
1358 * are being left alone.
1360 for (i
= 0; i
< geometry
.split
; i
++)
1361 fprintf(in
, "%s\n", pack_basename(geometry
.pack
[i
]));
1362 for (i
= geometry
.split
; i
< geometry
.pack_nr
; i
++)
1363 fprintf(in
, "^%s\n", pack_basename(geometry
.pack
[i
]));
1367 ret
= finish_pack_objects_cmd(&cmd
, &names
, 1);
1371 if (!names
.nr
&& !po_args
.quiet
)
1372 printf_ln(_("Nothing new to pack."));
1374 if (pack_everything
& PACK_CRUFT
) {
1375 const char *pack_prefix
= find_pack_prefix(packdir
, packtmp
);
1377 if (!cruft_po_args
.window
)
1378 cruft_po_args
.window
= po_args
.window
;
1379 if (!cruft_po_args
.window_memory
)
1380 cruft_po_args
.window_memory
= po_args
.window_memory
;
1381 if (!cruft_po_args
.depth
)
1382 cruft_po_args
.depth
= po_args
.depth
;
1383 if (!cruft_po_args
.threads
)
1384 cruft_po_args
.threads
= po_args
.threads
;
1385 if (!cruft_po_args
.max_pack_size
)
1386 cruft_po_args
.max_pack_size
= po_args
.max_pack_size
;
1388 cruft_po_args
.local
= po_args
.local
;
1389 cruft_po_args
.quiet
= po_args
.quiet
;
1391 ret
= write_cruft_pack(&cruft_po_args
, packtmp
, pack_prefix
,
1392 cruft_expiration
, &names
,
1397 if (delete_redundant
&& expire_to
) {
1399 * If `--expire-to` is given with `-d`, it's possible
1400 * that we're about to prune some objects. With cruft
1401 * packs, pruning is implicit: any objects from existing
1402 * packs that weren't picked up by new packs are removed
1403 * when their packs are deleted.
1405 * Generate an additional cruft pack, with one twist:
1406 * `names` now includes the name of the cruft pack
1407 * written in the previous step. So the contents of
1408 * _this_ cruft pack exclude everything contained in the
1409 * existing cruft pack (that is, all of the unreachable
1410 * objects which are no older than
1411 * `--cruft-expiration`).
1413 * To make this work, cruft_expiration must become NULL
1414 * so that this cruft pack doesn't actually prune any
1415 * objects. If it were non-NULL, this call would always
1416 * generate an empty pack (since every object not in the
1417 * cruft pack generated above will have an mtime older
1418 * than the expiration).
1420 ret
= write_cruft_pack(&cruft_po_args
, expire_to
,
1430 if (po_args
.filter_options
.choice
) {
1432 filter_to
= packtmp
;
1434 ret
= write_filtered_pack(&po_args
,
1436 find_pack_prefix(packdir
, packtmp
),
1443 string_list_sort(&names
);
1445 close_object_store(the_repository
->objects
);
1448 * Ok we have prepared all new packfiles.
1450 for_each_string_list_item(item
, &names
) {
1451 struct generated_pack_data
*data
= item
->util
;
1453 for (ext
= 0; ext
< ARRAY_SIZE(exts
); ext
++) {
1456 fname
= mkpathdup("%s/pack-%s%s",
1457 packdir
, item
->string
, exts
[ext
].name
);
1459 if (data
->tempfiles
[ext
]) {
1460 const char *fname_old
= get_tempfile_path(data
->tempfiles
[ext
]);
1461 struct stat statbuffer
;
1463 if (!stat(fname_old
, &statbuffer
)) {
1464 statbuffer
.st_mode
&= ~(S_IWUSR
| S_IWGRP
| S_IWOTH
);
1465 chmod(fname_old
, statbuffer
.st_mode
);
1468 if (rename_tempfile(&data
->tempfiles
[ext
], fname
))
1469 die_errno(_("renaming pack to '%s' failed"), fname
);
1470 } else if (!exts
[ext
].optional
)
1471 die(_("pack-objects did not write a '%s' file for pack %s-%s"),
1472 exts
[ext
].name
, packtmp
, item
->string
);
1473 else if (unlink(fname
) < 0 && errno
!= ENOENT
)
1474 die_errno(_("could not unlink: %s"), fname
);
1479 /* End of pack replacement. */
1481 if (delete_redundant
&& pack_everything
& ALL_INTO_ONE
)
1482 mark_packs_for_deletion(&existing
, &names
);
1485 struct string_list include
= STRING_LIST_INIT_NODUP
;
1486 midx_included_packs(&include
, &existing
, &names
, &geometry
);
1488 ret
= write_midx_included_packs(&include
, &geometry
, &names
,
1489 refs_snapshot
? get_tempfile_path(refs_snapshot
) : NULL
,
1490 show_progress
, write_bitmaps
> 0);
1492 if (!ret
&& write_bitmaps
)
1493 remove_redundant_bitmaps(&include
, packdir
);
1495 string_list_clear(&include
, 0);
1501 reprepare_packed_git(the_repository
);
1503 if (delete_redundant
) {
1505 remove_redundant_existing_packs(&existing
);
1507 if (geometry
.split_factor
)
1508 geometry_remove_redundant_packs(&geometry
, &names
,
1511 opts
|= PRUNE_PACKED_VERBOSE
;
1512 prune_packed_objects(opts
);
1514 if (!keep_unreachable
&&
1515 (!(pack_everything
& LOOSEN_UNREACHABLE
) ||
1516 unpack_unreachable
) &&
1517 is_repository_shallow(the_repository
))
1518 prune_shallow(PRUNE_QUICK
);
1521 if (run_update_server_info
)
1522 update_server_info(0);
1524 if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX
, 0)) {
1526 if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP
, 0))
1527 flags
|= MIDX_WRITE_BITMAP
| MIDX_WRITE_REV_INDEX
;
1528 write_midx_file(get_object_directory(), NULL
, NULL
, flags
);
1532 string_list_clear(&names
, 1);
1533 existing_packs_release(&existing
);
1534 free_pack_geometry(&geometry
);
1535 list_objects_filter_release(&po_args
.filter_options
);