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
ZheNing Hu <adlternative@gmail.com>
Date
Dec 26, 2024, 06:19 UTC
Message-ID
<CAOLTT8TraRjBObcLotNr7+a9Ap7Fy8VVy7HjHLLWwEB_LvBrUQ@mail.gmail.com>
In-Reply-To
<CABvF+3ZU=96jQBmGw3eWmAQ4DjCdcm1VT7fHMVz_MxvW2xxPng@mail.gmail.com>
Taylor Blau <me@ttaylorr.com> 于2024年12月24日周二 23:39写道:
Show 23 quoted lines
>
> On Tue, Dec 24, 2024 at 08:07:16PM +0800, ZheNing Hu wrote:
> > I am trying to use the --cruft feature of git gc, and everything works
> > well, but when I combine it with --prune=now, I notice that no cruft
> > package is generated, which is very strange. So I turned on trace and
> > checked: instead of executing `git repack --cruft`, it executed `git
> > repack -d -l -a`. Is this normal? If `git gc --cruft --prune=now`
> > doesn't work as expected, it won't be safe to further execute `git gc
> > --cruft --expire-to=<dir> --prune=now`(in my another patch).
> >
> > I checked the code, and it appears that add_repack_all_option() first
> > processes `--prune=now` before handling `--cruft` option.
>
> That's right, since --prune=now will cause your repository to purge any
> unreachable objects immediately, regardless of their mtimes.
>
> So after a 'git gc --prune=now', your repository will only consist of
> reachable objects, meaning that there will be nothing to put into a
> cruft pack.
>
> Note that 'git gc' does not support the '--expire-to' option, but you
> can use it via 'git repack'.
>

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).

> Thanks,
> Taylor

Thanks, ZheNing Hu

Previous: Taylor BlauNext: Jeff King
Message 3 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.