completion: respect $GIT_DIR
[gitweb.git] / contrib / completion / git-completion.bash
index efcd875f91a24389340e0620bc688c00661b6429..5d70cc428642486cdd964bcc51ba39995dd94d67 100644 (file)
@@ -41,6 +41,9 @@ __gitdir ()
        if [ -z "${1-}" ]; then
                if [ -n "${__git_dir-}" ]; then
                        echo "$__git_dir"
+               elif [ -n "${GIT_DIR-}" ]; then
+                       test -d "${GIT_DIR-}" || return 1
+                       echo "$GIT_DIR"
                elif [ -d .git ]; then
                        echo .git
                else