summaryrefslogtreecommitdiff
path: root/tools/check_for_upgrade.sh
diff options
context:
space:
mode:
authorMarc Cornellà <marc@mcornella.com>2024-04-18 07:33:13 +0200
committerMarc Cornellà <marc@mcornella.com>2024-04-18 07:33:13 +0200
commit56cfcb44e7ff730c10c5a00b58f38c33c984c52e (patch)
treee6bb2677d21b183ea6e05cfb9a2286c6d0f3ee6d /tools/check_for_upgrade.sh
parentc262ffbb68e6dfc30b619e6ce6bdbd00f27b8a71 (diff)
downloadzsh-56cfcb44e7ff730c10c5a00b58f38c33c984c52e.tar.gz
zsh-56cfcb44e7ff730c10c5a00b58f38c33c984c52e.tar.bz2
zsh-56cfcb44e7ff730c10c5a00b58f38c33c984c52e.zip
fix(updater): abort update if `$ZSH` is not a git repository
Fixes #12298
Diffstat (limited to 'tools/check_for_upgrade.sh')
-rw-r--r--tools/check_for_upgrade.sh10
1 files changed, 6 insertions, 4 deletions
diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh
index 1cc193bde..a5d2112f6 100644
--- a/tools/check_for_upgrade.sh
+++ b/tools/check_for_upgrade.sh
@@ -20,14 +20,16 @@ zstyle -s ':omz:update' mode update_mode || {
}
# Cancel update if:
-# - the automatic update is disabled.
-# - the current user doesn't have write permissions nor owns the $ZSH directory.
+# - the automatic update is disabled
+# - the current user doesn't have write permissions nor owns the $ZSH directory
# - is not run from a tty
-# - git is unavailable on the system.
+# - git is unavailable on the system
+# - $ZSH is not a git repository
if [[ "$update_mode" = disabled ]] \
|| [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \
|| [[ ! -t 1 ]] \
- || ! command git --version 2>&1 >/dev/null; then
+ || ! command git --version 2>&1 >/dev/null
+ || (builtin cd -q "$ZSH"; ! command git rev-parse --is-inside-work-tree &>/dev/null); then
unset update_mode
return
fi