git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [Possible Bug] --cruft option not work with git gc --prune=now

From
Jeff King <peff@peff.net>
Date
Dec 26, 2024, 15:23 UTC
Message-ID
<20241226152347.GA68791@coredump.intra.peff.net>
In-Reply-To
<CAOLTT8TraRjBObcLotNr7+a9Ap7Fy8VVy7HjHLLWwEB_LvBrUQ@mail.gmail.com>
On Thu, Dec 26, 2024 at 02:19:56PM +0800, ZheNing Hu wrote:
Show 7 quoted lines
> Okay, I know that gc doesn't have an --expire-to parameter,
> but here I was hoping to use git gc --prune=now --expire-to=<dir>,
> where expired and unreachable objects would be stored in <dir> for
> easy recovery in case of repository corruption. Moreover, it's more
> convenient compared to using git repack + git prune
> (isn't a single gc command much simpler? Plus, most users are
> likely familiar with gc rather than repack and prune).

I don't think there is any reason that gc _can't_ support --expire-to as you want. But any patch to do so would have to adjust how it calls git-repack.

Up until now, "--prune=now" meant it was fine to run "repack -ad", since that would just discard any unreachable packed objects without further consideration. If we're keeping any objects, then we have to tell repack what to do with them (which traditionally was just passing --unpack-unreachable, but these days can include --cruft).

With --expire-to, that logic wouldn't be valid anymore; even if we are expiring all objects, we still might want to tell repack where to put the expired ones. So I think you'd want to adjust the if/else in add_repack_all_option() to pass --cruft, etc, when you see --expire-to (but still continue to "repack -ad" otherwise to keep the traditional "git gc --prune=now" as cheap as possible).

-Peff
Previous: ZheNing HuNext: ZheNing Hu
Message 4 of 5 in “[Possible Bug] --cruft option not work with git gc --prune=now”
  1. ZheNing HuDec 24, 2024
  2. Taylor BlauDec 24, 2024
  3. ZheNing HuDec 26, 2024
  4. Jeff KingDec 26, 2024
  5. ZheNing HuDec 30, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.