Merge branch 'js/completion-hide-not-a-repo'
authorJunio C Hamano <gitster@pobox.com>
Tue, 21 Oct 2014 20:28:50 +0000 (13:28 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 21 Oct 2014 20:28:50 +0000 (13:28 -0700)
Some internal error messages leaked out of the bash completion when
typing "git cmd <TAB>" and the machinery tried to complete
refnames.

* js/completion-hide-not-a-repo:
completion: silence "fatal: Not a git repository" error

1  2 
contrib/completion/git-completion.bash
index d548e99ebc213cc107b61acbdafa065bbb46dc30,80e422f9d933307cac43572828c49de6feb0e03e..8704451e52e9ed4239ec7a8e96d3fd8e6be4cb01
@@@ -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 ()