#autoload +X local expl files ls_opts opts gitdir dirdiff i tmp zparseopts -D -E -a opts -- -cached -deleted -modified -others -ignored -unmerged -killed gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null) __git_command_successful || return ls_opts=("--exclude-per-directory=.gitignore") [[ -f "$gitdir/info/exclude" ]] && ls_opts+="--exclude-from=$gitdir/info/exclude" files=(${(ps:\0:)"$(cd $gitdir/..; _call_program files git ls-files -z $ls_opts $opts 2>/dev/null)"}) __git_command_successful || return [[ -n $gitdir ]] || return if [[ ! -d .git ]] { dirdiff=${PWD#${gitdir%/.git}} repeat ${#${(s:/:)dirdiff}}; do tmp+='../' done dirdiff=${dirdiff#/} for (( i=1; i <= $#files; i++)) { if [[ $files[$i] == $dirdiff/* ]] { files[$i]=${files[$i]#$dirdiff/} } else { files[$i]=$tmp${files[$i]#$dirdiff/} } } } _wanted files expl 'index file' _multi_parts $@ - / files