Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/prune-packed.c # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / prune-packed.c` 57 lines ยท 1214 bytes Raw Blame History 1 #include "git-compat-util.h" 2 #include "gettext.h" 3 #include "object-file.h" 4 #include "packfile.h" 5 #include "progress.h" 6 #include "prune-packed.h" 7 #include "repository.h" 8 9 struct prune_data { 10 struct repository *r; 11 int opts; 12 }; 13 14 static struct progress *progress; 15 16 static int prune_subdir(unsigned int nr, const char *path, void *data) 17 { 18 struct prune_data *d = data; 19 display_progress(progress, nr + 1); 20 if (!(d->opts & PRUNE_PACKED_DRY_RUN)) 21 rmdir(path); 22 return 0; 23 } 24 25 static int prune_object(const struct object_id *oid, const char *path, 26 void *data) 27 { 28 struct prune_data *d = data; 29 30 if (!has_object_pack(d->r, oid)) 31 return 0; 32 33 if (d->opts & PRUNE_PACKED_DRY_RUN) 34 printf("rm -f %s\n", path); 35 else 36 unlink_or_warn(path); 37 return 0; 38 } 39 40 void prune_packed_objects(struct repository *r, int opts) 41 { 42 struct prune_data cb_data = { 43 .r = r, 44 .opts = opts 45 }; 46 47 if (opts & PRUNE_PACKED_VERBOSE) 48 progress = start_delayed_progress(r, 49 _("Removing duplicate objects"), 256); 50 51 for_each_loose_file_in_source(r->objects->source, 52 prune_object, NULL, prune_subdir, &cb_data); 53 54 /* Ensure we show 100% before finishing progress */ 55 display_progress(progress, 256); 56 stop_progress(&progress); 57 }