git-commit-vandalism/builtin
Taylor Blau 05b9013b71 builtin/gc.c: ignore cruft packs with --keep-largest-pack
When cruft packs were implemented, we never adjusted the code for `git
gc`'s `--keep-largest-pack` and `gc.bigPackThreshold` to ignore cruft
packs. This option and configuration option share a common
implementation, but including cruft packs is wrong in both cases:

  - Running `git gc --keep-largest-pack` in a repository where the
    largest pack is the cruft pack itself will make it impossible for
    `git gc` to prune objects, since the cruft pack itself is kept.

  - The same is true for `gc.bigPackThreshold`, if the size of the cruft
    pack exceeds the limit set by the caller.

In the future, it is possible that `gc.bigPackThreshold` could be used
to write a separate cruft pack containing any new unreachable objects
that entered the repository since the last time a cruft pack was
written.

There are some complexities to doing so, mainly around handling
pruning objects that are in an existing cruft pack that is above the
threshold (which would either need to be rewritten, or else delay
pruning). Rewriting a substantially similar cruft pack isn't ideal, but
it is significantly better than the status-quo.

If users have large cruft packs that they don't want to rewrite, they
can mark them as `*.keep` packs. But in general, if a repository has a
cruft pack that is so large it is slowing down GC's, it should probably
be pruned anyway.

In the meantime, ignore cruft packs in the common implementation for
both of these options, and add a pair of tests to prevent any future
regressions here.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2023-04-18 14:56:47 -07:00
..
add.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
am.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
annotate.c strvec: rename struct fields 2020-07-30 19:18:06 -07:00
apply.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
archive.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
bisect.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
blame.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
branch.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
bugreport.c setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -07:00
bundle.c setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -07:00
cat-file.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
check-attr.c write-or-die.h: move declarations for write-or-die.c functions from cache.h 2023-03-21 10:56:54 -07:00
check-ignore.c write-or-die.h: move declarations for write-or-die.c functions from cache.h 2023-03-21 10:56:54 -07:00
check-mailmap.c write-or-die.h: move declarations for write-or-die.c functions from cache.h 2023-03-21 10:56:54 -07:00
check-ref-format.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
checkout--worker.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
checkout-index.c setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -07:00
checkout.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
clean.c setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -07:00
clone.c Merge branch 'jc/clone-object-format-from-void' 2023-04-11 13:49:13 -07:00
column.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
commit-graph.c environment.h: move declarations for environment.c functions from cache.h 2023-03-21 10:56:53 -07:00
commit-tree.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
commit.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
config.c setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -07:00
count-objects.c environment.h: move declarations for environment.c functions from cache.h 2023-03-21 10:56:53 -07:00
credential-cache--daemon.c abspath.h: move absolute path functions from cache.h 2023-03-21 10:56:52 -07:00
credential-cache.c write-or-die.h: move declarations for write-or-die.c functions from cache.h 2023-03-21 10:56:54 -07:00
credential-store.c write-or-die.h: move declarations for write-or-die.c functions from cache.h 2023-03-21 10:56:54 -07:00
credential.c builtins: mark unused prefix parameters 2023-03-28 14:11:24 -07:00
describe.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
diagnose.c abspath.h: move absolute path functions from cache.h 2023-03-21 10:56:52 -07:00
diff-files.c cocci: apply "pending" index-compatibility to some "builtin/*.c" 2022-11-21 12:06:15 +09:00
diff-index.c setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -07:00
diff-tree.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
diff.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
difftool.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
fast-export.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
fast-import.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
fetch-pack.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
fetch.c Merge branch 'ds/fetch-bundle-uri-with-all' 2023-04-06 13:38:32 -07:00
fmt-merge-msg.c wrapper.h: move declarations for wrapper.c functions from cache.h 2023-03-21 10:56:53 -07:00
for-each-ref.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
for-each-repo.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
fsck.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
fsmonitor--daemon.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
gc.c builtin/gc.c: ignore cruft packs with --keep-largest-pack 2023-04-18 14:56:47 -07:00
get-tar-commit-id.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
grep.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
hash-object.c write-or-die.h: move declarations for write-or-die.c functions from cache.h 2023-03-21 10:56:54 -07:00
help.c setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -07:00
hook.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
index-pack.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
init-db.c setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -07:00
interpret-trailers.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
log.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
ls-files.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
ls-remote.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
ls-tree.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
mailinfo.c environment.h: move declarations for environment.c functions from cache.h 2023-03-21 10:56:53 -07:00
mailsplit.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
merge-base.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
merge-file.c setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -07:00
merge-index.c builtins: mark unused prefix parameters 2023-03-28 14:11:24 -07:00
merge-ours.c builtins: mark unused prefix parameters 2023-03-28 14:11:24 -07:00
merge-recursive.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
merge-tree.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
merge.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
mktag.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
mktree.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
multi-pack-index.c environment.h: move declarations for environment.c functions from cache.h 2023-03-21 10:56:53 -07:00
mv.c setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -07:00
name-rev.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
notes.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
pack-objects.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
pack-redundant.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
pack-refs.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
patch-id.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
prune-packed.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
prune.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
pull.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
push.c environment.h: move declarations for environment.c functions from cache.h 2023-03-21 10:56:53 -07:00
range-diff.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
read-tree.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
rebase.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
receive-pack.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
reflog.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
remote-ext.c builtins: annotate always-empty prefix parameters 2023-03-28 14:11:24 -07:00
remote-fd.c builtins: annotate always-empty prefix parameters 2023-03-28 14:11:24 -07:00
remote.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
repack.c builtin/repack.c: fix incorrect reference to '-C' 2023-04-18 14:56:47 -07:00
replace.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
rerere.c wrapper.h: move declarations for wrapper.c functions from cache.h 2023-03-21 10:56:53 -07:00
reset.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
rev-list.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
rev-parse.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
revert.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
rm.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
send-pack.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
shortlog.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
show-branch.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
show-index.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
show-ref.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
sparse-checkout.c Merge branch 'ws/sparse-check-rules' 2023-04-11 13:49:12 -07:00
stash.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
stripspace.c write-or-die.h: move declarations for write-or-die.c functions from cache.h 2023-03-21 10:56:54 -07:00
submodule--helper.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
symbolic-ref.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
tag.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
unpack-file.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
unpack-objects.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
update-index.c write-or-die.h: move declarations for write-or-die.c functions from cache.h 2023-03-21 10:56:54 -07:00
update-ref.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
update-server-info.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
upload-archive.c builtins: annotate always-empty prefix parameters 2023-03-28 14:11:24 -07:00
upload-pack.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
var.c builtins: mark unused prefix parameters 2023-03-28 14:11:24 -07:00
verify-commit.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
verify-pack.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
verify-tag.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
worktree.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
write-tree.c environment.h: move declarations for environment.c functions from cache.h 2023-03-21 10:56:53 -07:00