From ce65b2da21c7f0254b3785f0c90b3f174a2082bc Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Wed, 10 Jun 2020 18:30:20 -0700 Subject: [PATCH] gc-util-functions.sh: adopt single-object loose packs The `git hash-object -w` utility has an "interesting" behavior in that if it's hashing a regular file (S_ISREG) either passed directly as the filename or as an open file handle (via `--stdin`), and the actual size of the file exceeds `core.bigFileThreshold`, then it *always creates a new single-object pack*! (Unless, of course, the object already exists in the repository.) When `git-svn fetch` creates new blobs, it first writes the data to a temporary file and then passes that to `git hash-object -w` (using the `--stdin-paths` option). What this means is that whenever `git-svn fetch` encounters a remote "blob" that exceeds `core.bigFileThreshold` it will be stored directly into a new single-object pack of its own if it does not already exist in the repository. Adopt any such single-object packs as "loose packs" (i.e. they have an "_l" infix right before the ".pack" suffix) to make them participate in pack combining operations. Make this relatively painless for callers by having the `pack_incremental_loose_objects` function perform this "adoption" right before it checks for too many "loose" packs. Signed-off-by: Kyle J. McKay --- jobd/gc-util-functions.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/jobd/gc-util-functions.sh b/jobd/gc-util-functions.sh index 66952c2..c934244 100755 --- a/jobd/gc-util-functions.sh +++ b/jobd/gc-util-functions.sh @@ -186,8 +186,15 @@ pack_incremental_loose_objects() { git prune-packed $quiet fi _packs= - _lpo="--exclude-no-idx --exclude-keep --exclude-bitmap --exclude-bndl" - _lpol="$_lpo --exclude-no-sfx _l" + __lpo="--exclude-no-idx --exclude-keep --exclude-bitmap --exclude-bndl" + _lpo01="$__lpo --exclude-limit 2" + _lpol="$__lpo --exclude-no-sfx _l" + list_packs --quiet $_lpo01 objects/pack 2>/dev/null | + while read -r _apack && _apack="${_apack%.pack}" && [ -n "$_apack" ]; do + case "$_apack" in *_*);;*) + rename_pack "$_apack" "${_apack}_l" || : + esac + done || : { _packs="$(list_packs --quiet --count $_lpol objects/pack || :)" || :; } 2>/dev/null [ "${_packs:-0}" -lt 20 ] || { combine_small_incremental_loose_packs -- 2.11.4.GIT