Created
April 7, 2010 13:49
-
-
Save hchbaw/358895 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#autoload +X | |
__git_files () { | |
local expl files ls_opts opts gitdir gitcdup | |
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 | |
gitcdup=$(_call_program gitcdup git rev-parse --show-cdup 2>/dev/null) | |
__git_command_successful || return | |
ls_opts=("--exclude-per-directory=.gitignore") | |
[[ -f "$gitdir/info/exclude" ]] && ls_opts+="--exclude-from=$gitdir/info/exclude" | |
local pathspec="${gitcdup}${PREFIX}" | |
if [[ $#PREFIX -gt 0 ]]; then | |
pathspec=${pathspec}* | |
fi | |
files=$(_call_program files git ls-files -z --full-name $ls_opts $opts -- $pathspec 2>/dev/null) | |
__git_command_successful || return | |
files=(${(ps:\0:)"$(__git_files_relative $files)"}) | |
__git_command_successful || return | |
local k | |
if [[ $#PREFIX -gt 0 ]]; then | |
(( k=${#${(s./.)PREFIX}} + 1 )) | |
else | |
k=1 | |
fi | |
files=(${(uI:${k}:@)files/\/*//}) | |
#_message $opts | |
_wanted files expl 'index file' _multi_parts $@ - / files | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment