Skip to content

Commit 4254269

Browse files
committed
fix(gc): make --prune=now compatible with --expire-to
The original `git gc --prune=now` attempted to delete all unreachable objects. However, after the introduction of `--cruft` and `--expire-to=<dir>` in git gc, `--prune=now` can now compress unreachable objects into a cruft pack and store them in the specified <dir> instead of deleting them directly. This is beneficial for recovery in case of data corruption during repository GC. Therefore, update the handling logic of `--prune=now` in gc so that `-a` parameter is only passed to the repack command when neither `--cruft` nor `--expire-to` are used. Signed-off-by: ZheNing Hu <[email protected]>
1 parent 14e94bf commit 4254269

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

builtin/gc.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ static int keep_one_pack(struct string_list_item *item, void *data UNUSED)
433433
static void add_repack_all_option(struct gc_config *cfg,
434434
struct string_list *keep_pack)
435435
{
436-
if (cfg->prune_expire && !strcmp(cfg->prune_expire, "now"))
436+
if (cfg->prune_expire && !strcmp(cfg->prune_expire, "now")
437+
&& !(cfg->cruft_packs && cfg->repack_expire_to))
437438
strvec_push(&repack, "-a");
438439
else if (cfg->cruft_packs) {
439440
strvec_push(&repack, "--cruft");

0 commit comments

Comments
 (0)