From 61f41dde199da137067ab4f97c4e91ae93d739f2 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Wed, 10 Jun 2020 03:15:02 -0700 Subject: [PATCH] git-svn: prune objects before deciding to pack Unfortunately, `git-svn fetch` can end up recreating packed objects as loose objects. If the loose object count appears to be high enough to warrant packing, prune any already-packed objects first and check again. Signed-off-by: Kyle J. McKay --- jobd/gc-git-svn.sh | 2 +- jobd/gc-util-functions.sh | 7 +++++++ taskd/clone.sh | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/jobd/gc-git-svn.sh b/jobd/gc-git-svn.sh index 1b8aa6d..1dbecc2 100755 --- a/jobd/gc-git-svn.sh +++ b/jobd/gc-git-svn.sh @@ -32,7 +32,7 @@ umask 002 v_get_proj_from_dir proj proj="${proj%.git}" -if lotsa_loose_objects; then +if lotsa_loose_pruned_objects; then echo "Packing loose objects ($(date))" pack_incremental_loose_objects echo "Packing and pruning complete ($(date))" diff --git a/jobd/gc-util-functions.sh b/jobd/gc-util-functions.sh index 6eb73f3..b469f75 100755 --- a/jobd/gc-util-functions.sh +++ b/jobd/gc-util-functions.sh @@ -84,6 +84,13 @@ lotsa_loose_objects() { [ ${_objs:-0} -ge 5 ] } +# same as lotsa_loose_objects but first runs `git prune-packed` +lotsa_loose_pruned_objects() { + lotsa_loose_objects || return $? + git prune-packed --quiet + lotsa_loose_objects +} + # pack any existing, non-packed loose objects into a new _l.pack file then run prune-packed # note that prune-packed is NOT run beforehand -- the caller must do that if needed # loose objects need not be part of complete commits/trees as --weak-naming is used diff --git a/taskd/clone.sh b/taskd/clone.sh index a4096b2..44646d6 100755 --- a/taskd/clone.sh +++ b/taskd/clone.sh @@ -399,7 +399,7 @@ case "$url" in fi # Pause briefly before retrying to be friendly to the server # Use that time to pack up loose objects if there are "lotsa" them - if ! lotsa_loose_objects; then + if ! lotsa_loose_pruned_objects; then echo 'Pausing for 120 seconds before retrying' sleep 120 else -- 2.11.4.GIT