From cbeaefb81084c6428c9ee53cab87cbbd3d34e2a2 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sun, 28 Jun 2020 13:49:37 -0700 Subject: [PATCH] jobd/gc.sh: rename variable to avoid confusion When processing forks of the project being gc'd, a variable named `packs` is used to count the number of packs present in each fork to determine whether or not the fork now `.needsgc`. The variable name used is `packs`. At first glance, this would seem to be very bad as the list of primary packs is stored in the variable named `packs` and bad things would happen if it gets stepped on before it's last needed. However, the forks are processed in an implicit subshell courtesy of a `|` and therefore stepping on the `packs` variable in that subshell has no effect on the `packs` variable outside the subshell. Nevertheless, change the name of the variable used in the subshell to avoid confusion and avoid a surprise bug if at some point in the future that code no longer runs in a subshell. Signed-off-by: Kyle J. McKay --- jobd/gc.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jobd/gc.sh b/jobd/gc.sh index 70cd33b..8f0345f 100755 --- a/jobd/gc.sh +++ b/jobd/gc.sh @@ -1481,8 +1481,8 @@ if [ -n "$gotforks" ]; then fi if ! [ -e "$cfg_reporoot/$fork.git/.needsgc" ]; then # Trigger a mini gc in the fork if it now has too many packs - packs="$(list_packs --quiet --count --exclude-no-idx --exclude-keep "$cfg_reporoot/$fork.git/objects/pack")" || : - if [ -n "$packs" ] && [ "$packs" -ge 20 ]; then + fpackcnt="$(list_packs --quiet --count --exclude-no-idx --exclude-keep "$cfg_reporoot/$fork.git/objects/pack")" || : + if [ -n "$fpackcnt" ] && [ "$fpackcnt" -ge 20 ]; then >"$cfg_reporoot/$fork.git/.needsgc" fi fi -- 2.11.4.GIT