1 #include "git-compat-util.h"
2 #include "object-store.h"
5 #include "prune-packed.h"
7 static struct progress
*progress
;
9 static int prune_subdir(unsigned int nr
, const char *path
, void *data
)
12 display_progress(progress
, nr
+ 1);
13 if (!(*opts
& PRUNE_PACKED_DRY_RUN
))
18 static int prune_object(const struct object_id
*oid
, const char *path
,
23 if (!has_object_pack(oid
))
26 if (*opts
& PRUNE_PACKED_DRY_RUN
)
27 printf("rm -f %s\n", path
);
33 void prune_packed_objects(int opts
)
35 if (opts
& PRUNE_PACKED_VERBOSE
)
36 progress
= start_delayed_progress(_("Removing duplicate objects"), 256);
38 for_each_loose_file_in_objdir(get_object_directory(),
39 prune_object
, NULL
, prune_subdir
, &opts
);
41 /* Ensure we show 100% before finishing progress */
42 display_progress(progress
, 256);
43 stop_progress(&progress
);