git-p4: don't print shell commands as python lists
[git/debian.git] / prune-packed.c
blob261520b472c9c2bbac57ea94460dcabeefb3a91b
1 #include "object-store.h"
2 #include "packfile.h"
3 #include "progress.h"
4 #include "prune-packed.h"
6 static struct progress *progress;
8 static int prune_subdir(unsigned int nr, const char *path, void *data)
10 int *opts = data;
11 display_progress(progress, nr + 1);
12 if (!(*opts & PRUNE_PACKED_DRY_RUN))
13 rmdir(path);
14 return 0;
17 static int prune_object(const struct object_id *oid, const char *path,
18 void *data)
20 int *opts = data;
22 if (!has_object_pack(oid))
23 return 0;
25 if (*opts & PRUNE_PACKED_DRY_RUN)
26 printf("rm -f %s\n", path);
27 else
28 unlink_or_warn(path);
29 return 0;
32 void prune_packed_objects(int opts)
34 if (opts & PRUNE_PACKED_VERBOSE)
35 progress = start_delayed_progress(_("Removing duplicate objects"), 256);
37 for_each_loose_file_in_objdir(get_object_directory(),
38 prune_object, NULL, prune_subdir, &opts);
40 /* Ensure we show 100% before finishing progress */
41 display_progress(progress, 256);
42 stop_progress(&progress);