From: Junio C Hamano Date: Tue, 21 Oct 2014 20:28:50 +0000 (-0700) Subject: Merge branch 'js/completion-hide-not-a-repo' X-Git-Tag: v2.2.0-rc0~26 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/693f62ff6862b2bcee2bfba8db8d1e9196fa239c?ds=sidebyside;hp=-c Merge branch 'js/completion-hide-not-a-repo' Some internal error messages leaked out of the bash completion when typing "git cmd " and the machinery tried to complete refnames. * js/completion-hide-not-a-repo: completion: silence "fatal: Not a git repository" error --- 693f62ff6862b2bcee2bfba8db8d1e9196fa239c diff --combined contrib/completion/git-completion.bash index d548e99ebc,80e422f9d9..8704451e52 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@@ -281,12 -281,16 +281,12 @@@ __gitcomp_file ( # argument, and using the options specified in the second argument. __git_ls_files_helper () { - ( - test -n "${CDPATH+set}" && unset CDPATH - cd "$1" - if [ "$2" == "--committable" ]; then - git diff-index --name-only --relative HEAD - else - # NOTE: $2 is not quoted in order to support multiple options - git ls-files --exclude-standard $2 - fi - ) 2>/dev/null + if [ "$2" == "--committable" ]; then + git -C "$1" diff-index --name-only --relative HEAD + else + # NOTE: $2 is not quoted in order to support multiple options + git -C "$1" ls-files --exclude-standard $2 + fi 2>/dev/null } @@@ -384,7 -388,8 +384,8 @@@ __git_refs ( ;; *) echo "HEAD" - git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##" + git for-each-ref --format="%(refname:short)" -- \ + "refs/remotes/$dir/" 2>/dev/null | sed -e "s#^$dir/##" ;; esac } @@@ -518,7 -523,7 +519,7 @@@ __git_complete_index_file ( ;; esac - __gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_" + __gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_" } __git_complete_file ()