Merge branch 'zh/gc-expire-to'
"git gc" learned the "--expire-to" option and passes it down to underlying "git repack". * zh/gc-expire-to: gc: add `--expire-to` option
This commit is contained in:
@@ -69,6 +69,13 @@ be performed as well.
|
|||||||
the `--max-cruft-size` option of linkgit:git-repack[1] for
|
the `--max-cruft-size` option of linkgit:git-repack[1] for
|
||||||
more.
|
more.
|
||||||
|
|
||||||
|
--expire-to=<dir>::
|
||||||
|
When packing unreachable objects into a cruft pack, write a cruft
|
||||||
|
pack containing pruned objects (if any) to the directory `<dir>`.
|
||||||
|
This option only has an effect when used together with `--cruft`.
|
||||||
|
See the `--expire-to` option of linkgit:git-repack[1] for
|
||||||
|
more information.
|
||||||
|
|
||||||
--prune=<date>::
|
--prune=<date>::
|
||||||
Prune loose objects older than date (default is 2 weeks ago,
|
Prune loose objects older than date (default is 2 weeks ago,
|
||||||
overridable by the config variable `gc.pruneExpire`).
|
overridable by the config variable `gc.pruneExpire`).
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ struct gc_config {
|
|||||||
char *prune_worktrees_expire;
|
char *prune_worktrees_expire;
|
||||||
char *repack_filter;
|
char *repack_filter;
|
||||||
char *repack_filter_to;
|
char *repack_filter_to;
|
||||||
|
char *repack_expire_to;
|
||||||
unsigned long big_pack_threshold;
|
unsigned long big_pack_threshold;
|
||||||
unsigned long max_delta_cache_size;
|
unsigned long max_delta_cache_size;
|
||||||
/*
|
/*
|
||||||
@@ -445,7 +446,8 @@ static int keep_one_pack(struct string_list_item *item, void *data UNUSED)
|
|||||||
static void add_repack_all_option(struct gc_config *cfg,
|
static void add_repack_all_option(struct gc_config *cfg,
|
||||||
struct string_list *keep_pack)
|
struct string_list *keep_pack)
|
||||||
{
|
{
|
||||||
if (cfg->prune_expire && !strcmp(cfg->prune_expire, "now"))
|
if (cfg->prune_expire && !strcmp(cfg->prune_expire, "now")
|
||||||
|
&& !(cfg->cruft_packs && cfg->repack_expire_to))
|
||||||
strvec_push(&repack, "-a");
|
strvec_push(&repack, "-a");
|
||||||
else if (cfg->cruft_packs) {
|
else if (cfg->cruft_packs) {
|
||||||
strvec_push(&repack, "--cruft");
|
strvec_push(&repack, "--cruft");
|
||||||
@@ -454,6 +456,8 @@ static void add_repack_all_option(struct gc_config *cfg,
|
|||||||
if (cfg->max_cruft_size)
|
if (cfg->max_cruft_size)
|
||||||
strvec_pushf(&repack, "--max-cruft-size=%lu",
|
strvec_pushf(&repack, "--max-cruft-size=%lu",
|
||||||
cfg->max_cruft_size);
|
cfg->max_cruft_size);
|
||||||
|
if (cfg->repack_expire_to)
|
||||||
|
strvec_pushf(&repack, "--expire-to=%s", cfg->repack_expire_to);
|
||||||
} else {
|
} else {
|
||||||
strvec_push(&repack, "-A");
|
strvec_push(&repack, "-A");
|
||||||
if (cfg->prune_expire)
|
if (cfg->prune_expire)
|
||||||
@@ -688,7 +692,6 @@ struct repository *repo UNUSED)
|
|||||||
const char *prune_expire_sentinel = "sentinel";
|
const char *prune_expire_sentinel = "sentinel";
|
||||||
const char *prune_expire_arg = prune_expire_sentinel;
|
const char *prune_expire_arg = prune_expire_sentinel;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
struct option builtin_gc_options[] = {
|
struct option builtin_gc_options[] = {
|
||||||
OPT__QUIET(&quiet, N_("suppress progress reporting")),
|
OPT__QUIET(&quiet, N_("suppress progress reporting")),
|
||||||
{ OPTION_STRING, 0, "prune", &prune_expire_arg, N_("date"),
|
{ OPTION_STRING, 0, "prune", &prune_expire_arg, N_("date"),
|
||||||
@@ -707,6 +710,8 @@ struct repository *repo UNUSED)
|
|||||||
PARSE_OPT_NOCOMPLETE),
|
PARSE_OPT_NOCOMPLETE),
|
||||||
OPT_BOOL(0, "keep-largest-pack", &keep_largest_pack,
|
OPT_BOOL(0, "keep-largest-pack", &keep_largest_pack,
|
||||||
N_("repack all other packs except the largest pack")),
|
N_("repack all other packs except the largest pack")),
|
||||||
|
OPT_STRING(0, "expire-to", &cfg.repack_expire_to, N_("dir"),
|
||||||
|
N_("pack prefix to store a pack containing pruned objects")),
|
||||||
OPT_END()
|
OPT_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -338,6 +338,39 @@ test_expect_success 'gc.maxCruftSize sets appropriate repack options' '
|
|||||||
test_subcommand $cruft_max_size_opts --max-cruft-size=3145728 <trace2.txt
|
test_subcommand $cruft_max_size_opts --max-cruft-size=3145728 <trace2.txt
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success '--expire-to sets repack --expire-to' '
|
||||||
|
rm -rf expired &&
|
||||||
|
mkdir expired &&
|
||||||
|
expire_to="$(pwd)/expired/pack" &&
|
||||||
|
GIT_TRACE2_EVENT=$(pwd)/trace2.txt git -C cruft--max-size gc --cruft --expire-to="$expire_to" &&
|
||||||
|
test_subcommand $cruft_max_size_opts --expire-to="$expire_to" <trace2.txt
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success '--expire-to with --prune=now sets repack --expire-to' '
|
||||||
|
rm -rf expired &&
|
||||||
|
mkdir expired &&
|
||||||
|
expire_to="$(pwd)/expired/pack" &&
|
||||||
|
GIT_TRACE2_EVENT=$(pwd)/trace2.txt git -C cruft--max-size gc --cruft --prune=now --expire-to="$expire_to" &&
|
||||||
|
test_subcommand git repack -d -l --cruft --cruft-expiration=now --expire-to="$expire_to" <trace2.txt
|
||||||
|
'
|
||||||
|
|
||||||
|
|
||||||
|
test_expect_success '--expire-to with --no-cruft sets repack -A' '
|
||||||
|
rm -rf expired &&
|
||||||
|
mkdir expired &&
|
||||||
|
expire_to="$(pwd)/expired/pack" &&
|
||||||
|
GIT_TRACE2_EVENT=$(pwd)/trace2.txt git -C cruft--max-size gc --no-cruft --expire-to="$expire_to" &&
|
||||||
|
test_subcommand git repack -d -l -A --unpack-unreachable=2.weeks.ago <trace2.txt
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success '--expire-to with --no-cruft sets repack -a' '
|
||||||
|
rm -rf expired &&
|
||||||
|
mkdir expired &&
|
||||||
|
expire_to="$(pwd)/expired/pack" &&
|
||||||
|
GIT_TRACE2_EVENT=$(pwd)/trace2.txt git -C cruft--max-size gc --no-cruft --prune=now --expire-to="$expire_to" &&
|
||||||
|
test_subcommand git repack -d -l -a <trace2.txt
|
||||||
|
'
|
||||||
|
|
||||||
run_and_wait_for_gc () {
|
run_and_wait_for_gc () {
|
||||||
# We read stdout from gc for the side effect of waiting until the
|
# We read stdout from gc for the side effect of waiting until the
|
||||||
# background gc process exits, closing its fd 9. Furthermore, the
|
# background gc process exits, closing its fd 9. Furthermore, the
|
||||||
|
|||||||
Reference in New Issue
Block a user