From: Junio C Hamano Date: Wed, 27 Oct 2010 04:39:03 +0000 (-0700) Subject: Merge branch 'ml/completion-zsh' X-Git-Tag: v1.7.4-rc0~169 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/5a3a484d577d8612f729d64f3a069e63df07ec07?ds=inline;hp=-c Merge branch 'ml/completion-zsh' * ml/completion-zsh: completion: make compatible with zsh --- 5a3a484d577d8612f729d64f3a069e63df07ec07 diff --combined contrib/completion/git-completion.bash index f83f019ca9,feab651be8..64341d53cc --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@@ -21,6 -21,11 +21,11 @@@ # 2) Added the following line to your .bashrc: # source ~/.git-completion.sh # + # Or, add the following lines to your .zshrc: + # autoload bashcompinit + # bashcompinit + # source ~/.git-completion.sh + # # 3) Consider changing your PS1 to also show the current branch: # PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ ' # @@@ -138,11 -143,12 +143,12 @@@ __git_ps1_show_upstream ( # get the upstream from the "git-svn-id: ..." in a commit message # (git-svn uses essentially the same procedure internally) local svn_upstream=($(git log --first-parent -1 \ - --grep="^git-svn-id: \(${svn_url_pattern:2}\)" 2>/dev/null)) + --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null)) if [[ 0 -ne ${#svn_upstream[@]} ]]; then svn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]} svn_upstream=${svn_upstream%@*} - for ((n=1; "$n" <= "${#svn_remote[@]}"; ++n)); do + local n_stop="${#svn_remote[@]}" + for ((n=1; n <= n_stop; ++n)); do svn_upstream=${svn_upstream#${svn_remote[$n]}} done @@@ -1125,7 -1131,7 +1131,7 @@@ _git_diff ( case "$cur" in --*) __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex - --base --ours --theirs + --base --ours --theirs --no-index $__git_diff_common_options " return @@@ -2339,6 -2345,11 +2345,11 @@@ _git ( { local i c=1 command __git_dir + if [[ -n $ZSH_VERSION ]]; then + emulate -L bash + setopt KSH_TYPESET + fi + while [ $c -lt $COMP_CWORD ]; do i="${COMP_WORDS[c]}" case "$i" in @@@ -2372,17 -2383,22 +2383,22 @@@ fi local completion_func="_git_${command//-/_}" - declare -F $completion_func >/dev/null && $completion_func && return + declare -f $completion_func >/dev/null && $completion_func && return local expansion=$(__git_aliased_command "$command") if [ -n "$expansion" ]; then completion_func="_git_${expansion//-/_}" - declare -F $completion_func >/dev/null && $completion_func + declare -f $completion_func >/dev/null && $completion_func fi } _gitk () { + if [[ -n $ZSH_VERSION ]]; then + emulate -L bash + setopt KSH_TYPESET + fi + __git_has_doubledash && return local cur="${COMP_WORDS[COMP_CWORD]}" @@@ -2417,3 -2433,29 +2433,29 @@@ if [ Cygwin = "$(uname -o 2>/dev/null) complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \ || complete -o default -o nospace -F _git git.exe fi + + if [[ -n $ZSH_VERSION ]]; then + shopt () { + local option + if [ $# -ne 2 ]; then + echo "USAGE: $0 (-q|-s|-u)