From ab8b9913cb6cba35da3126887d4c0b67f033fffa Mon Sep 17 00:00:00 2001 From: Xuehai Pan Date: Mon, 6 Sep 2021 23:46:56 +0800 Subject: [PATCH] fix(git-auto-fetch): cancel fetch if we don't have permission over git folder (#10010) --- plugins/git-auto-fetch/git-auto-fetch.plugin.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh index 0da84f2f5..dbc949621 100644 --- a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh +++ b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh @@ -11,8 +11,9 @@ function git-fetch-all { return 0 fi - # Do nothing if auto-fetch disabled - if [[ -z "$gitdir" || -f "$gitdir/NO_AUTO_FETCH" ]]; then + # Do nothing if auto-fetch is disabled or don't have permissions + if [[ ! -w "$gitdir" || -f "$gitdir/NO_AUTO_FETCH" ]] || + [[ -f "$gitdir/FETCH_LOG" && ! -w "$gitdir/FETCH_LOG" ]]; then return 0 fi