completion: don't list 'HEAD' when trying refs completion outside of a repo
[gitweb.git] / contrib / completion / git-completion.bash
index af5ad52bb189273ed77072ba473ed0871992538a..19f60931b0cde2f60e502325da0b693ecb7cf96a 100644 (file)
@@ -346,7 +346,11 @@ __git_refs ()
        local list_refs_from=path remote="${1-}"
        local format refs pfx
 
-       if [ -n "$remote" ]; then
+       if [ -z "$remote" ]; then
+               if [ -z "$dir" ]; then
+                       return
+               fi
+       else
                if __git_is_configured_remote "$remote"; then
                        # configured remote takes precedence over a
                        # local directory with the same name
@@ -360,7 +364,7 @@ __git_refs ()
                fi
        fi
 
-       if [ "$list_refs_from" = path ] && [ -d "$dir" ]; then
+       if [ "$list_refs_from" = path ]; then
                case "$cur" in
                refs|refs/*)
                        format="refname"