threads / discuss / 47044

clarify documentation of leading "**" in gitignore(5) man page

Subject: clarify documentation of leading "**" in gitignore(5) man page

## tl;dr

One message between Oct 27, 2017 and Oct 27, 2017.

replies: 0people: 1as markdown or json

David Prager Branner· Oct 27, 2017, 14:51 UTC · lore
I've long been confused by something in the man page for gitignore. I think it's unclear and I'd like to propose a change. The passage is this (source at https://git.kernel.org/pub/scm/git/git-manpages.git/tree/man5/gitignore.5):
Show 9 quoted lines
> Two consecutive asterisks ("**") in patterns matched against full
> pathname may have special meaning:
>
> o   A leading "**" followed by a slash means match in all directories.
>     For example, "**/foo" matches file or directory "foo" anywhere, the
>     same as pattern "foo". "**/foo/bar" matches file or directory "bar"
>     anywhere that is directly under directory "foo".
>
> ...
In the first paragraph, it would be clearer to specify:
> Two consecutive asterisks ("**"), in patterns matched against a full
> pathname, are a wildcard representing some arbitrary number of nested
> directories within that pathname:
In the second paragraph, I suggest removing the first pattern, "**/foo", since it is completely redundant. There are no circumstances when "**/foo" is necessary in place of plain "foo", and its presence muddies discussion.
Leading "**" may represent nested directories in a pathname, but is useful only before a _pattern_ containing nested directories. I suggest making that explicit. Here is how I propose to rewrite it:
Show 5 quoted lines
> o   A leading "**", followed by a slash and a pattern containing nested
>     directories, means match that pattern in all pathnames.
>     For example, "**/foo/bar" matches file or directory "bar"
>     anywhere that is directly under directory "foo". It would match
>     "foo/bar", "other/foo/bar", "src/foo/bar/scram/gravy".
Thanks.
- dpb

← back to recent threads