Thread (12 messages) flat view 12 messages, 4 authors, 2016-06-15

git show doesn't work on file names with square brackets

From: Kirill Likhodedov <hidden>
Date: 2016-06-15 23:08:08

I’ve faced a problem that `git show <rev>:<filename>` returns an error when <filename> contains square brackets.

Interestingly, the problem is reproducible on "GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)", but not on "zsh 5.0.7 (x86_64-pc-linux-gnu)”. The problem is also reproducible when called from a Java program by forking a process with given parameters.

Is it a bug or I just didn’t find the proper way to escape the brackets? 

Steps to reproduce:

    git init brackets
    cd brackets/
    echo ‘asd’ > bra[ckets].txt
    git add bra\[ckets\].txt
    git commit -m initial
    git show HEAD:bra[ckets].txt

Error:
fatal: ambiguous argument 'HEAD:bra[ckets].txt': both revision and filename
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]’

Neither escaping, not quoting doesn’t help:
    git show HEAD:bra\[ckets\].txt
returns the same error

    git show "HEAD:bra\[ckets\].txt”
returns empty output

Thanks a lot!
-- Kirill
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help