On 2011-01-16 21:45 +0100, Boyd Stephen Smith Jr. wrote:

> In <87aaj0vceg....@turtle.gmx.de>, Sven Joachim wrote:
>>On 2011-01-16 20:58 +0100, Boyd Stephen Smith Jr. wrote:
>>> In <20110116160216.GA6914@think.homelan>, Andrei Popescu wrote:
>>>>$ git init
>>>>Initialized empty Git repository in /home/amp/Download/gitest/.git/
>>>>$ touch dir/file3
>>>>$ echo '*' > .gitignore
>>>>$ git status -s
>>>>$ echo '!file1' >> .gitignore
>>>>$ echo '!dir/' >> .gitignore
>>>>$ git status -s
>>>>?? file1
>>>>$
>>>>
>>>>Why is 'dir' still ignored?
>>>>
>>> Looks like a bug to me.  It is at least an undocumented feature.
>>
>>The FAQ mentions¹ that you cannot add empty directories in git, and the
>>'*' in .gitignore means that no _files_ below dir/ will be added.
>
> !dir/ doesn't just match a directory.  Per the gitignore(5) manpage:
>        ·   An optional prefix !  which negates the pattern; any matching file
>            excluded by a previous pattern will become included again. If a
>            negated pattern matches, this will override lower precedence
>            patterns sources.
>
>        ·   If the pattern ends with a slash, it is removed for the purpose of
>            the following description, but it would only find a match with a
>            directory. In other words, foo/ will match a directory foo and
>            paths underneath it, but will not match a regular file or a
>            symbolic link foo (this is consistent with the way how pathspec
>            works in general in git).

I see.  Indeed, even replacing "!dir/" with "!dir/*" or "!dir/file3" in
Andrei's example does not persuade "git status -s" to mention the file.
This seems to be a bug indeed, taking it to g...@vger.kernel.org would be
good.

Sven


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/871v4cv9oa....@turtle.gmx.de

Reply via email to