bash completion for git branch/checkout/etc doesn't escape metacharacters

From: Kevin Stenerson <hidden>
Date: 2016-06-15 23:03:37

The bash completion provided with git doesn't escape or quote parens
in tag or branch names.
Alternatively, it doesn't reject branch or tag names with parenthesis
as an invalid name (as it does for names with spaces or tabs)
Bash treats parentheses in unquoted words as a word separator.

When encountering this problem I was using git version 2.2.2 and bash
version 4.3.11

Steps to reproduce with bash:

    mkdir foo
    cd foo
    git init foo
    touch bar
    git add bar
    git commit -m "Went to a bar"

Then for tags

    git tag 'v1.0.0(215)'

Or branches

    git branch 'mybranch(myuser)'

And the actual bash completion

    git checkout   # Use completion here -- it won't escape the parenthesis
    git checkout master
    git branch -d   # Use completion here -- it won't escape the parenthesis

Similarily, when typing a name with an escape character such as
"mytag\(", it won't complete the name from that point.

This appears to be true for other bash meta characters as well such as
'<', '>', '|', ';', '&'

-----------
Kevin Stenerson
kevin@reflexionhealth.com
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help