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

Re: Wrong gitattributes documentation?

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 3, 2017, 00:01 UTC
Message-ID
<xmqq8tlax7lm.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<e7734a23-12b2-8f62-ab5c-c856d59e3010@pasing.net>
Rene Pasing <rene@pasing.net> writes:
Show 8 quoted lines
> The problem is, the documentation[1] says: "The rules how the pattern
> matches paths are the same as in .gitignore files; see gitignore[5].",
> so when I have a pattern like '/images/', it should match on all
> files+folders under /images, even the directory itself, right?
>
> Or when
> I'd use '/images/*', it should match on all files+folders under
> /images, right?

My reading of "PATTERN FORMAT" section in "git help ignore" says it shouldn't.

 - If the pattern does not contain a slash '/', Git treats it as
   a shell glob pattern and checks for a match against the
   pathname relative to the location of the `.gitignore` file
   (relative to the toplevel of the work tree if not from a
   `.gitignore` file).
 - Otherwise, Git treats the pattern as a shell glob suitable
   for consumption by fnmatch(3) with the FNM_PATHNAME flag:
   wildcards in the pattern will not match a / in the pathname.
   For example, "Documentation/{asterisk}.html" matches
   "Documentation/git.html" but not "Documentation/ppc/ppc.html"
   or "tools/perf/Documentation/perf.html".
Your "/images/*" is the "Otherwise" case, isn't it?
Previous: Rene PasingNext: Rene Pasing
Message 2 of 4 in “Wrong gitattributes documentation?”
  1. Rene PasingJun 2, 2017
  2. Junio C HamanoJun 3, 2017
  3. Rene PasingJun 3, 2017
  4. Rene PasingJun 3, 2017

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.