completion: let 'for-each-ref' strip the remote name from remote branches
[gitweb.git] / contrib / completion / git-completion.bash
index 976f8059885cf8f95e440486c01ff92d8425fe68..206eaf0ca5457d48ad422e6a416a893cceca0e4e 100644 (file)
@@ -423,11 +423,10 @@ __git_refs ()
                        # Try to find a remote branch that matches the completion word
                        # but only output if the branch name is unique
                        local ref entry
-                       __git for-each-ref --shell --format="ref=%(refname:strip=2)" \
+                       __git for-each-ref --shell --format="ref=%(refname:strip=3)" \
                                "refs/remotes/" | \
                        while read -r entry; do
                                eval "$entry"
-                               ref="${ref#*/}"
                                if [[ "$ref" == "$match"* ]]; then
                                        echo "$ref"
                                fi
@@ -450,9 +449,9 @@ __git_refs ()
                        case "HEAD" in
                        $match*)        echo "HEAD" ;;
                        esac
-                       __git for-each-ref --format="%(refname:strip=2)" \
+                       __git for-each-ref --format="%(refname:strip=3)" \
                                "refs/remotes/$remote/$match*" \
-                               "refs/remotes/$remote/$match*/**" | sed -e "s#^$remote/##"
+                               "refs/remotes/$remote/$match*/**"
                else
                        local query_symref
                        case "HEAD" in