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

Re: [PATCH] Support \ in non-wildcard .gitignore entries

From
Finn Arne Gangstad <finnag@pvv.org>
Date
Feb 10, 2009, 12:58 UTC
Message-ID
<20090210125800.GA14800@pvv.org>
In-Reply-To
<alpine.DEB.1.00.0902101354460.10279@pacific.mpi-cbg.de>
On Tue, Feb 10, 2009 at 01:56:36PM +0100, Johannes Schindelin wrote:
Show 19 quoted lines
> Hi,
> 
> On Tue, 10 Feb 2009, Finn Arne Gangstad wrote:
> 
> > If you had an exclude-pattern with a backslash in it, e.g. "\#foo",
> > this would not work, since git would do a strcmp of the exclude pattern
> > and the filename. Only wildcard patterns were matched with fnmatch,
> > which does the right thing with backslashes. We now also treat all patterns
> > containing backslashes as wildcards.
> > 
> > De-escaping the pattern while reading the .gitignore file is error prone,
> > since that would break patterns with both backslashes and wildcards.
> > E.g. "\\*.c" would be translated to "\*.c" before fnmatch got it,
> > and would change the meaning of the rule dramatically.
> 
> I am not sure I understand (maybe a test case would help, but that test 
> case would have to be disabled on Windows, I guess):
> 
> You mean that '\#abc' would match '\#abc', but '\#abc*' would not?

Currently, \#abc does not match a file named #abc, but \#abc* does. With the patch, both will match.

- Finn Arne
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 3 of 13 in “Support \ in non-wildcard .gitignore entries”
  1. Support \ in non-wildcard .gitignore entriesFinn Arne Gangstad, Feb 10, 2009
  2. Johannes SchindelinFeb 10, 2009
  3. Finn Arne GangstadFeb 10, 2009
  4. Johannes SchindelinFeb 10, 2009
  5. Support "\" in non-wildcard exclusion entriesFinn Arne Gangstad, Feb 10, 2009
  6. Johannes SchindelinFeb 10, 2009
  7. Finn Arne GangstadFeb 10, 2009
  8. Junio C HamanoFeb 10, 2009
  9. Junio C HamanoFeb 10, 2009
  10. Finn Arne GangstadFeb 10, 2009
  11. Support "\" in non-wildcard exclusion entriesFinn Arne Gangstad, Feb 12, 2009
  12. Johannes SchindelinFeb 12, 2009
  13. Junio C HamanoFeb 12, 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.