From: Taylor Blau Date: Fri, 18 Nov 2022 23:43:09 +0000 (-0500) Subject: Merge branch 'tb/repack-expire-to' X-Git-Tag: v2.39.0-rc0~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad9096881d451bdb56d713a4c7d271dda3662cb2;p=thirdparty%2Fgit.git Merge branch 'tb/repack-expire-to' "git repack" learns to send cruft objects out of the way into packfiles outside the repository. * tb/repack-expire-to: builtin/repack.c: implement `--expire-to` for storing pruned objects builtin/repack.c: write cruft packs to arbitrary locations builtin/repack.c: pass "cruft_expiration" to `write_cruft_pack` builtin/repack.c: pass "out" to `prepare_pack_objects` --- ad9096881d451bdb56d713a4c7d271dda3662cb2 diff --cc builtin/repack.c index 10e23f9ee1,a70962ee03..65eb1b8bd2 --- a/builtin/repack.c +++ b/builtin/repack.c @@@ -627,37 -661,10 +627,39 @@@ static int write_midx_included_packs(st return finish_command(&cmd); } +static void remove_redundant_bitmaps(struct string_list *include, + const char *packdir) +{ + struct strbuf path = STRBUF_INIT; + struct string_list_item *item; + size_t packdir_len; + + strbuf_addstr(&path, packdir); + strbuf_addch(&path, '/'); + packdir_len = path.len; + + /* + * Remove any pack bitmaps corresponding to packs which are now + * included in the MIDX. + */ + for_each_string_list_item(item, include) { + strbuf_addstr(&path, item->string); + strbuf_strip_suffix(&path, ".idx"); + strbuf_addstr(&path, ".bitmap"); + + if (unlink(path.buf) && errno != ENOENT) + warning_errno(_("could not remove stale bitmap: %s"), + path.buf); + + strbuf_setlen(&path, packdir_len); + } + strbuf_release(&path); +} + static int write_cruft_pack(const struct pack_objects_args *args, + const char *destination, const char *pack_prefix, + const char *cruft_expiration, struct string_list *names, struct string_list *existing_packs, struct string_list *existing_kept_packs) @@@ -710,9 -721,12 +718,14 @@@ if (line.len != the_hash_algo->hexsz) die(_("repack: Expecting full hex object ID lines only " "from pack-objects.")); - - item = string_list_append(names, line.buf); - item->util = populate_pack_exts(line.buf); + /* + * avoid putting packs written outside of the repository in the + * list of names + */ - if (local) - string_list_append(names, line.buf); ++ if (local) { ++ item = string_list_append(names, line.buf); ++ item->util = populate_pack_exts(line.buf); ++ } } fclose(out); @@@ -858,7 -876,9 +875,7 @@@ int cmd_repack(int argc, const char **a split_pack_geometry(geometry, geometric_factor); } - prepare_pack_objects(&cmd, &po_args); - sigchain_push_common(remove_pack_on_signal); - + prepare_pack_objects(&cmd, &po_args, packtmp); show_progress = !po_args.quiet && isatty(2);