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

Re: Oddities in gitignore matching

From
John Thorvald Wodder II <jwodder@gmail.com>
Date
Jun 28, 2022, 13:57 UTC
Message-ID
<288621B7-8418-471B-8C64-3F8AE5AA4DC2@gmail.com>
In-Reply-To
<0871A57F-4AF4-4F45-AC56-10C1817761BB@gmail.com>
On 2022 Jun 28, at 09:48, John Thorvald Wodder II <jwodder@gmail.com> wrote:
> Through further experimentation, I've discovered a fourth oddity with gitignore: If "foo//" (with two or more trailing slashes) is added to .gitignore and `mkdir -p foo/bar` is run, then `git status --ignored=matching --porcelain` won't show "foo/" or "foo/bar/" at all, which is something I'd previously only encountered for completely empty top-level directories.  This holds true no matter how deep or wide you make the directory tree at "foo/", as long as it's all-directories; once a file gets added somewhere under "foo/", the "git status" command shows "foo/" as ignored.
Correction: When a file is added under "foo/", then "git status" shows it as *untracked*, not ignored.  I also see now that a pure-directory tree being absent from "git status" happens even without a .gitignore, so presumably this is intended behavior.  It's just a little odd that, if "foo/" is an empty top-level directory, it only shows up in "git status --ignored=matching" if it's ignored.
-- John Wodder
Previous: John Thorvald Wodder IINext: Phillip Wood
Message 4 of 5 in “Oddities in gitignore matching”
  1. John Thorvald Wodder IIJun 26, 2022
  2. Phillip WoodJun 28, 2022
  3. John Thorvald Wodder IIJun 28, 2022
  4. John Thorvald Wodder IIJun 28, 2022
  5. Phillip WoodJun 29, 2022

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.