git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Typo in the .gitignore docs?
@ 2019-03-30 19:35 Dr. Adam Nielsen
  2019-03-31  9:54 ` Duy Nguyen
  0 siblings, 1 reply; 5+ messages in thread
From: Dr. Adam Nielsen @ 2019-03-30 19:35 UTC (permalink / raw)
  To: git

Hi everyone,

I think there is a typo in the gitignore docs.

Its stated on https://git-scm.com/docs/gitignore that

>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).

I think that maybe two things are not 100% correct. First I think it
should be "If the pattern does contain" instead of "does not contain".
Secondly, I think it should be mentioned that this is only true for
slashes that are not a trailing slash.

You find discussions about this at
https://github.com/git/git-scm.com/issues/1332 and at
https://stackoverflow.com/a/41761521/2311074

Here is my proposal for an alternative, maybe more clear version:

>Whenever you have a string that contains a non-trailing slash "/" , its always considered from
>the root. There is no difference between foo/bar and /foo/bar. The pattern foo/ is not
>considered from the root, because it has no non-trailing slash "/".
>One may match a path that does not start at the root by using "**" (see below).

Also since we are on it, I would suggest to reduce

>If the pattern ends with a slash, it is removed for the purpose of the following description, but it
>would only find a match with a directory. In other words, foo/ will match a directory foo and
>paths underneath it, but will not match a regular file or a symbolic link foo (this is consistent
>with the way how pathspec works in general in Git).

to

>If the pattern ends with a slash, it would only find a match with a directory. In other words, foo/
>will match a directory foo and paths underneath it, but will not match a regular file or a
>symbolic link foo.

What do you think?

Best regards,
Adam

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-04-01  9:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-30 19:35 Typo in the .gitignore docs? Dr. Adam Nielsen
2019-03-31  9:54 ` Duy Nguyen
2019-03-31 10:04   ` Duy Nguyen
     [not found]   ` <CAKrvxcWFtA7pT++pJRT1ccOwUVzqvD1o0xeXC45em__VHte6pQ@mail.gmail.com>
2019-04-01  0:46     ` Duy Nguyen
2019-04-01  9:02       ` Dr. Adam Nielsen

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).