From a2f03b0ec8a69049343a00f522a88ae280235176 Mon Sep 17 00:00:00 2001 From: SZEDER Gábor Date: Fri, 3 Feb 2017 03:48:15 +0100 Subject: completion: ensure that the repository path given on the command line exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The __gitdir() helper function prints the path to the git repository to its stdout or stays silent and returns with error when it can't find a repository or when the repository given via $GIT_DIR doesn't exist. This is not the case, however, when the path in $__git_dir, i.e. the path to the repository specified on the command line via 'git --git-dir=', doesn't exist: __gitdir() still outputs it as if it were a real existing repository, making some completion functions believe that they operate on an existing repository. Check that the path in $__git_dir exists and return with error without printing anything to stdout if it doesn't. Signed-off-by: SZEDER Gábor Signed-off-by: Junio C Hamano --- contrib/completion/git-completion.bash | 1 + 1 file changed, 1 insertion(+) (limited to 'contrib/completion/git-completion.bash') diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index a43322b04a..9280132926 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -40,6 +40,7 @@ __gitdir () { if [ -z "${1-}" ]; then if [ -n "${__git_dir-}" ]; then + test -d "$__git_dir" || return 1 echo "$__git_dir" elif [ -n "${GIT_DIR-}" ]; then test -d "${GIT_DIR-}" || return 1 -- cgit v1.3