Re: Cannot negate `*` ignore pattern for directory with space in the name
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Sep 18, 2018, 17:59 UTC
- Message-ID
- <CACsJy8Cbp+1-CXMup4m=qLgJA511X0NtM51sFma_8nmp4_EhKg@mail.gmail.com>
- In-Reply-To
- <955f404f-83ed-758e-017b-d6b4a1f69ef7@catalyst.net.nz>
On Tue, Sep 18, 2018 at 6:13 AM Victor Engmark <victorengmark@catalyst.net.nz> wrote:
Show 15 quoted lines
> > To reproduce (from <https://unix.stackexchange.com/q/469708/3645>): > > $ cd "$(mktemp --directory)" > $ mkdir foo\ bar > $ touch foo\ bar/test > $ git init > Initialized empty Git repository in /tmp/tmp.iGmBR6y2xR/.git/ > $ git status --short > ?? foo bar/ > $ cat > .gitignore << EOF > > * > > !foo bar > > !foo\ bar > > !"foo bar"
No need to quote, either with double quotes or backslashes. They are interpreted as literal " and \
> $ git status --short > [no output]
It's not exactly a bug, more like a trap. '*' matches anything, at every level. So even if you negate 'foo bar', when we check 'foo bar/test', '*' pattern applies again and ignores 'foo bar/test'. If the first line in .gitignore is /* instead of * (to keep match anything at the top level directory only), then it should work.
-- Duy