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

Re: [PATCH] gitignore(5): Allow "foo/" in ignore list to match directory "foo"

From
APAdam Piatyszek <ediap@users.sourceforge.net>
Date
Jan 31, 2008, 22:53 UTC
Message-ID
<47A25180.5000903@users.sourceforge.net>
In-Reply-To
<7vr6fxbr5a.fsf@gitster.siamese.dyndns.org>
* Junio C Hamano [31 I 2008 22:51]:
Show 13 quoted lines
> [PATCH] gitignore(5): Allow "foo/" in ignore list to match directory "foo"
> 
> A pattern "foo/" in the exclude list did not match directory
> "foo", but a pattern "foo" did.  This just strips the trailing
> slash from such input.
> 
> This makes the behaviour slightly inconsistent with that of
> pathspecs, where "foo/" only matches directory "foo" and not
> regular file "foo" and make "foo/" in the ignore list match
> regular file "foo" happily.  This may hopefully does not matter
> in practice.
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This is more or less what I suggested originally. ;-)

Anyway, even if this new behaviour is not consistent with that of pathspecs, it is not worse than the current behaviour of git. I.e. now you have to use "foo" to ignore the "foo" directory and its contents, but it does not protect you from masking the file "foo" in the same repository.

However, it is not possible to have both the "foo" directory and "foo" file in the same directory level of a repository at the same time. So, the problem with this patch might be only when one replaces the ignored directory "foo" with a file using the same name and forgets to remove the "foo/" entry from .gitignore or .git/info/exclude. But exactly the same situation can occur for the current implementation.

So, I tend to agree that your latest patch is a sensible solution for 99.9% of cases.

BR, /Adam

-- 
.:.  Adam Piatyszek (ediap)  .:.....................................:.
.:.  ediap@users.sourceforge.net  .:................................:.
Previous: Junio C HamanoNext: Andreas Ericsson
Message 17 of 20 in “Why does git track directory listed in .gitignore/".git/info/exclude"?”
  1. pradeep singh rautelaJan 23, 2008
  2. pradeep singh rautelaJan 23, 2008
  3. Linus TorvaldsJan 23, 2008
  4. pradeep singh rautelaJan 24, 2008
  5. Adam PiatyszekJan 30, 2008
  6. Junio C HamanoJan 30, 2008
  7. Junio C HamanoJan 30, 2008
  8. Adam PiatyszekJan 31, 2008
  9. *Re: Why does git track directory listed in .gitignore/".git/info/exclude"?Junio C Hamano, Jan 31, 2008
  10. gitignore(5): Allow "foo/" in ignore list to match directory "foo"Junio C Hamano, Jan 31, 2008
  11. Jeff KingJan 31, 2008
  12. Junio C HamanoJan 31, 2008
  13. Jeff KingJan 31, 2008
  14. Johannes SchindelinJan 31, 2008
  15. pradeep singh rautelaJan 31, 2008
  16. Junio C HamanoJan 31, 2008
  17. Adam PiatyszekJan 31, 2008
  18. Andreas EricssonFeb 1, 2008
  19. Adam PiatyszekJan 31, 2008
  20. Wayne DavisonJan 23, 2008

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.