Merge branch 'sg/complete-refs'
[gitweb.git] / contrib / completion / git-completion.bash
index 16623d7c3f001201819949fdf9c006e968e42369..cc1bdf960949cfeb977d8a188a2324b48bf5c6df 100755 (executable)
@@ -110,6 +110,7 @@ __git_ps1_show_upstream ()
        local upstream=git legacy="" verbose=""
 
        # get some config options from git-config
+       local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')"
        while read key value; do
                case "$key" in
                bash.showupstream)
@@ -125,7 +126,7 @@ __git_ps1_show_upstream ()
                        upstream=svn+git # default upstream is SVN if available, else git
                        ;;
                esac
-       done < <(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')
+       done <<< "$output"
 
        # parse configuration values
        for option in ${GIT_PS1_SHOWUPSTREAM}; do
@@ -1444,6 +1445,10 @@ _git_gitk ()
        _gitk
 }
 
+__git_match_ctag() {
+       awk "/^${1////\\/}/ { print \$1 }" "$2"
+}
+
 _git_grep ()
 {
        __git_has_doubledash && return
@@ -1466,6 +1471,15 @@ _git_grep ()
                ;;
        esac
 
+       case "$cword,$prev" in
+       2,*|*,-*)
+               if test -r tags; then
+                       __gitcomp_nl "$(__git_match_ctag "$cur" tags)"
+                       return
+               fi
+               ;;
+       esac
+
        __gitcomp_nl "$(__git_refs)"
 }