Re: Why does git track directory listed in .gitignore/".git/info/exclude"?
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 30, 2008, 20:39 UTC
- Message-ID
- <7vprvjgi9v.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <47A06EF9.60704@users.sourceforge.net>
Adam Piatyszek <ediap@users.sourceforge.net> writes:
Show 16 quoted lines
> In my opinion, the exclude matching routine should convert "dir/" to > "dir", especially that the "git status" command lists untracked > directories with the trailing slash "/", e.g: > > ediap@lespaul ~/git/acm_ofdm $ git status > # On branch master > # Untracked files: > # (use "git add <file>..." to include in what will be committed) > # > # ldpc13.bm > # results/ > > So, most newbies will try to add "dir/" to .gitignore or > .git/info/exclude instead of "dir" in such a case. > > Can you seen any drawbacks of such modification?
I do not see a problem if you are saying:
when the user has an entry 'dir/' in .gitignore, it should match directory 'dir'.
However, there is a subtle problem in a naive implementation of that. IOW,
when the user has an entry 'dir/' in .gitignore, behave as if the entry were 'dir' instead.
is wrong.
When you say "foo", you mean "I want either 'foo' that is a non-directory, or everything under 'foo' if that is a directory". When you say "foo/", you are saying "I do not want 'foo' if it is a non-directory. I want everything under 'foo' if and only if that is a directory". Compare:
git ls-files -s Makefile/
git ls-files -s MakefileThe first one is silent, and the latter answers. On the other hand, for a directory, both of these give you the same:
git ls-files Documentation/
git ls-files Documentation