git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "ZheNing Hu via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, me@ttaylorr.com,
	ZheNing Hu <adlternative@gmail.com>,
	ZheNing Hu <adlternative@gmail.com>
Subject: [PATCH v2 2/2] fix(gc): make --prune=now compatible with --expire-to
Date: Tue, 31 Dec 2024 02:18:33 +0000	[thread overview]
Message-ID: <579757957d21faaa8dd9228a191d82f663e93c03.1735611513.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1843.v2.git.1735611513.gitgitgadget@gmail.com>

From: ZheNing Hu <adlternative@gmail.com>

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 <adlternative@gmail.com>
---
 builtin/gc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/builtin/gc.c b/builtin/gc.c
index 77904694c9f..8656e1caff0 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -433,7 +433,8 @@ static int keep_one_pack(struct string_list_item *item, void *data UNUSED)
 static void add_repack_all_option(struct gc_config *cfg,
 				  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");
 	else if (cfg->cruft_packs) {
 		strvec_push(&repack, "--cruft");
-- 
gitgitgadget

  parent reply	other threads:[~2024-12-31  2:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-24 11:52 [PATCH] gc: add `--expire-to` option ZheNing Hu via GitGitGadget
2024-12-31  2:18 ` [PATCH v2 0/2] gc: add --expire-to option ZheNing Hu via GitGitGadget
2024-12-31  2:18   ` [PATCH v2 1/2] gc: add `--expire-to` option ZheNing Hu via GitGitGadget
2025-01-03  4:57     ` ZheNing Hu
2025-01-13  7:12     ` ZheNing Hu
2024-12-31  2:18   ` ZheNing Hu via GitGitGadget [this message]
2025-01-13  9:17     ` [PATCH v2 2/2] fix(gc): make --prune=now compatible with --expire-to Jeff King
2025-01-15  7:56       ` ZheNing Hu
2025-01-16  2:35   ` [PATCH v3] gc: add `--expire-to` option ZheNing Hu via GitGitGadget
2025-01-16 18:23     ` Junio C Hamano
2025-01-23  3:42       ` ZheNing Hu
2025-01-24  7:49     ` [PATCH v4] " ZheNing Hu via GitGitGadget
2025-02-04 18:15       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=579757957d21faaa8dd9228a191d82f663e93c03.1735611513.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=adlternative@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=me@ttaylorr.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).