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

Re: [PROPOSAL] .gitignore syntax modification

From
Kevin Ballard <kevin@sb.org>
Date
Oct 9, 2010, 00:03 UTC
Message-ID
<FD4E6D0A-34E6-4FC4-AA7A-327E07AB58D4@sb.org>
In-Reply-To
<loom.20101008T234354-493@post.gmane.org>
On Oct 8, 2010, at 2:58 PM, Maaartin wrote:
Show 8 quoted lines
> You don't. You can do something like
> 
> *.xcodeproj/*
> !.xcodeproj/subdir_with_project
> .xcodeproj/subdir_with_project/*
> !.xcodeproj/subdir_with_project/*.pbxproj
> 
> I'm a beginner but I just stumbled upon this very problem five minutes ago.
That's not the right layout. I'd have to do

*.xcodeproj/* !*.xcodeproj/project.pbxproj */*.xcodeproj/* !*/*.xcodeproj/project.pbxproj

And so on, once for each possible level of nesting.
> The reason for git ignoring everything in the directory without ever looking 
> there is efficiency.
That's not what's happening either. That happens if you ignore the directory itself, such as
*.xcodeproj/
That won't look in the directory at all to match non-ignore patterns. The problem I'm talking about is simply that you cannot write a pattern that includes a slash and have that pattern match at any nesting level.
Upon further reflection, if we stick with platform-provided fnmatch() we don't have to special-case a prefixed **/. We could simply define patterns as always matching in that way, and you can use the already-existing prefixed / to root it at the current level. So if my pattern looks like
*.xcodeproj/*
Then it will attempt to match this pattern against the last 2 path components of any path rooted in this directory. It can simply count the slashes to determine the number of path components. If I really want it to just match *.xcodeproj files in the current directory then my pattern should look like
/*.xcodeproj/*
-Kevin Ballard
Previous: MaaartinNext: Maaartin
Message 3 of 13 in “[PROPOSAL] .gitignore syntax modification”
  1. Kevin BallardOct 8, 2010
  2. MaaartinOct 8, 2010
  3. Kevin BallardOct 9, 2010
  4. MaaartinOct 11, 2010
  5. Nguyen Thai Ngoc DuyOct 13, 2010
  6. Kevin BallardOct 13, 2010
  7. Jonathan NiederOct 13, 2010
  8. Kevin BallardOct 13, 2010
  9. Junio C HamanoOct 13, 2010
  10. Nguyen Thai Ngoc DuyOct 13, 2010
  11. Kevin BallardOct 15, 2010
  12. Nguyen Thai Ngoc DuyOct 15, 2010
  13. Kevin BallardOct 15, 2010

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.