2013-04-28 48 views
6

首先我鍵入git stash show輸入git存儲時自動完成問題顯示存儲@ {1}

然後鍵入小號標籤,它顯示了git stash show [email protected]{,到現在它工作正常。

但是在我鍵入和標籤,它becames git stash show [email protected]{1},這是明顯錯誤的。

我覺得在.git-completion.bash下面的代碼中可能會出現一些錯誤,但我幾乎看不懂這個。

_git_stash() 
{ 
    local save_opts='--keep-index --no-keep-index --quiet --patch' 
    local subcommands='save list show apply clear drop pop create branch' 
    local subcommand="$(__git_find_on_cmdline "$subcommands")" 
    if [ -z "$subcommand" ]; then 
     case "$cur" in 
     --*) 
      __gitcomp "$save_opts" 
      ;; 
     *) 
      if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then 
       __gitcomp "$subcommands" 
      else 
       COMPREPLY=() 
      fi 
      ;; 
     esac 
    else 
     case "$subcommand,$cur" in 
     save,--*) 
      __gitcomp "$save_opts" 
      ;; 
     apply,--*|pop,--*) 
      __gitcomp "--index --quiet" 
      ;; 
     show,--*|drop,--*|branch,--*) 
      COMPREPLY=() 
      ;; 
     show,*|apply,*|drop,*|pop,*|branch,*) 
      __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \                
        | sed -n -e 's/:.*//p')" 
      ;; 
     *) 
      COMPREPLY=() 
      ;; 
     esac 
    fi 
} 

有誰知道如何解決它? Bash版本:GNU bash,版本4.2.37(2) - 發佈(i386-apple-darwin12.0.0)。

git的版本:1.8.0.3

整個源:https://gist.github.com/pktangyue/5477924

+0

我正在使用bash'4.1.10(1)'。我在'/ etc/bash-completion.d/git-completion.sh'中定義了相同的完成函數,並且完成對我的工作很好。你能提供關於你的bash版本的細節嗎?另外,如果你可以發佈一個鏈接(可能是?)到你完整的'git-completion.sh',它可能對比較有用。 – Tuxdude 2013-04-28 17:15:19

+0

@Tuxdude增加了更多信息。 – pktangyue 2013-04-28 18:41:38

+0

我收集你至少有10個藏有?我試圖複製你的情況。我沒有遇到過這種問題(git 1.8.2.3,bash 4.2.45,Arch Linux x86_64)。 – kampu 2013-05-14 13:49:29

回答

0

擊-完成應該作爲一個單獨的包或多或少獨立擊本身。例如,我有bash版本4.1.10-4和bash完成版本1.3-1從Cygwin和你描述的完成工作,因爲它應該。

請檢查您安裝的Bash-Completion的版本。您也可以嘗試直接從http://bash-completion.alioth.debian.org/安裝最新版本,或嘗試僅使用上游版本替換文件/etc/bash_completion.d/git

0

當我手動下載過期的git完成腳本時,我遇到了同樣的問題。我能夠通過獲得最新的使用自制軟件來修復它。

brew install git bash-completion 

刪除您在「.profile」中可能擁有的舊鏈接。替換爲使用brew中的腳本

if [ -f $(brew --prefix)/etc/bash_completion ]; then 
    . $(brew --prefix)/etc/bash_completion 
fi 

現在,當我選中它時,它會正確完成。 (git stash show stash @ {0 .. give git stash show stash @ {0})