completion: match ctags symbol names in grep patterns
[gitweb.git] / contrib / completion / git-completion.bash
index 888e8e10ccd932df3aa8f30a3d83441d5485fc30..af283cb73b0b71490948f755c82339b688b77095 100755 (executable)
@@ -1429,6 +1429,10 @@ _git_gitk ()
        _gitk
 }
 
+__git_match_ctag() {
+       awk "/^${1////\\/}/ { print \$1 }" "$2"
+}
+
 _git_grep ()
 {
        __git_has_doubledash && return
@@ -1451,6 +1455,15 @@ _git_grep ()
                ;;
        esac
 
+       case "$cword,$prev" in
+       2,*|*,-*)
+               if test -r tags; then
+                       __gitcomp "$(__git_match_ctag "$cur" tags)"
+                       return
+               fi
+               ;;
+       esac
+
        __gitcomp "$(__git_refs)"
 }