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

Re: [PATCH 2/4] Documentation: clarify effect of '/' in gitignore(5) patterns

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Nov 7, 2011, 10:05 UTC
Message-ID
<CACsJy8AnPD7NFeCbMG+vy5YvWWfb5CwaRX=qRkOE8_Hk_9zUNw@mail.gmail.com>
In-Reply-To
<20111107080842.GB30486@elie.hsd1.il.comcast.net>
2011/11/7 Jonathan Nieder <jrnieder@gmail.com>:
Show 13 quoted lines
> The introduction of directory-only matches in v1.5.5-rc0~208^2~1
> (gitignore(5): Allow "foo/" in ignore list to match directory "foo",
> 2008-01-31) was a small, incremental change to gitignore syntax that
> did not affect the rest of the rules in any major way.  A '/' at the
> end of a pattern means "match directories only" and does not otherwise
> affect the pattern.  And that is how the gitignore(5) manpage explains
> the syntax.
>
> However, to a person parsing an unfamiliar gitignore entry like foo/,
> it is too easy to notice the later (old) rule that describes how
> patterns containing a slash are anchored and miss that the slash
> should have been stripped off before considering whether the rule
> applies.
I think I make this mistake too. Documenting it is one way. Another way is t
Show 6 quoted lines
>
> Let's just explicitly say that patterns are only anchored if they
> contain a slash that is not at the end of the pattern, avoiding this
> confusion.  A more graceful presentation of this material may be
> possible, but for now the goal is to get the facts clear --- we can
> refactor the text to scan well without losing its meaning later.

I think the first slash in 'foo//' may function as the anchor and it's not very clear to me if it's in the middle of pattern of at the end. Of course we could just change the code to strip all trailing slashes.

-- 
Duy
Previous: Jonathan NiederNext: Jonathan Nieder
Message 6 of 10 in “gitignore.5 clarifications”
  1. 0/5 gitignore.5 clarificationsJonathan Nieder, Nov 7, 2011
  2. 1/4 Documentation/gitignore: "foo/" patterns match directories, not files under themJonathan Nieder, Nov 7, 2011
  3. Nguyen Thai Ngoc DuyNov 7, 2011
  4. Junio C HamanoNov 7, 2011
  5. 2/4 Documentation: clarify effect of '/' in gitignore(5) patternsJonathan Nieder, Nov 7, 2011
  6. Nguyen Thai Ngoc DuyNov 7, 2011
  7. 3/4 Documentation: unanchored gitignore patterns match basenameJonathan Nieder, Nov 7, 2011
  8. Nguyen Thai Ngoc DuyNov 7, 2011
  9. 4/4 Documentation/gitignore: explain how to un-ignore part of a directoryJonathan Nieder, Nov 7, 2011
  10. Nguyen Thai Ngoc DuyNov 7, 2011

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.