Merge branch 'cc/repack-sift-filtered-objects-to-separate-pack'

"git repack" machinery learns to pay attention to the "--filter="
option.

* cc/repack-sift-filtered-objects-to-separate-pack:
  gc: add `gc.repackFilterTo` config option
  repack: implement `--filter-to` for storing filtered out objects
  gc: add `gc.repackFilter` config option
  repack: add `--filter=<filter-spec>` option
  pack-bitmap-write: rebuild using new bitmap when remapping
  repack: refactor finding pack prefix
  repack: refactor finishing pack-objects command
  t/helper: add 'find-pack' test-tool
  pack-objects: allow `--filter` without `--stdout`
This commit is contained in:
Junio C Hamano
2023-10-10 11:39:14 -07:00
15 changed files with 544 additions and 51 deletions

50
t/helper/test-find-pack.c Normal file
View File

@ -0,0 +1,50 @@
#include "test-tool.h"
#include "object-name.h"
#include "object-store.h"
#include "packfile.h"
#include "parse-options.h"
#include "setup.h"
/*
* Display the path(s), one per line, of the packfile(s) containing
* the given object.
*
* If '--check-count <n>' is passed, then error out if the number of
* packfiles containing the object is not <n>.
*/
static const char *find_pack_usage[] = {
"test-tool find-pack [--check-count <n>] <object>",
NULL
};
int cmd__find_pack(int argc, const char **argv)
{
struct object_id oid;
struct packed_git *p;
int count = -1, actual_count = 0;
const char *prefix = setup_git_directory();
struct option options[] = {
OPT_INTEGER('c', "check-count", &count, "expected number of packs"),
OPT_END(),
};
argc = parse_options(argc, argv, prefix, options, find_pack_usage, 0);
if (argc != 1)
usage(find_pack_usage[0]);
if (repo_get_oid(the_repository, argv[0], &oid))
die("cannot parse %s as an object name", argv[0]);
for (p = get_all_packs(the_repository); p; p = p->next)
if (find_pack_entry_one(oid.hash, p)) {
printf("%s\n", p->pack_name);
actual_count++;
}
if (count > -1 && count != actual_count)
die("bad packfile count %d instead of %d", actual_count, count);
return 0;
}

View File

@ -31,6 +31,7 @@ static struct test_cmd cmds[] = {
{ "env-helper", cmd__env_helper },
{ "example-decorate", cmd__example_decorate },
{ "fast-rebase", cmd__fast_rebase },
{ "find-pack", cmd__find_pack },
{ "fsmonitor-client", cmd__fsmonitor_client },
{ "genrandom", cmd__genrandom },
{ "genzeros", cmd__genzeros },

View File

@ -25,6 +25,7 @@ int cmd__dump_reftable(int argc, const char **argv);
int cmd__env_helper(int argc, const char **argv);
int cmd__example_decorate(int argc, const char **argv);
int cmd__fast_rebase(int argc, const char **argv);
int cmd__find_pack(int argc, const char **argv);
int cmd__fsmonitor_client(int argc, const char **argv);
int cmd__genrandom(int argc, const char **argv);
int cmd__genzeros(int argc, const char **argv);