From 6a8e5dd5a97fb7c04f0c7718df52bf53e3b4d39c Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 2 Mar 2015 21:50:16 -0800 Subject: [PATCH] genindex.sh: take optional project name to increase speed If an optional project name is given, then only the entry for that project name will be updated. Running git config unnecessarily thousands of times just to add or remove one entry makes project creation and deletion unnecessarily slow. Instead we can use join to extract the previously computed values for all the entries we're not updating to save time. It's not so much the actual time it takes to retrieve the config entry as it is the disk waiting to access files that may not be in the cache and also the churn of creating all those git processes. --- gitweb/genindex.sh | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/gitweb/genindex.sh b/gitweb/genindex.sh index bdc36d9..14f9895 100755 --- a/gitweb/genindex.sh +++ b/gitweb/genindex.sh @@ -2,10 +2,16 @@ # # genindex - Generate gitweb project list from Girocco's +# Usage: genindex.sh [project-to-update] +# +# If project-to-update is given, then only that one will be updated + . @basedir@/shlib.sh set -e +update="${1%.git}" + # Use the correct umask so the list file is group-writable, if owning_group set if [ -n "$cfg_owning_group" ]; then umask 002 @@ -16,9 +22,23 @@ fi # both the owner email and in the project name. Otherwise '+' will be # displayed as a ' ' in the owner email and will cause a project name # containing it to be omitted from the project list page. -get_repo_list | while read proj; do - echo "$proj $(cd "$cfg_reporoot/$proj.git" && config_get owner)" -done | LC_ALL=C sort -k 1,1 >/tmp/gitproj.list.$$ + +if [ -z "$update" ] || [ ! -s "$cfg_chroot/etc/gitproj.list" ]; then + # Must read all the owners so don't bother with join at all + get_repo_list | while read proj; do + echo "$proj $(cd "$cfg_reporoot/$proj.git" && config_get owner)" + done | LC_ALL=C sort -k 1,1 >/tmp/gitproj.list.$$ +else + get_repo_list | LC_ALL=C sort -k 1,1 | \ + LC_ALL=C join -a 1 - "$cfg_chroot/etc/gitproj.list" | \ + while read proj owner; do + if [ -z "$owner" -o "$proj" = "$update" ]; then + echo "$proj $(cd "$cfg_reporoot/$proj.git" && config_get owner)" + else + echo "$proj $owner" + fi + done | LC_ALL=C sort -k 1,1 >/tmp/gitproj.list.$$ +fi sed -e 's/ /.git /;s/+/%2B/g' /tmp/gitweb.list.$$ # Set the proper group, if configured, before the move -- 2.11.4.GIT