From 7d2ea090cdf4eeb952ff19929490bd22fdef1f59 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Tue, 7 Jul 2020 12:55:23 -0700 Subject: [PATCH] gitweb/genindex.sh: maintain a gitdir.list file The gitdir.list file contains two fields on each line, the project name followed by a space, followed by the full, absolute, physical path to the project's "GIT_DIR". By using the gitdir.list file it's always possible to translate a full absolute physical path back into the correct project name (notwitstanding any bind mounts that cause a project to be located in more than one physical location). Signed-off-by: Kyle J. McKay --- gitweb/genindex.sh | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/gitweb/genindex.sh b/gitweb/genindex.sh index 99e24da..06eda60 100755 --- a/gitweb/genindex.sh +++ b/gitweb/genindex.sh @@ -25,15 +25,21 @@ fi if [ -z "$update" ] || [ ! -s "$cfg_projlist_cache_dir/gitproj.list" ]; then # Must read all the owners so don't bother with join at all + exec 3>/tmp/gitdir.listu.$$ get_repo_list | while read proj; do - echo "$proj $(cd "$cfg_reporoot/$proj.git" && config_get owner)" + echo "$proj $(cd "$cfg_reporoot/$proj.git" && + echo "$proj $(pwd -P)" >&3 && + config_get owner)" done | perl -MDigest::MD5=md5_hex -ne \ '@_=split;print "$_[0] ",md5_hex(lc($_[1]))," $_[1]\n";' | LC_ALL=C sort -k 1,1 >/tmp/gitproj.list.$$ test $? -eq 0 + exec 3>&- + LC_ALL=C sort -k 1,1 /tmp/gitdir.list.$$ + rm -f /tmp/gitdir.listu.$$ else - get_repo_list | LC_ALL=C sort -k 1,1 | - LC_ALL=C join -a 1 - "$cfg_projlist_cache_dir/gitproj.list" | + get_repo_list | LC_ALL=C sort -k 1,1 >/tmp/gitproj.srt.$$ + LC_ALL=C join -a 1 /tmp/gitproj.srt.$$ "$cfg_projlist_cache_dir/gitproj.list" | while read proj hash owner; do if [ "$proj" = "$update" ] || [ -z "$owner" ] || [ -z "$hash" ]; then echo "$proj recalc $(cd "$cfg_reporoot/$proj.git" && config_get owner)" @@ -44,14 +50,26 @@ else '@_=split;print "$_[0] ",$_[1] eq "recalc"?md5_hex(lc($_[2])):$_[1]," $_[2]\n";' | LC_ALL=C sort -k 1,1 >/tmp/gitproj.list.$$ test $? -eq 0 + LC_ALL=C join -a 1 -t ' ' /tmp/gitproj.srt.$$ "$cfg_projlist_cache_dir/gitdir.list" | + while read proj path; do + if [ "$proj" = "$update" ] || [ -z "$path" ]; then + echo "$proj $(cd "$cfg_reporoot/$proj.git" && pwd -P)" + else + echo "$proj $path" + fi + done | + LC_ALL=C sort -k 1,1 >/tmp/gitdir.list.$$ + test $? -eq 0 + rm -f /tmp/gitproj.srt.$$ fi cut -d ' ' -f 1,3- /tmp/gitweb.list.$$ # Set the proper group, if configured, before the move if [ -n "$cfg_owning_group" ]; then - chgrp "$cfg_owning_group" /tmp/gitproj.list.$$ /tmp/gitweb.list.$$ + chgrp "$cfg_owning_group" /tmp/gitproj.list.$$ /tmp/gitdir.list.$$ /tmp/gitweb.list.$$ fi # Atomically move into place mv -f /tmp/gitproj.list.$$ "$cfg_projlist_cache_dir/gitproj.list" +mv -f /tmp/gitdir.list.$$ "$cfg_projlist_cache_dir/gitdir.list" mv -f /tmp/gitweb.list.$$ "$cfg_projlist_cache_dir/gitweb.list" -- 2.11.4.GIT