git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How do I qualify paths in the .gitignore file w.r.t. the repo root directory?

From
Björn Steinbrink <b.steinbrink@gmx.de>
Date
Feb 26, 2009, 00:45 UTC
Message-ID
<20090226004530.GA11730@atjola.homenet>
In-Reply-To
<7vvdqyyzsr.fsf@gitster.siamese.dyndns.org>
On 2009.02.25 13:25:24 -0800, Junio C Hamano wrote:
Show 9 quoted lines
> Sitaram Chamarty <sitaramc@gmail.com> writes:
> > Do we not want to specify that we don't descend?  The
> > original text does say '...will match a directory foo and
> > paths underneath it'.
> 
> Ok.  If we unignore a directory that does not mean all paths inside it are
> now unignored --- they are still subject to .gitignore rules read from it
> and its subdirectories.  So "will match it and paths inside it" is correct
> but "will ignore it and paths inside it" is not.

I don't think that's good enough. The case in which we ignore directories is impressively hard to describe correctly. Consider this:

.gitignore # Contains foo foo/.gitignore # Contains !bar foo/bar

The current man page says that for "foo/bar" foo/.gitignore has the highest precedence, overriding the patterns from .gitignore. So without further information, one could think that while foo/bar is matched by the "foo" pattern, this is invalidated by the "!bar" rule and thus foo/bar would not be ignored. But of course we don't bother looking into foo at all, so the foo/.gitignore has no effect.

And it gets more interesting:

.gitignore # Contains "foo" and "!foo/bar" foo/bar

Even in this case, foo/bar is ignored. Because again, we don't look into foo at all, so we never even see foo/bar and thus we won't notice that it is to be unignored. So saying "match it and paths inside it" is misleading, because we'll never even see any path inside it that could match, and it might lead to failing gitignore setups like the above.

So maybe instead of "... and paths inside it", we could have something like this:

    If a directory is ignored, git won't look into it at all when
    searching for untracked files. This means that all paths inside it
    are implicitly ignored and that you cannot unignore these paths.
Björn
Previous: Junio C HamanoNext: Sitaram Chamarty
Message 10 of 15 in “How do I qualify paths in the .gitignore file w.r.t. the repo root directory?”
  1. Brent GoodrickFeb 24, 2009
  2. Junio C HamanoFeb 24, 2009
  3. Sitaram ChamartyFeb 24, 2009
  4. Junio C HamanoFeb 24, 2009
  5. Sitaram ChamartyFeb 24, 2009
  6. Sitaram ChamartyFeb 25, 2009
  7. Junio C HamanoFeb 25, 2009
  8. Sitaram ChamartyFeb 25, 2009
  9. Junio C HamanoFeb 25, 2009
  10. Björn SteinbrinkFeb 26, 2009
  11. Sitaram ChamartyFeb 26, 2009
  12. Sitaram ChamartyFeb 26, 2009
  13. Junio C HamanoFeb 26, 2009
  14. Brent GoodrickFeb 25, 2009
  15. Sitaram ChamartyFeb 25, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.