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

Re: [BUG] gitignore documentation inconsistent with actual behaviour

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 14, 2018, 22:56 UTC
Message-ID
<xmqqk1mk87d0.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<CACsJy8DVSu2Sh34UG4P9aqqEMsY5zOGc61tEizo=0sG4BoSgkw@mail.gmail.com>
Duy Nguyen <pclouds@gmail.com> writes:
Show 9 quoted lines
>> Our matching function comes from rsync originally, whose manpage says:
>>
>>     use ’**’ to match anything, including slashes.
>>
>> I believe this is accurate as far as the implementation goes.
>
> No. "**" semantics is not the same as from rsync. The three cases
> "**/", "/**/" and "/**" were requested by Junio if I remember
> correctly. You can search the mail archive for more information.

Perhaps spelling the rules out would be more benefitial for the purpose of this thread? I do not recall what I requested, but let me throw out my guesses (i.e. what I would have wished if I were making a request to implement something) to keep the thread alive, you can correct me, and people can take it from there to update the docs ;-)

    A double-asterisk, both of whose ends are adjacent to a
    directory boundary (i.e. the beginning of the pattern, the end
    of the pattern or a slash) macthes 0 or more levels of
    directories.  e.g. **/a/b would match a/b, x/a/b, x/y/a/b, but
    not z-a/b.  a/**/b would match a/b, a/x/b, but not a/z-b or
    a-z-b.

What a double-asterisk that does not sit on a directory boundary, e.g. "a**b", "a**/b", "a/**b", or "**a/b", matches, as far as I am concerned, is undefined, meaning that (1) I do not care all that much what the code actually do when a pattern like that is given as long as it does not segfault, and (2) I do not think I would mind changing the behaviour as a "bugfix", if their current behaviour does not make sense and we can come up with a saner alternative.

But the documentation probably should describe what these currently match as the starting point.

Thanks.
Previous: Duy NguyenNext: Duy Nguyen
Message 6 of 17 in “[BUG] gitignore documentation inconsistent with actual behaviour”
  1. danaOct 11, 2018
  2. danaOct 11, 2018
  3. Ævar Arnfjörð BjarmasonOct 11, 2018
  4. danaOct 14, 2018
  5. Duy NguyenOct 14, 2018
  6. Junio C HamanoOct 14, 2018
  7. Duy NguyenOct 15, 2018
  8. Duy NguyenOct 20, 2018
  9. danaOct 20, 2018
  10. Duy NguyenOct 20, 2018
  11. danaOct 20, 2018
  12. wildmatch: change behavior of "foo**bar" in WM_PATHNAME modeNguyễn Thái Ngọc Duy, Oct 27, 2018
  13. Torsten BögershausenOct 28, 2018
  14. Duy NguyenOct 28, 2018
  15. Junio C HamanoOct 29, 2018
  16. Ævar Arnfjörð BjarmasonOct 29, 2018
  17. Duy NguyenOct 29, 2018

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.