From dbadbd75efe1b7ca5845cbafd3fb5d40d2c25bd4 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Fri, 5 Jul 2013 15:10:08 -0700 Subject: [PATCH] gc.sh: small optimization when dealing with forks When garbage collecting a project with forks it is enough to copy the objects down to just the next fork level. They need not be copied down to further levels (that will happen when the next level is garbage collected). Also do not try to copy objects into a non-existent fork or a fork that is a symbolic link. --- jobd/gc.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/jobd/gc.sh b/jobd/gc.sh index a0c4b3a..b74eb0e 100755 --- a/jobd/gc.sh +++ b/jobd/gc.sh @@ -26,17 +26,23 @@ progress "+ [$proj] garbage check (`date`)" # the redundant ones again then forkdir="$1" if [ -d "../${forkdir##*/}" ]; then - get_repo_list "$forkdir/" | + # It is enough to copy objects just one level down and get_repo_list + # takes a regular expression (which is automatically prefixed with '^') + # so we can easily match forks exactly one level down from this project + get_repo_list "$forkdir/[^/]*:" | while read fork; do + # Ignore forks that do not exist or are symbolic links + [ ! -L "$cfg_reporoot/$fork.git" -a -d "$cfg_reporoot/$fork.git" ] || \ + continue # Match objects in parent project for d in objects/?? objects/pack; do [ "$d" != "objects/??" ] || continue mkdir -p "$cfg_reporoot/$fork.git/$d" - [ "$d" != "objects/pack" ] || + [ "$d" != "objects/pack" ] || \ [ "$(echo objects/pack/*)" != \ "objects/pack/*" ] || \ continue - ln -f "$d"/* "$cfg_reporoot/$fork.git/$d" ||: + ln -f "$d"/* "$cfg_reporoot/$fork.git/$d" || : done done fi -- 2.11.4.GIT