tarjoilija/zgen

zgen traverses all subdirectories (including .git directory) when updating.

hvindin opened this issue · 3 comments

On my machine with zsh 5.3.1 and the latest master for zgen I get the following output from a zgen update:

$ printf "ZSH Version: $(zsh --version)\nZgen Version: "; GIT_DIR=~/.zgen/.git git rev-parse HEAD; zgen update 2>&1 | sed -e "s#$USER#username#g" 
ZSH Version: zsh 5.3.1 (x86_64-redhat-linux-gnu)
Zgen Version: ffd3f50addf7a0106d9ea199025eb99efbb858f4
-- zgen: Updating '/home/username/.zgen/ascii-soup/zsh-url-highlighter-master/' ...
Current branch master is up to date.
-- zgen: Updating '/home/username/.zgen/.git/branches/' ...
fatal: This operation must be run in a work tree
-- zgen: Updating '/home/username/.zgen/.git/config' ...
zgen-update:cd:3: not a directory: /home/username/.zgen/.git/config
-- zgen: Updating '/home/username/.zgen/.git/description' ...
zgen-update:cd:3: not a directory: /home/username/.zgen/.git/description
-- zgen: Updating '/home/username/.zgen/.git/FETCH_HEAD' ...
zgen-update:cd:3: not a directory: /home/username/.zgen/.git/FETCH_HEAD
-- zgen: Updating '/home/username/.zgen/.git/HEAD' ...
zgen-update:cd:3: not a directory: /home/username/.zgen/.git/HEAD
-- zgen: Updating '/home/username/.zgen/.git/hooks/' ...
fatal: This operation must be run in a work tree
-- zgen: Updating '/home/username/.zgen/.git/index' ...
zgen-update:cd:3: not a directory: /home/username/.zgen/.git/index
-- zgen: Updating '/home/username/.zgen/.git/info/' ...
fatal: This operation must be run in a work tree
-- zgen: Updating '/home/username/.zgen/.git/logs/' ...
fatal: This operation must be run in a work tree
-- zgen: Updating '/home/username/.zgen/.git/objects/' ...
fatal: This operation must be run in a work tree
-- zgen: Updating '/home/username/.zgen/.git/packed-refs' ...
zgen-update:cd:3: not a directory: /home/username/.zgen/.git/packed-refs
-- zgen: Updating '/home/username/.zgen/.git/refs/' ...
fatal: This operation must be run in a work tree
-- zgen: Updating '/home/username/.zgen/unixorn/autoupdate-zgen-master/' ...
Current branch master is up to date.
-- zgen: Updating '/home/username/.zgen/zsh-users/zsh-autosuggestions-master/' ...
Current branch master is up to date.
-- zgen: Updating '/home/username/.zgen/zsh-users/zsh-completions-master/' ...
Current branch master is up to date.
-- zgen: Updating '/home/username/.zgen/zsh-users/zsh-history-substring-search-master/' ...
Current branch master is up to date.
-- zgen: Updating '/home/username/.zgen/zsh-users/zsh-syntax-highlighting-master/' ...
Current branch master is up to date.
-- zgen: Deleting `/home/username/.zgen/init.zsh` ...

This seems to be caused by this bit of zgen-update:
for repo in "${ZGEN_DIR}"/*/*; do

I've fixed this in my own fork of zgen by changing that line to:
for repo in "${ZGEN_DIR}"/(^.git)/*; do

which will match alldirectories in the zgen_dir that don't match '.git'

I'll create a pull request shortly, but I'd be interested to know if others are seeing the same issue.

For me, * does not match dot files. Is that a zsh setting?

Odd, it never actually occured to me that this was something I had set in my dotfiles a few years ago, found this in my .zshenv:

setopt globdots

Ok, so maybe it would have been better to set NO_GLOBDOTS locally, rather than my fix in #109?