]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/repack.c: extract `has_existing_non_kept_packs()`
authorTaylor Blau <me@ttaylorr.com>
Wed, 13 Sep 2023 19:17:54 +0000 (15:17 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 13 Sep 2023 19:32:47 +0000 (12:32 -0700)
commit4bbfb003c06c9a3b8e02d8957f053ce938c3d93e
tree9bd5b610b4e259de9b0fd28738204b5a8890793c
parentf2d3bf178aaf4e590f3618d657e14aceb44514f0
builtin/repack.c: extract `has_existing_non_kept_packs()`

When there is:

  - at least one pre-existing packfile (which is not marked as kept),
  - repacking with the `-d` flag, and
  - not doing a cruft repack

, then we pass a handful of additional options to the inner
`pack-objects` process, like `--unpack-unreachable`,
`--keep-unreachable`, and `--pack-loose-unreachable`, in addition to
marking any packs we just wrote for promisor remotes as kept in-core
(with `--keep-pack`, as opposed to the presence of a ".keep" file on
disk).

Because we store both cruft and non-cruft packs together in the same
`existing.non_kept_packs` list, it suffices to check its `nr` member to
see if it is zero or not.

But a following change will store cruft- and non-cruft packs separately,
meaning this check would break as a result. Prepare for this by
extracting this part of the check into a new helper function called
`has_existing_non_kept_packs()`.

This patch does not introduce any functional changes, but prepares us to
make a more isolated change in a subsequent patch.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/repack.c