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

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

From
ZheNing Hu <adlternative@gmail.com>
Date
Dec 24, 2024, 12:07 UTC
Message-ID
<CAOLTT8Q0cH3Q=yPnTYKAwn8bC+iDW7onibsLF=bzVr8tGw5J0Q@mail.gmail.com>

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.

If this is a bug, I am willing to propose a patch to fix it.

```shell GIT_TRACE=1 git gc --prune=now --cruft 19:56:54.132263 git.c:479 trace: built-in: git gc --prune=now --cruft 19:56:54.137004 run-command.c:666 trace: run_command: git pack-refs --all --prune 19:56:54.137087 run-command.c:758 trace: start_command: /Users/adl/libexec/git-core/git pack-refs --all --prune 19:56:54.152233 git.c:479 trace: built-in: git pack-refs --all --prune 19:56:54.166598 run-command.c:666 trace: run_command: git reflog expire --all 19:56:54.166705 run-command.c:758 trace: start_command: /Users/adl/libexec/git-core/git reflog expire --all 19:56:54.181965 git.c:479 trace: built-in: git reflog expire --all 19:56:54.184495 run-command.c:666 trace: run_command: git repack -d -l -a 19:56:54.184571 run-command.c:758 trace: start_command: /Users/adl/libexec/git-core/git repack -d -l -a 19:56:54.196211 git.c:479 trace: built-in: git repack -d -l -a 19:56:54.198260 run-command.c:666 trace: run_command: git pack-objects --local --delta-base-offset objects/pack/.tmp-59391-pack --keep-true-parents --honor-pack-keep --non-empty --all --reflog --indexed-objects --write-bitmap-index-quiet 19:56:54.198304 run-command.c:758 trace: start_command: /Users/adl/libexec/git-core/git pack-objects --local --delta-base-offset objects/pack/.tmp-59391-pack --keep-true-parents --honor-pack-keep --non-empty --all --reflog --indexed-objects --write-bitmap-index-quiet 19:56:54.209384 git.c:479 trace: built-in: git pack-objects --local --delta-base-offset objects/pack/.tmp-59391-pack --keep-true-parents --honor-pack-keep --non-empty --all --reflog --indexed-objects --write-bitmap-index-quiet Enumerating objects: 512819, done. Counting objects: 100% (512819/512819), done. Delta compression using up to 12 threads Compressing objects: 100% (237575/237575), done. Writing objects: 100% (512819/512819), done. Selecting bitmap commits: 23999, done. Building bitmaps: 100% (309/309), done. Total 512819 (delta 116078), reused 512819 (delta 116078), pack-reused 0 (from 0) 19:57:12.783287 run-command.c:666 trace: run_command: git prune --expire now 19:57:12.783887 run-command.c:758 trace: start_command: /Users/adl/libexec/git-core/git prune --expire now 19:57:12.799337 git.c:479 trace: built-in: git prune --expire now 19:57:12.802050 run-command.c:666 trace: run_command: git worktree prune --expire 3.months.ago 19:57:12.802115 run-command.c:758 trace: start_command: /Users/adl/libexec/git-core/git worktree prune --expire 3.months.ago 19:57:12.812977 git.c:479 trace: built-in: git worktree prune --expire 3.months.ago 19:57:12.814412 run-command.c:666 trace: run_command: git rerere gc 19:57:12.814476 run-command.c:758 trace: start_command: /Users/adl/libexec/git-core/git rerere gc 19:57:12.825732 git.c:479 trace: built-in: git rerere gc ```

-- ZheNing Hu

Next: Taylor Blau
Message 1 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.