ab8b9913cb6cba35da3126887d4c0b67f033fffa
- Author
- Xuehai Pan <XuehaiPan@outlook.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
fix(git-auto-fetch): cancel fetch if we don't have permission over git folder (#10010)
Diff
1diff --git a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh
2index 0da84f2f5addf7cc1bb95092296e06dd2775294d..dbc949621f4ef0dda9e3864aa45cdf3073171575 100644
3--- a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh
4+++ b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh
5@@ -11,8 +11,9 @@ function git-fetch-all {
6 return 0
7 fi
8
9- # Do nothing if auto-fetch disabled
10- if [[ -z "$gitdir" || -f "$gitdir/NO_AUTO_FETCH" ]]; then
11+ # Do nothing if auto-fetch is disabled or don't have permissions
12+ if [[ ! -w "$gitdir" || -f "$gitdir/NO_AUTO_FETCH" ]] ||
13+ [[ -f "$gitdir/FETCH_LOG" && ! -w "$gitdir/FETCH_LOG" ]]; then
14 return 0
15 fi
16